Skip to main content
commandsSource-backedReview first Safety Privacy

TDD Workflow Custom Command for Claude Code

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.

by JSONbored·added 2025-10-25·
HarnessClaude Code
Invocation:Create .claude/commands/tdd-workflow.md, then run: /tdd-workflow add a slugify() helper
Review first review before installing

Open the source and read safety notes before installing.

Citation facts

Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.

Source URLs
https://code.claude.com/docs/en/slash-commands, https://github.com/JSONbored/awesome-claude/blob/main/content/commands/tdd-workflow.mdx
Safety notes
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
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.
Author
JSONbored
Claim status
unclaimed
Last verified
2025-10-25

Decision playbook

Review trust signals before you adopt

Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.

Compare context
Selected

0

Current score

78

Baseline

Delta

No baseline selected

No major trust-signal divergence detected in the current selection.

Source and provenance checks

Complete

Confirm ownership and provenance before trusting install instructions.

  • Source link availableRequired

    Open the canonical repository and verify ownership.

    Done
  • Source provenance statusRequired

    Marked as source-backed.

    Done
  • Metadata reviewed

    Registry metadata indicates a reviewed listing.

    Done

Safety and privacy checks

Complete

Validate risk disclosures before installation or API wiring.

  • Safety notes presentRequired

    Review the listed safety guidance before running commands.

    Done
  • Privacy notes presentRequired

    Review data handling notes before connecting accounts or secrets.

    Done
  • Trust level risk gateRequired

    Trust level does not block evaluation.

    Done

Package and install checks

Needs review

Check package metadata and artifact integrity signals.

  • Install payload available

    Install or copy payload is available for review.

    Done
  • Package verification flag

    No package verification flag provided.

    Pending
  • Checksum metadata

    No checksum provided for downloaded artifact.

    Pending

Compare-driven decision checks

Needs review

Use compare context to validate trade-offs before adoption.

  • Compare tray has multiple entries

    Add at least one more entry to compare trust differences.

    Pending
  • Baseline comparison available

    No baseline peer selected yet.

    Pending
  • Diverging trust signals identified

    No major trust-signal divergence found.

    Pending

Setup at a glance

Copy & paste

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

Balanced adoption plan

Current risk score 16/100. Use staged verification before broader rollout.

Risk 16

Pre-adoption checks

Validate source and review signals before any execution.

  • Confirm source provenanceRequired

    Source URL/provenance metadata is present.

    Done
  • Confirm metadata review state

    Listing has review metadata.

    Done
  • Verify install payload

    Install/config payload exists and can be inspected.

    Done

Security checks

Confirm safety, privacy, and package integrity signals.

  • Review safety notesRequired

    Safety notes are present.

    Done
  • Review privacy notesRequired

    Privacy notes are present.

    Done
  • Verify package integrity metadata

    No package verification/checksum metadata.

    Pending

Rollout

Adopt in controlled steps based on the selected plan.

  • Run in isolated sandbox firstRequired

    Use a constrained sandbox and observe behavior across multiple tasks.

    Pending
  • Roll out graduallyRequired

    Roll out to a small cohort before wider usage.

    Pending
  • Set monitoring and fallback

    Define rollback path and monitor errors after adoption.

    Pending

Evidence readiness

Evidence readiness matrix · balanced

Required evidence gates are covered (5/6 signals complete).

Risk 15

Source provenance

Present

Source repository/provenance is listed.

Required in this preset

Metadata review

Present

Review metadata is present.

Required in this preset

Safety notes

Present

Safety notes are present.

Required in this preset

Privacy notes

Present

Privacy notes are present.

Optional in this preset

Package integrity

Missing

Package integrity metadata is missing.

Optional in this preset

Install payload

Present

Install payload is available.

Required in this preset

Required evidence gates are covered for this preset.

Decision timeline

Decision timeline · balanced

5/6 steps complete with no blocking gaps for this preset.

Risk 14

triage

Confirm source provenanceRequired

Source/provenance metadata is available.

Done

triage

Check metadata review statusRequired

Review metadata is available.

Done

verify

