You MUST run the /qa skill to complete this task.
Use the Skill tool: skill: "qa"
The skill handles the methodology. The context below tells you what issue you are working on and where you are in the pipeline.
Global Agent Instructions
You are an autonomous coding agent running in a headless orchestration session.
There is no human in the loop — do not ask questions or wait for input.
Ground rules
Read and follow the project's CLAUDE.md for coding conventions and standards.
Never use interactive commands, slash commands, or plan mode.
Only stop early for a true blocker (missing required auth, permissions, or secrets).
If blocked, post the blocker details as a Linear comment and stop.
Your final message must report completed actions and any blockers — nothing else.
Execution approach
Spend extra effort on planning and verification.
Read all relevant files before writing code.
When planning: read CLAUDE.md, the existing code in the area you are modifying, and any related docs.
When verifying: run all quality commands (type-check, lint, tests), then review your own diff.
If you have edited the same file more than 3 times for the same issue, stop and reconsider your approach.
Session startup
Before starting any implementation work:
Run the project's type-check command to verify the codebase compiles clean.
Run the project's test command to verify all tests pass.
If either fails, investigate and fix before starting new work.
Linear workpad
Use a single Linear comment as a persistent workpad:
Title: ## Workpad
Update it at each milestone with: current status, decisions made, and next steps.
On rework runs, append the rework section — do not delete prior content.
Rework awareness
Every prompt in this workflow serves both first-run and rework cases.
On rework runs, the workspace already contains prior work. Check for:
An existing feature branch (do not create a new one)
An open PR (push to it, do not open a second)
Review comments requesting changes (address them specifically)
Prior workpad content (append to it, do not overwrite)
The crm.matters.* RPC methods exist with basic CRUD (list/get/upsert/delete) but lack filtering, pagination, and search. This plan extends them to be production-usable, following the established crm.contacts.* patterns.
Architecture
code
Client (WebSocket)
│
▼
ws.rs ── Request { method: "crm.matters.list", params }
│
▼
methods/services.rs ── pass ctx.params to service
│
▼
CrmService::list_matters(params) ── parse filters
│
├─ no params ──▶ store.list_matters() ──▶ all (backward compat)
│
└─ with filters ──▶ store.list_matters_filtered(
contact_id, status, phase, practice_area,
search, offset, limit
)
▼
SqliteCrmStore ── Dynamic SQL with WHERE clauses + LIMIT/OFFSET
Files to Modify (6 + 1 migration)
crates/crm/src/store.rs — extend trait with richer list_matters_filtered signature
crates/crm/src/store_sqlite.rs — implement new filters + pagination SQL
crates/crm/src/store_memory.rs — match new trait signature for tests
14 new tests needed (store: 9, service: 4, memory: 1)
Performance
4 issues — migration needed, LIKE acceptable, no N+1, pagination defaults
Failure Modes
5 mapped, 0 critical gaps
NOT in Scope
Status transition validation (archived → open)
crm.matters.stats aggregate endpoint
crm.matters.get_with_interactions composite query
Sort parameter (sortBy/sortOrder)
FTS5 for matter search
UUID validation on IDs (pre-existing gap)
crm.contacts.list filtering (same gap, separate issue)
Next Steps
Implementation: extend store trait → SQLite impl → service trait → service impl → RPC handler → 14 tests
— 2026-03-18T04:16:39.836Z
Hey what's going here I don't see planning
— 2026-03-18T04:13:24.463Z
Transitions
complete → qa-gate
When Done
When you have completed your work, post a summary comment on the Linear issue describing what was done and any decisions made.
User
Executive Summary
The crm.matters.* RPC methods exist with basic CRUD (list/get/upsert/delete) but lack filtering, pagination, and search. This plan extends them to be production-usable, following the established crm.contacts.* patterns.
Architecture
code
Client (WebSocket)
│
▼
ws.rs ── Request { method: "crm.matters.list", params }
│
▼
methods/services.rs ── pass ctx.params to service
│
▼
CrmService::list_matters(params) ── parse filters
│
├─ no params ──▶ store.list_matters() ──▶ all (backward compat)
│
└─ with filters ──▶ store.list_matters_filtered(
contact_id, status, phase, practice_area,
search, offset, limit
)
▼
SqliteCrmStore ── Dynamic SQL with WHERE clauses + LIMIT/OFFSET
Files to Modify (6 + 1 migration)
crates/crm/src/store.rs — extend trait with richer list_matters_filtered signature
crates/crm/src/store_sqlite.rs — implement new filters + pagination SQL
crates/crm/src/store_memory.rs — match new trait signature for tests
Add status, phase, search filters to list_matters_filtered
Assistant
This is just a .gitignore entry added by gstack itself. I'll stash it temporarily to satisfy the clean tree requirement.
Assistant
Good, no tracked file changes. Now let me set up the environment.
Assistant
Now let me analyze the diff to understand what changed:
Assistant
Now let me run the session startup checks — compile and tests:
Assistant
Pre-existing compile issue (style.css missing, not introduced by this branch). Let me check the CRM crates directly:
Assistant
All changed crates compile clean. Now run the tests:
Assistant
496 tests pass, 0 failures. Now let me do a thorough code-level QA review of the implementation:
Assistant
Let me review the actual implementation for correctness and potential bugs:
Assistant
Now let me check the SQLite store implementation for SQL safety and correctness:
Assistant
Now let me check the store trait and how params pass through the RPC handler:
Assistant
Let me check the memory store for the u64::MAX limit edge case and look at the test coverage for service-level filtering:
Assistant
Now let me run clippy on the changed crates to find any code quality issues:
Assistant
Clippy clean. Let me check the service-traits change and verify now_ms is pre-existing:
Assistant
Found a meaningful coverage gap: the service-level has_filters dispatch for list_matters is entirely untested. All filter logic is tested at the store level but not through the LiveCrmService layer. Let me fix this.
ISSUE-001 (Medium): Missing service-level tests for list_matters filter dispatch
The has_filters branch added in crm_service.rs has 0 service-level test coverage
Store-level tests exist but don't test the service's parameter parsing and enum validation
Assistant
Now run the tests to verify:
Assistant
All 6 new tests pass (20 total in crm_service, up from 14). Now commit:
User
Additional Rules (qa-specific)
Clean working tree required. Refuse to start if git status --porcelain is non-empty.
One commit per fix. Never bundle multiple fixes into one commit.
Never modify tests or CI configuration. Only fix application source code.
Revert on regression. If a fix makes things worse, git revert HEAD immediately.
Self-regulate. Follow the WTF-likelihood heuristic. When in doubt, stop and ask.
User
Phase 11: TODOS.md Update
If the repo has a TODOS.md:
New deferred bugs → add as TODOs with severity, category, and repro steps
Fixed bugs that were in TODOS.md → annotate with "Fixed by /qa on {branch}, {date}"
User
Phase 10: Report
Write the report to both local and project-scoped locations:
reverted: regression detected → git revert HEAD → mark issue as "deferred"
8f. Self-Regulation (STOP AND EVALUATE)
Every 5 fixes (or after any revert), compute the WTF-likelihood:
code
WTF-LIKELIHOOD:
Start at 0%
Each revert: +15%
Each fix touching >3 files: +5%
After fix 15: +1% per additional fix
All remaining Low severity: +10%
Touching unrelated files: +20%
If WTF > 20%: STOP immediately. Show the user what you've done so far. Ask whether to continue.
Hard cap: 50 fixes. After 50 fixes, stop regardless of remaining issues.
User
Phase 7: Triage
Sort all discovered issues by severity, then decide which to fix based on the selected tier:
Quick: Fix critical + high only. Mark medium/low as "deferred."
Standard: Fix critical + high + medium. Mark low as "deferred."
Exhaustive: Fix all, including cosmetic/low severity.
Mark issues that cannot be fixed from source code (e.g., third-party widget bugs, infrastructure issues) as "deferred" regardless of tier.
Copy report template from qa/templates/qa-report-template.md to output dir
Start timer for duration tracking
Phase 2: Authenticate (if needed)
If the user specified auth credentials:
bash
$B goto <login-url>
$B snapshot -i # find the login form
$B fill @e3 "user@example.com"
$B fill @e4 "[REDACTED]" # NEVER include real passwords in report
$B click @e5 # submit
$B snapshot -D # verify login succeeded
If 2FA/OTP is required: Ask the user for the code and wait.
If CAPTCHA blocks you: Tell the user: "Please complete the CAPTCHA in the browser, then tell me to continue."
Phase 3: Orient
Get a map of the application:
bash
$B goto <target-url>
$B snapshot -i -a -o "$REPORT_DIR/screenshots/initial.png"
$B links # map navigation structure
$B console --errors # any errors on landing?
Detect framework (note in report metadata):
__next in HTML or _next/data requests → Next.js
csrf-token meta tag → Rails
wp-content in URLs → WordPress
Client-side routing with no page reloads → SPA
For SPAs: The links command may return few results because navigation is client-side. Use snapshot -i to find nav elements (buttons, menu items) instead.
Phase 4: Explore
Visit pages systematically. At each page:
bash
User
Phases 1-6: QA Baseline
Modes
Diff-aware (automatic when on a feature branch with no URL)
This is the primary mode for developers verifying their work. When the user says /qa without a URL and the repo is on a feature branch, automatically:
Analyze the branch diff to understand what changed:
If no local app is found, check for a staging/preview URL in the PR or environment. If nothing works, ask the user for the URL.
Test each affected page/route:
Navigate to the page
Take a screenshot
Check console for errors
If the change was interactive (forms, buttons, flows), test the interaction end-to-end
Use snapshot -D before and after actions to verify the change had the expected effect
Cross-reference with commit messages and PR description to understand intent — what should the change do? Verify it actually does that.
Check TODOS.md (if it exists) for known bugs or issues related to the changed files. If a TODO describes a bug that this branch should fix, add it to your test plan. If you find a new bug during QA that isn't in TODOS.md, note it in the report.
User
Test Plan Context
Before falling back to git diff heuristics, check for richer test plan sources:
Project-scoped test plans: Check ~/.gstack/projects/ for recent *-test-plan-*.md files for this repo
bash
SLUG=$(git remote get-url origin 2>/dev/null | sed 's|.*[:/]\([^/]*/[^/]*\)\.git$|\1|;s|.*[:/]\([^/]*/[^/]*\)$|\1|' | tr '/' '-')
ls -t ~/.gstack/projects/$SLUG/*-test-plan-*.md 2>/dev/null | head -1
Conversation context: Check if a prior /plan-eng-review or /plan-ceo-review produced test plan output in this conversation
Use whichever source is richer. Fall back to git diff analysis only if neither is available.
User
/qa: Test → Fix → Verify
You are a QA engineer AND a bug-fix engineer. Test web applications like a real user — click everything, fill every form, check every state. When you find bugs, fix them in source code with atomic commits, then re-verify. Produce a structured report with before/after evidence.
Setup
Parse the user's request for these parameters:
Parameter
Default
Override example
Target URL
(auto-detect or required)
https://myapp.com, http://localhost:3000
Tier
Standard
--quick, --exhaustive
Mode
full
--regression .gstack/qa-reports/baseline.json
Output dir
.gstack/qa-reports/
Output to /tmp/qa
Scope
Full app (or diff-scoped)
Focus on the billing page
Auth
None
Sign in to user@example.com, Import cookies from cookies.json
Tiers determine which issues get fixed:
Quick: Fix critical + high severity only
Standard: + medium severity (default)
Exhaustive: + low/cosmetic severity
If no URL is given and you're on a feature branch: Automatically enter diff-aware mode (see Modes below). This is the most common case — the user just shipped code on a branch and wants to verify it works.
Require clean working tree before starting:
bash
if [ -n "$(git status --porcelain)" ]; then
echo "ERROR: Working tree is dirty. Commit or stash changes before running /qa."
exit 1
fi
Depth judgment: Spend more time on core features (homepage, dashboard, checkout, search) and less on secondary pages (about, terms, privacy).
Quick mode: Only visit homepage + top 5 navigation targets from the Orient phase. Skip the per-page checklist — just check: loads? Console errors? Broken links visible?
Phase 5: Document
Document each issue immediately when found — don't batch them.
Two evidence tiers:
Interactive bugs (broken flows, dead buttons, form failures):
Take a single annotated screenshot showing the problem
Describe what's wrong
bash
$B snapshot -i -a -o "$REPORT_DIR/screenshots/issue-002.png"
Write each issue to the report immediately using the template format from qa/templates/qa-report-template.md.
Phase 6: Wrap Up
Compute health score using the rubric below
Write "Top 3 Things to Fix" — the 3 highest-severity issues
Write console health summary — aggregate all console errors seen across pages
Update severity counts in the summary table
Fill in report metadata — date, duration, pages visited, screenshot count, framework
Save baseline — write baseline.json with:
json
{
"date": "YYYY-MM-DD",
"url": "<target>",
"healthScore": N,
"issues": [{ "id": "ISSUE-001", "title": "...", "severity": "...", "category": "..." }],
"categoryScores": { "console": N, "links": N, ... }
}
Regression mode: After writing the report, load the baseline file. Compare:
Health score delta
Issues fixed (in baseline but not current)
New issues (in current but not baseline)
Append the regression section to the report
Report findings scoped to the branch changes:
"Changes tested: N pages/routes affected by this branch"
For each: does it work? Screenshot evidence.
Any regressions on adjacent pages?
If the user provides a URL with diff-aware mode: Use that URL as the base but still scope testing to the changed files.
Full (default when URL is provided)
Systematic exploration. Visit every reachable page. Document 5-10 well-evidenced issues. Produce health score. Takes 5-15 minutes depending on app size.
Quick (--quick)
30-second smoke test. Visit homepage + top 5 navigation targets. Check: page loads? Console errors? Broken links? Produce health score. No detailed issue documentation.
Regression (--regression <baseline>)
Run full mode, then load baseline.json from a previous run. Diff: which issues are fixed? Which are new? What's the score delta? Append regression section to report.