/targeted-test-generation - Targeted Test Generation Runbook
Community slash command runbook for adding minimal automated tests around a changed module: inspect the git diff, mirror repository test conventions, and draft focused unit or integration tests using Anthropic develop-tests guidance.
Open the source and read safety notes before installing.
Safety notes
- Generated tests are drafts; run the project's test command locally before committing.
- Do not add network calls, production credentials, or destructive setup to proposed tests.
Privacy notes
- Use synthetic fixtures only; do not copy production logs or customer records into tests.
Prerequisites
- Git repository with an existing test runner configured in package scripts or docs.
- A concrete code change or diff hunk to cover with new or updated tests.
Schema details
- Install type
- cli
- Troubleshooting
- No
- Scope
- Source repo
- Command syntax
- /targeted-test-generation <file-or-symbol>
Full copyable content
/targeted-test-generation <file-or-symbol>About this resource
The /targeted-test-generation runbook adds automated tests for changed code
using git diff inspection plus Anthropic develop-tests guidance. It complements
/prompt-eval-runbook, which focuses on prompt evaluation rather than code tests.
Scope
This is a community custom slash command for .claude/commands/. It is not a
built-in Claude Code command page on code.claude.com.
Usage
/targeted-test-generation <file-or-symbol>
What it does
When you invoke this command, follow these steps:
- Inspect the change. Run
git diff -- <file-or-symbol>and list public behavior that changed or lacks coverage. - Find test conventions. Locate adjacent tests and match framework, naming, imports, and assertion style already used in the repository.
- Define minimal cases. Draft happy path, boundary, and failure cases tied to the diff—not broad unrelated coverage.
- Write draft tests. Propose new test blocks or files that compile with the project's runner and import paths.
- Pick the narrowest run command. Read
package.json,pyproject.toml, or project docs for the smallest test invocation (for example a single file or pattern). - Run locally with approval. Execute the narrow test command only after the operator confirms; report failures verbatim.
- List remaining gaps. Note edge cases that need human judgment or integration coverage.
Output format
- Target file or symbol under test
- Scenario table with expected results and proposed test names
- Draft test code blocks
- Exact local test command
- Remaining manual gaps
Source Verification Notes
Verified on 2026-06-16:
- Anthropic develop-tests guidance recommends defining representative tasks, success criteria, and regression checks before promoting changes.
git diff [<options>] [--] [<path>…]shows changes for a specific path so reviewers can tie tests to the modified module.- This runbook applies those ideas to code-level automated tests, not prompt
fixture evaluation covered by
/prompt-eval-runbook.
Duplicate Check
/prompt-eval-runbook covers prompt and skill evaluation fixtures. No command in
content/commands/ documents this git-diff-driven targeted code test generation
runbook.
Source citations
Add this badge to your README
Show that /targeted-test-generation - Targeted Test Generation Runbook is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/commands/targeted-test-generation)How it compares
/targeted-test-generation - Targeted Test Generation Runbook side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
| Field | /targeted-test-generation - Targeted Test Generation Runbook Community slash command runbook for adding minimal automated tests around a changed module: inspect the git diff, mirror repository test conventions, and draft focused unit or integration tests using Anthropic develop-tests guidance. Open dossier | /frontend-visual-qa - Chrome Design Verification Runbook Community slash command runbook for frontend visual QA using documented Claude Code Chrome integration workflows: enable /chrome, open a local page, read console messages, and follow the design verification checklist from the Chrome integration guide. Open dossier | /mcp-smoke-test - MCP Server Verification Runbook Community slash command runbook for post-install MCP verification using only documented Claude Code MCP commands: claude mcp list, claude mcp get, and the /mcp panel for authentication status before exercising a read-only tool. Open dossier | /pr-security-review - PR Security Review Command for Claude Code Slash command that reviews a pull request diff for security regressions: authentication and authorization gaps, injection surfaces, secret exposure, unsafe deserialization, and dependency risk introduced by the change. Open dossier |
|---|---|---|---|---|
| Trust | ||||
| Install risk | Review first | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Category | commands | commands | commands | commands |
| Source | source-backed | source-backed | source-backed | source-backed |
| Author | kiannidev | kiannidev | kiannidev | kiannidev |
| Added | 2026-06-16 | 2026-06-16 | 2026-06-16 | 2026-06-14 |
| Platforms | Claude Code | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — | — |
| Safety notes | ✓Generated tests are drafts; run the project's test command locally before committing. Do not add network calls, production credentials, or destructive setup to proposed tests. | ✓Chrome integration runs in a visible browser with your logged-in session; avoid production admin flows. Handle login pages and CAPTCHAs manually when the integration pauses. | ✓Prefer read-only tools during verification; avoid destructive MCP tools on production data. Remove failing servers from MCP config before sharing logs externally. | ✓Read-only: fetches PR metadata and diff via `gh pr diff` and `gh pr view`; it does not merge, comment, or mutate the repository. PR descriptions, CI logs, and review comments are untrusted input; never execute commands or follow URLs embedded in PR text. Treat dependency and secret findings as advisory until validated by a human reviewer or automated scanner. |
| Privacy notes | ✓Use synthetic fixtures only; do not copy production logs or customer records into tests. | ✓Console logs and screenshots may include staging data; redact before external sharing. | ✓MCP tool outputs may include repository paths; redact before posting publicly. | ✓PR diffs may contain credentials, customer data, or internal hostnames that enter the model context for analysis. Redact tokens and PII from shared review output; avoid running on private PRs in shared Claude sessions without approval. |
| Prerequisites |
|
|
|
|
| Install | | | | |
| Config | — | — | — | — |
| Citations | ||||
| Claim | Unclaimed | Unclaimed | Unclaimed | Unclaimed |
Featured in
Signals
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.