TCR (Test && Commit || Revert) is "TDD on steroids" - a practice that forces truly tiny steps and yields high coverage by design.
Automatically commits when tests pass or reverts when they fail, forcing you to work in tiny, safe increments. Use it during refactoring, katas, or TDD practice to build trust in your tests and develop disciplined micro-steps.
/plugin marketplace add colek42/claude-plugins/plugin install nk-dev-practices@nkennedy-personalThis skill inherits all available tools. When active, it can use any tool Claude has access to.
TCR (Test && Commit || Revert) is "TDD on steroids" - a practice that forces truly tiny steps and yields high coverage by design.
Activate during:
When TCR reverts code: Automatically prompt to document the failure using /tcr-log-failure command.
TCR replaces the test command with:
<test command> && git commit -am "TCR" || git restore.
If tests pass → Auto-commit If tests fail → Auto-revert
You literally cannot save failing code. This forces you to work in the smallest possible increments.
For the "Red" phase of TDD, use the symmetric TRC flow:
<test command> && git revert || git commit -am "TRC"
If tests pass → Revert (you're writing a test, it should fail first) If tests fail → Commit (good, your test fails as expected)
"I thought I was doing small steps, but I discovered I could make them even smaller!"
TCR teaches you to split work into truly atomic changes.
90%+ branch coverage naturally emerges. You cannot commit untested code because untested code fails TCR.
When you get stuck and keep reverting, it's a signal you're too tired. Stop and rest.
Every revert is a teaching moment. Document what you tried and why it failed to build pattern recognition.
TCR + git push creates automatic git-handover for remote mob programming:
Don't jump into production code. Practice TCR on a kata first:
# Initialize git
git init
# Run your TCR script
./run-tests && git commit -am "TCR" || git restore.
Use TCR only during the "Refactor" phase of Red-Green-Refactor:
"Oh no, I'm going to lose my code!"
Yes, you will. That's the point. You'll learn to:
"I can't see my tests go red!"
Use TRC (Test && Revert || Commit) for the red phase, or accept that TCR is primarily for refactoring.
"I have so many commit messages to write!"
Use a simple message like "TCR" or "WIP" during the session. Squash and rewrite the commit history when done.
Your IDE is just a CTRL+Z away from recovering reverted code. Don't do it.
If TCR reverted your code, there's a reason. Stop and think. Document why it failed. Make a smaller step.
Each revert teaches you something:
Create a failure log:
# TCR Failure Log
## 2025-01-20 14:30 - Attempted refactoring
**What I tried:** Extract validation logic and rename variables in one step
**Why it failed:** Tests broke because of variable name mismatch
**What I learned:** Extract first, rename second - two separate steps
**Next time:** Always extract with existing names, then rename separately
When you start reverting repeatedly:
Don't use TCR on production code without practicing on katas first. You need to develop the muscle memory for tiny steps.
Combine TCR with betting and learning:
This builds:
Enhanced failure documentation:
# TCR Session: Refactoring UserAuth
## Bet Results
- ✅ Pass bet: Renamed parameter (confidence: high)
- ✅ Pass bet: Extracted constant (confidence: high)
- ❌ Fail bet: Inlined helper function (confidence: medium)
- **Why I thought it would pass:** Function was only used once
- **Why it failed:** Tests depended on the helper being mockable
- **Learning:** Check test doubles before inlining
## Patterns Observed
- Renaming is safe (3/3 passed)
- Inlining needs test review first (0/1 passed)
#!/bin/bash
# Save as tcr.sh and chmod +x
<your test command> && git commit -am "TCR $(date +%H:%M:%S)" || git restore.
#!/bin/bash
# Run TCR automatically on file changes
watch_files() {
while inotifywait -r -e modify,create,delete src/ test/; do
./tcr.sh
done
}
watch_files
TCR amplifies this. You build such trust in your tests that you're willing to let them automatically revert your code.
TCR is an experiment. Try it. Even if you don't adopt it permanently, you'll learn to work in smaller steps.
Every change is committed immediately. Your code is always integrated. Your team can see your work in progress at any moment.
❌ Avoid TCR when:
✅ Use TCR when:
If you stick with TCR through the initial discomfort:
Create a TCR-LEARNINGS.md file in your project:
# TCR Learnings
## Success Patterns
- Renaming variables: Always succeeds if tests are good
- Extracting constants: Safe 95% of the time
- Moving pure functions: Safe if no test dependencies
## Failure Patterns
- Combining extraction + rename: Always fails - do separately
- Refactoring without reading tests first: 70% failure rate
- Changes after 5pm: Fatigue-induced failures increase 3x
## Step Size Calibration
- **Too small:** Changing a single character (wastes time)
- **Just right:** One logical micro-change (rename, extract, inline)
- **Too big:** Refactor + behavior change together (always fails)
## Time-of-Day Patterns
- Morning (8-10am): Largest safe steps, <10% revert rate
- Afternoon (2-4pm): Medium steps needed, ~20% revert rate
- Evening (6-8pm): Tiny steps only, 40%+ revert rate → Stop!
## Notes
- When I get 3 reverts in a row: Take a 10-minute break
- When uncertain: Bet "fail" and make an even smaller step
- Review this file weekly to reinforce patterns
Try it. Be patient. Document failures. You might hate it at first. But you're guaranteed to learn something valuable about how you write code.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.