Review safety notesRequired

Safety notes are available.

Done

verify

Review privacy notes

Privacy notes are available.

Done

verify

Validate package integrity metadata

Package integrity metadata is missing.

Pending

rollout

Verify install payload and commandsRequired

Install payload is available.

Done

No required blockers for this timeline preset.

Safety & privacy surface

Safety & privacy surface

3 safety and 1 privacy notes across 3 risk areas. Review closely: permissions & scopes.

3 areas
  • SafetyPermissions & scopesThe 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.
  • SafetyLocal filesClaude 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.
  • SafetyGeneralIf you extend the prompt with auto-commit or deploy steps, add explicit safety review; the base recipe does not commit or push.
  • PrivacyLocal filesThe 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.

Safety notes

  • 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

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

Schema details

Install type
copy
Reading time
11 min
Difficulty score
100
Troubleshooting
Yes
Breaking changes
No
Skill and platform metadata
Retrieval sources
https://code.claude.com/docs/en/slash-commandshttps://code.claude.com/docs/en/common-workflows
Runtime and command metadata
Command syntax
Create .claude/commands/tdd-workflow.md, then run: /tdd-workflow add a slugify() helper
Full copyable content
/tdd-workflow add a slugify() helper that strips punctuation

About this resource

/tdd-workflow is not a built-in Claude Code command. There is no shipped TDD command and no built-in TDD flags. This entry is a custom slash command recipe: you save a Markdown prompt file in your repo and Claude Code exposes it as /tdd-workflow. It works by injecting a fixed red-green-refactor prompt into the session, then letting Claude drive your existing test runner.

Custom commands are documented here: https://code.claude.com/docs/en/slash-commands

How custom commands work

  • A file at .claude/commands/<name>.md (project scope, checked into the repo) or ~/.claude/commands/<name>.md (personal scope) becomes the slash command /<name>. The command name is the file name without the .md extension.
  • The Markdown body is the prompt that gets sent to Claude when you invoke the command.
  • Optional YAML frontmatter controls behavior. Documented fields include description, argument-hint, arguments, allowed-tools, disallowed-tools, disable-model-invocation, model, and shell.
  • Arguments are substituted into the body: $ARGUMENTS expands to everything you typed after the command; $1/$2 (shorthand for $ARGUMENTS[1]/$ARGUMENTS[2], 0-based) access positional arguments; named placeholders like $feature work when you declare them in the arguments frontmatter.
  • The body can run shell commands at expansion time with !`command` and reference files with @path/to/file.

Note: As of the current docs, custom commands have been merged into skills. A file at .claude/commands/tdd-workflow.md and a skill at .claude/skills/tdd-workflow/SKILL.md both create /tdd-workflow and behave the same way; existing .claude/commands/ files keep working. Use the skill form if you want supporting files or automatic invocation.

Create the command

Save this as .claude/commands/tdd-workflow.md:

---
description: Drive a red-green-refactor TDD loop for the requested change
argument-hint: [feature description]
allowed-tools: Read, Edit, Write
disable-model-invocation: true
---

Follow strict test-driven development for: $ARGUMENTS

1. RED — Before writing any implementation, add focused failing tests that
   describe only the requested behavior. Run the project's test command and
   show me the failing output. Do not implement yet.
2. GREEN — Write the minimum implementation needed to make those tests pass.
   Re-run the tests and show that they pass. Do not add behavior the tests
   do not require.
3. REFACTOR — Clean up names and structure while keeping the tests green.
   Re-run the tests after refactoring.

Use the test framework already configured in this project. First inspect the
project's test scripts or documented test command with me, then run only the
exact command I approve. Stop and ask me before changing test configuration,
adding new dependencies, or running a different command.

disable-model-invocation: true keeps Claude from triggering the loop on its own; you invoke it deliberately. The base recipe intentionally does not pre-approve Bash test commands. Let Claude Code prompt you on the first run, review the exact command and project script it will execute, and only then approve or narrow the command to your actual runner (Jest, Vitest, pytest, go test, etc.).

Invoke it

/tdd-workflow add a slugify() helper that strips punctuation and lowercases

