Install command
Not provided
A user-created custom slash command for Claude Code that turns a file or function into a test suite. You create .claude/commands/generate-tests.md and invoke it with /generate-tests; it is a prompt recipe, not a built-in command, and uses no CLI flags.
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Not provided
Config snippet
Not provided
Copy snippet
Provided
Prerequisites
None
Platforms
1 listed
Difficulty
100/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Safety & privacy surface
3 safety and 1 privacy notes across 4 risk areas. Review closely: credentials & tokens, permissions & scopes.
mkdir -p .claude/commands && printf -- '---\ndescription: Generate a test suite for the given file or function\nargument-hint: [file-or-function]\n---\nWrite a thorough test suite for $ARGUMENTS. Match the project'\''s existing test framework and conventions, cover the happy path, edge cases, and error handling, and run the tests.\n' > .claude/commands/generate-tests.mdThere is no built-in /generate-tests (or /test-gen) command in Claude Code, and custom slash commands do not accept CLI-style flags such as --unit, --jest, or --threshold=90. This page describes how to build generate-tests yourself as a custom slash command — a small Markdown prompt recipe you save in your project — following the official Claude Code slash commands / skills documentation.
A custom command is just a Markdown file. The command name comes from the filename: a file at .claude/commands/generate-tests.md creates /generate-tests. (Custom commands have been merged into skills; a skill at .claude/skills/generate-tests/SKILL.md produces the same /generate-tests and is the newer, recommended form, but existing .claude/commands/*.md files keep working identically.)
| Scope | Location | Available in |
|---|---|---|
| Project (shared via git) | .claude/commands/generate-tests.md |
This repository |
| Personal (all your projects) | ~/.claude/commands/generate-tests.md |
Every project on your machine |
The command name is the filename without the .md extension. Subdirectories namespace the command (for example .claude/commands/test/unit.md is invoked as /test:unit).
mkdir -p .claude/commands
Save this to .claude/commands/generate-tests.md:
---
description: Generate a test suite for the given file or function
argument-hint: [file-or-function]
---
Write a thorough automated test suite for $ARGUMENTS.
- Detect and match the project's existing test framework and conventions
(look for jest.config.*, vitest.config.*, pytest.ini, pyproject.toml,
go.mod, etc.). Do not introduce a new framework unless none exists.
- Cover the happy path, edge cases (empty/zero/boundary values), and
error handling.
- Place tests next to existing tests, following the current naming pattern.
- After writing, run the test command and fix any failures.
The $ARGUMENTS placeholder is replaced with whatever you type after the command name. The description and argument-hint frontmatter fields drive the autocomplete UI. These are the real frontmatter fields documented for custom commands/skills — there are no test-type or framework flags.
/generate-tests src/utils/discount.js
/generate-tests "the calculateDiscount function in pricing.ts"
Because the behavior is plain prompt text, you steer test type and framework by what you write in the recipe or in your arguments, not via flags. For example, you can keep one recipe and ask for a specific style at call time:
/generate-tests src/api/users.py — focus on integration tests with pytest fixtures
Or maintain several focused recipes (.claude/commands/test/unit.md, .claude/commands/test/integration.md, .claude/commands/test/edge-cases.md) and call /test:unit, /test:integration, etc.
Custom commands support a documented preprocessing syntax. A line beginning with !`<command>` runs the shell command and inlines its output into the prompt before Claude reads it, and @path/to/file includes a file's contents. This lets the recipe hand Claude the source under test automatically:
---
description: Generate a test suite for the given file
argument-hint: [file]
allowed-tools: Bash(npm test:*), Bash(pytest:*)
---
Existing test layout:
!`ls -R tests __tests__ 2>/dev/null | head -40`
Source to test:
@$ARGUMENTS
Write a thorough test suite for the file above, matching existing conventions,
then run the tests.
allowed-tools grants the listed tools without a per-call permission prompt while the command is active; it does not restrict Claude's other tools. Shell-injection lines (!`...`) can be disabled org-wide with "disableSkillShellExecution": true in settings.
Given a JavaScript function:
function calculateDiscount(price, discountPercentage, customerType) {
if (price <= 0) throw new Error("Price must be positive");
if (discountPercentage < 0 || discountPercentage > 100) {
throw new Error("Discount must be between 0 and 100");
}
const baseDiscount = price * (discountPercentage / 100);
const multiplier = customerType === "premium" ? 1.2 : 1;
return Math.min(baseDiscount * multiplier, price * 0.5);
}
/generate-tests src/pricing.js might produce a Jest suite:
describe("calculateDiscount", () => {
test("calculates a basic discount", () => {
expect(calculateDiscount(100, 10, "regular")).toBe(10);
});
test("applies the premium multiplier", () => {
expect(calculateDiscount(100, 10, "premium")).toBe(12);
});
test("caps the discount at 50% of price", () => {
expect(calculateDiscount(100, 60, "premium")).toBe(50);
});
test("throws on non-positive price", () => {
expect(() => calculateDiscount(-10, 10, "regular")).toThrow(
"Price must be positive",
);
});
test("throws on out-of-range discount", () => {
expect(() => calculateDiscount(100, 105, "regular")).toThrow(
"Discount must be between 0 and 100",
);
});
});
For Python projects the same recipe yields pytest tests using fixtures and @pytest.mark.parametrize. The framework is chosen by matching your project, not by a flag.
Reach for a generate-tests recipe when you repeatedly ask Claude to scaffold tests and want a consistent, project-aware prompt one keystroke away. For one-off test generation you can just ask in chat — the custom command pays off when the instructions (framework detection, naming conventions, coverage expectations, run-and-fix loop) are stable enough to codify.
--mutation/--property-based switch, and no built-in report generation; you get whatever you ask the prompt to produce.Generate Tests Custom Command side by side with 2 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
Next steps differ across entries — use the actions in the table below to copy install commands and source links per resource.
| Field | A user-created custom slash command for Claude Code that turns a file or function into a test suite. You create .claude/commands/generate-tests.md and invoke it with /generate-tests; it is a prompt recipe, not a built-in command, and uses no CLI flags. Open dossier | User-created Claude Code custom slash command recipe for planning deeper tests around a file or function, including edge cases, property-style invariants, regression cases, and mutation-score gaps where the project already supports those tools. Open dossier | A user-created custom slash command that runs a red-green-refactor TDD loop in Claude Code: write failing tests first, implement until they pass, then refactor. Built with the documented custom-command frontmatter and $ARGUMENTS substitution, not a built-in feature. Open dossier |
|---|---|---|---|
| Next stepsDiffers | |||
| Trust | |||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed | Source-backed |
| Submitter | — | — | — |
| Install risk | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — | — |
| Category | commands | commands | commands |
| Source | source-backed | source-backed | source-backed |
| Author | JSONbored | JSONbored | JSONbored |
| Added | 2025-09-16 | 2025-09-16 | 2025-10-25 |
| Platforms | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — |
| Safety notes | ✓The recipe asks Claude to run the test suite, which executes project code and test commands locally; review the source and tests before running, especially in an unfamiliar repository. If you add an allowed-tools field (e.g. Bash(npm test:*)), Claude can run those tool calls without a per-use permission prompt while the command is active. Scope it narrowly. Project-level .claude/commands files are shared via git and run for anyone who trusts the workspace; treat a checked-in command as executable content and review it before trusting the repo. | ✓This recipe asks Claude to inspect and draft tests against local project code; review generated tests before committing them. Run the narrowest relevant test command yourself and verify failures before broadening the suite or changing production code. If you add allowed-tools or dynamic shell injection to the command file, scope those permissions narrowly because the command can run local tools. | ✓The base recipe does not pre-approve Bash commands. Review the project's test scripts first, then approve the exact test command when Claude Code prompts or add a narrowly scoped command only after you trust it. Claude may create and edit test and source files as part of the loop (Read/Edit/Write). Run it in version control so changes are reviewable and reversible. If you extend the prompt with auto-commit or deploy steps, add explicit safety review; the base recipe does not commit or push. |
| Privacy notes | ✓Dynamic-injection lines (!`...`) and @file references send the output of shell commands and the contents of referenced files into the model context; avoid pointing them at files containing secrets, credentials, or other sensitive data. | ✓The target source file, nearby tests, failures, logs, and command arguments may be sent into the model context. Use synthetic fixtures and redacted logs; do not paste production data, credentials, customer records, or private incident details into generated tests. | ✓The command body can read project files via @ references and !`command` injection if you add them; only reference files you are comfortable sending to the model as prompt context. The base recipe asks you to inspect project test scripts instead of injecting package.json automatically. |
| Prerequisites | — none listed | — none listed | — none listed |
| Install | — | | — |
| Config | — | — | — |
| Citations | |||
| Claim | Unclaimed | Unclaimed | Unclaimed |
Source-backed guides for putting this to work.
Set autoMode.hard_deny rules to block risky actions in auto mode.
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.