Skip to main content
commandsSource-backedReview first Safety Privacy

/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.

by kiannidev·added 2026-06-16·
HarnessClaude Code
Invocation:/targeted-test-generation <file-or-symbol>
Review first review before installing

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
Source repository stats
Scope
Source repo
Runtime and command metadata
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:

  1. Inspect the change. Run git diff -- <file-or-symbol> and list public behavior that changed or lacks coverage.
  2. Find test conventions. Locate adjacent tests and match framework, naming, imports, and assertion style already used in the repository.
  3. Define minimal cases. Draft happy path, boundary, and failure cases tied to the diff—not broad unrelated coverage.
  4. Write draft tests. Propose new test blocks or files that compile with the project's runner and import paths.
  5. 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).
  6. Run locally with approval. Execute the narrow test command only after the operator confirms; report failures verbatim.
  7. 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.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/commands/targeted-test-generation.svg)](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 riskReview firstReview firstReview firstReview first
Notes Safety Privacy Safety Privacy Safety Privacy Safety Privacy
Categorycommandscommandscommandscommands
Sourcesource-backedsource-backedsource-backedsource-backed
Authorkiannidevkiannidevkiannidevkiannidev
Added2026-06-162026-06-162026-06-162026-06-14
Platforms
Claude Code
Claude Code
Claude Code
Claude Code
Source repo
Safety notesGenerated 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 notesUse 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
  • 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.
  • Claude Code 2.0.73+ and Claude in Chrome extension 1.0.36+ on Chrome or Edge.
  • Local dev server reachable from the operator browser session.
  • Server already added with claude mcp add or present in project .mcp.json.
  • Non-production credentials when testing OAuth or remote MCP servers.
  • GitHub CLI (`gh`) authenticated with access to the pull request repository.
  • Pull request number or current branch PR context in a git repository.
  • Permission to read the PR diff, changed files, and lockfile updates.
Install
/targeted-test-generation <file-or-symbol>
/frontend-visual-qa <route-or-host>
/mcp-smoke-test [server-name]
/pr-security-review [pr-number]
Config
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.