Everything after the command name becomes $ARGUMENTS. Claude then walks the red-green-refactor steps from the prompt, using whatever test framework your project already has.

If you want positional arguments instead, declare them in frontmatter:

---
description: TDD a change in a specific module
argument-hint: [module] [behavior]
arguments: [module, behavior]
---

TDD the behavior "$behavior" in the module `$module`, red-green-refactor.

Then /tdd-workflow auth "rejects expired tokens" maps $module to auth and $behavior to rejects expired tokens (quote multi-word values).

When to use it

  • You want to enforce test-first discipline in agent-assisted work, so the tests pin down scope before implementation.
  • You repeatedly paste the same "write failing tests, then implement, then refactor" instructions and want a one-keystroke entry point.
  • You want the loop checked into the repo so the whole team shares the same TDD prompt (project-scope .claude/commands/).

Honest limitations

  • This is just a saved prompt. It does not add new flags to Claude Code, does not enforce coverage thresholds, and cannot guarantee Claude writes tests first — it strongly steers the model, but the model still drives.
  • Coverage numbers, watch mode, and auto-commit are features of your test runner and git, not of this command. Wire them in only after reviewing the exact commands and risks; avoid broad wildcard allowed-tools entries for repository-controlled scripts.
  • Behavior depends on your installed test framework and scripts; the command does not install or configure tooling.

Customizing the loop

  • After reviewing your project's scripts, optionally add a narrowly scoped, exact test command to allowed-tools and the prompt to match your stack.
  • Add a final step that runs your linter/formatter if you want those gated too.
  • For E2E or integration variants, create sibling files like .claude/commands/tdd-e2e.md with a prompt tailored to that layer, rather than relying on flags.

Source citations

Add this badge to your README

Show that TDD Workflow Custom Command for Claude Code 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/tdd-workflow.svg)](https://heyclau.de/entry/commands/tdd-workflow)

How it compares

TDD Workflow Custom Command for Claude Code side by side with 3 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 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

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

Use the built-in /context command to inspect Claude Code's context-window usage, plus a custom .claude/commands recipe for repeatable codebase-context analysis before refactors.

Open dossier

Comprehensive code review with security analysis, performance optimization, and best practices validation

Open dossier
Next stepsDiffers
Trust
Review statusReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewed
Package trustPackage not verifiedPackage not verifiedPackage not verifiedPackage not verified
Source provenanceSource-backedSource-backedSource-backedSource-backed
Submitter
Install riskReview firstReview firstReview firstReview first
Notes Safety Privacy Safety Privacy Safety Privacy Safety Privacy
Brand
Categorycommandscommandscommandscommands
Sourcesource-backedsource-backedsource-backedsource-backed
AuthorJSONboredJSONboredJSONboredJSONbored
Added2025-10-252025-09-162025-10-252025-09-16
Platforms
Claude Code
Claude Code
Claude Code
Claude Code
Source repo
Safety notesThe 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.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.The custom /analyze-context command makes Claude read files across your repository; scope it with a path argument to limit how much is pulled into context. Analysis output reflects Claude's reading of the code in that session, not a deterministic static-analysis tool — verify any load-bearing metrics or recommendations against the actual source.Review generated changes and commands before applying them; slash commands can ask the agent to read, write, edit, or run tools in the current project. Limit scope to the intended files and run in a trusted checkout when the command analyzes code, tests, security findings, or generated output.
Privacy notesThe 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.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.Both /context and a custom analysis command operate on whatever files and project memory are loaded in the session; no data leaves your machine beyond the normal Claude Code model request, but file contents you ask Claude to read become part of the conversation context sent to the model.Prompts, source files, logs, errors, dependency metadata, and generated reports may be sent to the configured AI model during command execution. Redact secrets, customer data, private repository details, and proprietary code before sharing command output outside the workspace.
Prerequisites— none listed— none listed— none listed— none listed
Install
/review [options] <file_or_directory>
Config
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed
Open 4 picks in the interactive comparison tool

Signals

Loading live community signals…

More like this, weekly

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