writing-test
The writing-test slash command guides developers through creating comprehensive test suites for new features by consulting matching testing documentation templates, gathering requirements context, and systematically building unit and integration tests with 100% coverage targets. Use this command when adding a new feature to ensure tests align with project standards, design requirements, and existing testing patterns before proceeding to code review.
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/codeaholicguy/ai-devkit/HEAD/commands/writing-test.md -o ~/.claude/commands/writing-test.mdwriting-test.md
Review tests using the latest matching `docs/ai/testing/YYYY-MM-DD-feature-{name}.md`. If none exists, use `docs/ai/testing/feature-{name}.md`. Keep it aligned with the base template.
1. **Gather Context** — If not already provided, ask for: feature name/branch, summary of changes (link to design & requirements docs), target environment, existing test suites, and any flaky/slow tests to avoid.
2. **Use Memory for Context** — Search memory for existing testing patterns and prior edge cases: `npx ai-devkit@latest memory search --query "<feature testing strategy>"`.
3. **Analyze Testing Template** — Identify required sections from the selected testing doc. Confirm success criteria and edge cases from requirements & design docs. Note available mocks/stubs/fixtures.
4. **Unit Tests (aim for 100% coverage)** — For each module/function: list behavior scenarios (happy path, edge cases, error handling), generate test cases with assertions using existing utilities/mocks, and highlight missing branches preventing full coverage.
5. **Integration Tests** — Identify critical cross-component flows. Define setup/teardown steps and test cases for interaction boundaries, data contracts, and failure modes.
6. **Coverage Strategy** — Recommend coverage tooling commands. Call out files/functions still needing coverage and suggest additional tests if <100%.
7. **Store Reusable Knowledge** — Save reusable testing patterns or tricky fixtures with `npx ai-devkit@latest memory store ...`.
8. **Update Documentation** — Summarize tests added or still missing. Update the selected testing doc with links to test files and results. Flag deferred tests as follow-up tasks.
9. **Next Command Guidance** — If tests expose design issues, return to `/review-design`; otherwise continue to `/code-review`.AI DevKit · Compare implementation with design and requirements docs to ensure alignment.
AI DevKit · Pre-push code review against design docs.
AI DevKit · Execute a feature plan task by task.
AI DevKit · Scaffold feature documentation from requirements through planning.
AI DevKit · Store reusable guidance in the knowledge memory service.
AI DevKit · Review feature design for completeness.
AI DevKit · Review feature requirements for completeness.
AI DevKit · Update planning docs to reflect implementation progress.