AgentSkillsCN

qstash-lint

对qstash-stress项目进行代码质量检查:构建、审核、测试,以及竞态条件检测。 当用户提出以下需求时使用此功能:(1) 检查代码质量;(2) 执行代码风格检查;(3) 验证构建过程;(4) 运行测试;(5) 检查竞态条件;(6) 在提交前进行验证。 可通过“代码风格检查”“检查代码”“运行审核”“验证构建”“检查竞态条件”“进行验证”等指令触发。

SKILL.md
--- frontmatter
name: qstash-lint
description: |
  Run code quality checks for qstash-stress: build, vet, test, and race detection.
  Use when user asks to: (1) check code quality, (2) run linting, (3) verify build,
  (4) run tests, (5) check for race conditions, (6) validate before commit.
  Triggers: "lint", "check code", "run vet", "verify build", "check for races", "validate".

qstash-lint

Run Go code quality checks for qstash-stress project.

Quick Check (All)

Run all checks in sequence:

bash
go build ./... && go vet ./... && go test ./... && go test -race ./...

Individual Checks

Build Verification

bash
go build ./...

Verifies code compiles without errors.

Static Analysis (go vet)

bash
go vet ./...

Catches common mistakes:

  • Printf format string mismatches
  • Unreachable code
  • Suspicious constructs

Unit Tests

bash
go test ./...

Runs all tests. For verbose output:

bash
go test -v ./...

Race Detection

bash
go test -race ./...

Detects data races. Critical for this project due to:

  • sync.Map usage in tracker
  • Atomic operations for counters
  • Per-message RWMutex locks
  • Concurrent HTTP handlers

Project-Specific Checks

Thread Safety Patterns

Verify these patterns are followed:

  1. Tracker counters: Use atomic.AddInt64, atomic.LoadInt64
  2. TrackingInfo access: Always lock with info.mu.Lock() / info.mu.RLock()
  3. Metrics samples: Protected by m.mu.Lock() / m.mu.RLock()
  4. BehaviorConfig: Protected by b.mu mutex

Common Issues

Unused imports/variables:

bash
go build ./...
# Compiler errors will show unused items

Error handling: Check that io.ReadAll and json.Marshal errors are handled.

Connection reuse: Ensure drainAndClose(resp.Body) is called on HTTP responses.

Pre-Commit Checklist

  1. go build ./... - Compiles
  2. go vet ./... - No warnings
  3. go test ./... - All pass
  4. go test -race ./... - No races
  5. Check for TODO comments that should be addressed