A structured Test-Driven Development workflow for AI-assisted development:
- Claude Code via slash commands
- Codex via a dedicated
tdd-workflowskill
This repo provides reusable workflow assets and an ai-context/ directory structure that guide you through a strict TDD cycle:
Spec → Test → Research → Implement → Refactor
Each phase produces artifacts that feed into the next, with context management built in to keep Claude effective across long workflows.
Design principle: Each phase runs in a fresh context (/clear between phases). Phases communicate only through artifact files on disk — this prevents the LLM's reasoning from bleeding across phase boundaries, preserving TDD's role separation.
| Command | Purpose |
|---|---|
/start_work |
Begin a work session — routes to the right workflow |
/create_spec |
Generate a specification with acceptance criteria |
/generate_tests |
Create failing tests from the spec (TDD red state) |
/research_implementation |
Analyze the codebase and plan implementation |
/implement |
Write code to make tests pass (TDD green state) |
/refactor |
Optimize and clean up while keeping tests green |
/finish_work |
Clean up artifacts after PR merge |
Clone the repo and run the install script:
git clone https://github.com/damonbanks/TDD-claude-code-workflow.git ~/.claude/TDD-claude-code-workflow
~/.claude/TDD-claude-code-workflow/install.sh --target claudeTo install the Codex skill:
~/.claude/TDD-claude-code-workflow/install.sh --target codexTo pin a specific release:
~/.claude/TDD-claude-code-workflow/install.sh --target claude v1.0.2
~/.claude/TDD-claude-code-workflow/install.sh --target codex v1.0.2To update later:
~/.claude/TDD-claude-code-workflow/update.sh --target claude # latest main
~/.claude/TDD-claude-code-workflow/update.sh --target claude v1.0.2 # specific release
~/.claude/TDD-claude-code-workflow/update.sh --target codex # latest main skill
~/.claude/TDD-claude-code-workflow/update.sh --target codex v1.0.2 # specific skill releaseNotes:
- Claude installs command files into
~/.claude/commands/. - Codex installs skill
tdd-workflowinto~/.codex/skills/tdd-workflow. --targetdefaults toclaudeif omitted.
- Install Claude commands:
~/.claude/TDD-claude-code-workflow/install.sh --target claude - In your project, ensure
ai-context/exists. - Start with:
/start_work - Follow phases:
/create_spec -> /generate_tests -> /research_implementation -> /implement -> /refactor -> /finish_work
- Install Codex skill:
~/.claude/TDD-claude-code-workflow/install.sh --target codex - Restart Codex so the skill is loaded.
- Start with a prompt such as:
Use tdd-workflow to start work on PROJ-123 add user authentication. - Continue by prompting the same phase progression (spec -> tests -> research -> implement -> refactor -> finish).
After installation, invoke the skill directly in Codex prompts. Example requests:
Use tdd-workflow to start work on PROJ-123 add user authentication.
Use tdd-workflow to create a spec for password reset.
Use tdd-workflow to generate failing happy-path tests from ai-context/specs/2026-02-26_PROJ-123_password-reset_spec.md.
The skill definition is in skills/tdd-workflow/ and reuses the same phase contracts as the Claude command set.
Copy files directly into your project:
# From your project root
cp -r /path/to/TDD-claude-code-workflow/commands/ .claude/commands/
cp -r /path/to/TDD-claude-code-workflow/skills/tdd-workflow/ .codex/skills/tdd-workflow/
cp -r /path/to/TDD-claude-code-workflow/ai-context/ ai-context/Use Claude commands when working in Claude Code, or the tdd-workflow skill prompts when working in Codex.
This workflow auto-detects your project's setup at runtime — no configuration required.
Go, TypeScript/JavaScript, Rust, Python, Java/Kotlin, C#/.NET, Ruby, PHP, Elixir, Swift, C/C++, and any other language with a discoverable test framework.
Jira (PROJ-123), GitHub/GitLab Issues (#42), Shortcut (sc-12345), Linear, YouTrack, or any format. Tickets are optional — the workflow works without them.
GitHub, GitLab, Bitbucket, Azure DevOps. PR/MR creation adapts to your platform's CLI or web interface.
Auto-detected from your git history and commitlint config. Supports Conventional Commits, ticket-prefixed, and custom formats.
When you run /start_work, Claude runs a discovery protocol that detects your project's tooling and conventions:
- Language & framework from manifest files (
package.json,go.mod,Cargo.toml, etc.) - Test framework & conventions from existing test files (framework, location, naming patterns, assertion style)
- Build/test/lint commands from
Makefile,package.jsonscripts, CI config, or README - Git platform from remote URL and CI/CD config files
- Commit convention from recent git history and commitlint config
Results are cached in ai-context/project-context.md. This file persists across features — /finish_work does not delete it. Every subsequent command (/create_spec, /generate_tests, /implement, etc.) reads this cached context so it uses the correct test command, commit format, and platform tooling — no re-discovery needed.
If a command is run without /start_work first, it will run discovery on its own and cache the results.
The discovery protocol is defined in commands/_project_discovery.md — it's a reference document, not a slash command.
To override auto-detection, copy ai-context/.workflow-config.yml.template to ai-context/.workflow-config.yml and configure the settings you want to control explicitly.
- New Feature — Full 5-phase TDD cycle with approval gates
- Bug Fix — Streamlined 4-phase workflow (analyze → reproduce → fix → verify)
- Resume Work — Pick up where you left off using saved artifacts
- Read-only exploration is used for spec, bug analysis, research, and refactor assessment — exploration only, requires approval (via AskUserQuestion) before proceeding
- Implementation is used for writing tests, code, and executing refactors
- Artifacts are saved to
ai-context/with a consistent naming convention:YYYY-MM-DD_TICKET-ID_feature-name_type.md(ticket portion is optional) - Context isolation between phases — run
/clearbefore each new phase so the LLM approaches each role (spec author, test writer, researcher, implementer, refactorer) with fresh perspective. Phases communicate only through artifact files inai-context/
See ai-context/WORKFLOW_GUIDE.md for the full guide.
- Claude Code CLI
- Codex CLI (for
--target codexskill install)