Skip to content

Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA

TypeScript
7.1 KB
Raw Blame

/qa for workers, jobs and webhooks: Test → Repair → Verify

Use this workflow when the selected target is a background worker, scheduled job, queue consumer or webhook receiver and the user has asked /qa to find and fix defects. Test with the repository's own commands, clients and queue tools. Do not open a browser or build a new harness. This file is the whole workflow.

Step 1 — Inputs and authority

Parse the request:

Parameter Default Example
Target Infer from the request and repository, or ask ProcessPaymentWebhook, bin/jobs run nightly-export
Mode Full --quick (success + highest-risk changed edge), --regression <previous-report>
Fix tier Standard (critical, high, medium) --quick (critical, high), --exhaustive (all)
Output dir .gstack/qa-reports/ Output to /tmp/qa

Run git status --porcelain. If it is not empty, stop and ask the user to commit, stash, or abort; do only what they choose.

Create the output dir. If it already holds files, create run-YYYYMMDDTHHMMSSZ (UTC) inside it. Never overwrite earlier reports or evidence.

Regression mode needs the previous functional report and its replay evidence. Read them before any probe. A missing, unreadable or wrong-target report blocks regression mode; say so and ask whether to run Full instead.

Step 2 — Isolation and boundaries

  1. Find the documented way to run the target locally: the test queue adapter, bin/rails runner, npm run worker -- --once, a webhook fixture sender.
  2. Use owned state only: a test database, a temp directory, an in-memory or local queue, synthetic accounts and payloads. Before running anything, resolve where the worker reads and writes, and where it sends downstream calls (payment provider, email, other services). If any destination could be production or a real third party, STOP and ask for permission naming the target, operation and effect.
  3. Post a short plan: target, contracts, tools, permitted writes, and the timeout you will give each command (default 60s).

Step 3 — Contract map

Write one row per contract before probing. Sources are docs, types, tests or the user's request; never the current implementation alone.

Contract What to observe
Success The final business effect (row updated, file written, message emitted), not just "job enqueued" or HTTP 2xx
Invalid payload Declared rejection or dead-letter; no partial state change
Signature / auth Valid signature accepted; missing, wrong or replayed signature rejected with no effect
State transitions Initial → intermediate → completed/failed; no forbidden transition
Retry The documented attempts and backoff; correct terminal state; no unbounded retry
Duplicate delivery Same event delivered twice → the documented number of effects
Ordering / concurrency Two competing events in both completion orders → final invariant holds
Partial failure Kill or fail after the first effect, restart → completes once or lands in dead-letter, no duplicate effect

Separate acceptance, enqueue, processing, retry/dead-letter and final effect: an accepted webhook is not a processed one.

Step 4 — Probe loop

For each contract:

  1. Reset the fixture to its initial state and record that state.
  2. Run one probe: the exact command or request, with its timeout. Save exit code or status, stdout and stderr separately under evidence/NNN/, plus a dump of the durable state before and after.
  3. Compare with the contract. Record pass, fail, blocked (prerequisite missing), not run, or inconclusive.
  4. Before the next probe, append one line to exploration.md: what the last probe showed and why the next probe follows from it.
  5. For a fail, replay the exact same command from the same initial state. Fails twice = confirmed defect (ISSUE-NNN). Fails once = "observed once"; keep both runs. Then shrink the input to the smallest payload that still fails.

Quick mode stops after the success contract and the highest-risk changed edge; mark the rest not run. A missing service never counts as a pass.

Step 5 — Triage

Severity: Critical = data loss, duplicate charge/effect, or security exposure; High = the contract fails with no workaround; Medium = fails but recovers on retry or manual action; Low = wrong log/status text with correct effects. Fix confirmed defects within the tier, most severe first. Mark the rest, and anything caused by infrastructure or a third party, as deferred.

Step 6 — Repair loop (one defect at a time)

  1. Diagnose. Using the minimized replay, write the observed versus documented behavior and the causal hypothesis. Read the responsible code; edit only files responsible for this defect. Environment failures and unclear contracts are reported, never "fixed".
  2. Regression test first. Prefer extending an existing test table or fixture for this worker. Match the nearby tests' naming, setup and assertions; mock only unrelated services. Encode the exact failing precondition and assert the documented effect (for duplicates: count the effects). Run it with the project's test command and confirm it fails because of the defect, not a broken fixture or import. Add // Regression: ISSUE-NNN — <defect>.
  3. Fix with the smallest change that makes the test pass. No refactors or new features.
  4. Recheck three things: the regression test, the original replay command, and an adjacent happy path. Inspect the final durable state each time; a job reporting success is not proof. Any failed or unavailable recheck leaves the defect unresolved.
  5. Commit the fix with its test only: fix(qa): ISSUE-NNN — <description>.
  6. Classify: verified (all rechecks passed), best-effort (fix applied, one recheck impossible; say why), reverted (the fix broke another contract: revert only your commit, keep the red test and evidence, mark deferred).

Stop and ask the user after two reverts, after editing a file unrelated to the defect, or after 20 fixes.

Step 7 — Final run

Rerun every affected contract and its adjacent happy path on the final code. Any contract that passed at baseline and now fails is a regression: report it at the top.

Step 8 — Report

Write qa-report-{target}-{YYYY-MM-DD}.md:

  • Header: date, branch and revision, mode, fix tier, runtime and tools, fixture ownership and downstream destinations, duration and stop reason.
  • Contract outcomes: contract and source, exact probe and evidence path, expected → observed, outcome.
  • Findings: for each ISSUE-NNN: severity, intended contract, reproduction (working directory, reset, env var names, exact command or request with synthetic values), observed output and state, evidence, diagnosis, fix status, commit SHA, regression test path with red and green evidence.
  • Discoveries: link exploration.md; list proposed tests not written.
  • Coverage limits and cleanup: contracts not run or blocked and why, remaining risk, owned state removed, anything left behind.

No health score applies to functional targets. Summary line: "QA checked N contracts: P pass, F fail, B blocked; fixed M defects."