tcr-practice
# TCR: Test && Commit || Revert
What this skill does
# TCR: Test && Commit || Revert
TCR (Test && Commit || Revert) is "TDD on steroids" - a practice that forces truly tiny steps and yields high coverage by design.
## When to Use
Activate during:
- Katas and practice sessions
- Refactoring existing code
- Pure TDD work with fast test suites
- Mob/ensemble programming sessions
- Training others in baby-step programming
**When TCR reverts code:** Automatically prompt to document the failure using `/tcr-log-failure` command.
## What is TCR?
TCR replaces the test command with:
```bash
<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.
## The Flow
### Standard TCR (Refactoring-Focused)
1. Make a tiny code change
2. Run TCR command
3. Tests pass → Code automatically committed
4. Tests fail → Code automatically reverted to last working state
5. **On revert → Document the failure** (what you tried, why it failed, what you learned)
### TRC Variant (TDD Red Phase)
For the "Red" phase of TDD, use the symmetric TRC flow:
```bash
<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)
## Key Benefits
### Forces Baby Steps
> "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.
### High Coverage by Design
90%+ branch coverage naturally emerges. You cannot commit untested code because untested code fails TCR.
### Feedback on Fatigue
When you get stuck and keep reverting, it's a signal you're too tired. Stop and rest.
### Learning from Failures
Every revert is a teaching moment. Document what you tried and why it failed to build pattern recognition.
### Seamless Remote Mobbing
TCR + git push creates automatic git-handover for remote mob programming:
- Every change is committed and pushed
- Next person pulls and continues
- No manual handover ceremony needed
### Sustainable Pace
- Less tiring than traditional development
- Clear stopping points (every commit)
- No fear of losing work (it's all committed)
## Getting Started
### Start with Katas
Don't jump into production code. Practice TCR on a kata first:
```bash
# Initialize git
git init
# Run your TCR script
./run-tests && git commit -am "TCR" || git restore.
```
### Start with Refactoring Only
Use TCR only during the "Refactor" phase of Red-Green-Refactor:
- Write test (normal way)
- Make it pass (normal way)
- **Refactor with TCR** ← Start here
### Challenges You'll Face
**"Oh no, I'm going to lose my code!"**
Yes, you will. That's the point. You'll learn to:
- Make smaller changes
- Trust your tests more
- Work more sustainably
**"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.
## Common Mistakes
### Don't Cheat!
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.
### Don't Ignore Failures
Each revert teaches you something:
- **Immediate documentation:** Write down what failed and why (comment, note, or commit message when you succeed)
- **Pattern recognition:** "I always fail when I try to X and Y together - I need to split them"
- **Step size calibration:** "This type of change needs 3 smaller steps, not 1"
**Create a failure log:**
```markdown
# 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
```
### Don't Push Through Fatigue
When you start reverting repeatedly:
1. **Document the pattern** - Write down what keeps failing
2. You're too tired OR your steps are too big
3. Review your failure log to see if there's a pattern
4. Stop for the day or take a different approach
### Don't Skip the Practice Phase
Don't use TCR on production code without practicing on katas first. You need to develop the muscle memory for tiny steps.
## Advanced: TCRDD (TCR with Deliberate Documentation)
Combine TCR with betting and learning:
1. Make a change
2. **Bet** on whether tests will pass or fail
3. Run TCR
4. **If you lost the bet:** Document why you were wrong
5. See patterns in your failed bets
This builds:
- Confidence in your code
- Understanding of what "safe changes" look like
- A failure catalog you can learn from
**Enhanced failure documentation:**
```markdown
# 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)
```
## Tools
### Simple Script
```bash
#!/bin/bash
# Save as tcr.sh and chmod +x
<your test command> && git commit -am "TCR $(date +%H:%M:%S)" || git restore.
```
### Watch Mode
```bash
#!/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
```
### Open Source Options
- Thomas Deniffel's shell script variations
- Xavier's TCRDD tool (bet on tests, see failures)
- Lars Eckart's JUnit 5 extension
- Murex TCR tool (cross-language, remote mobbing)
## TCR Philosophy
### "Test-Driven Development is a way of managing fear during programming." - Kent Beck
TCR amplifies this. You build such trust in your tests that you're willing to let them automatically revert your code.
### "You're bound to learn something."
TCR is an experiment. Try it. Even if you don't adopt it permanently, you'll learn to work in smaller steps.
### Continuous Integration by Design
Every change is committed immediately. Your code is always integrated. Your team can see your work in progress at any moment.
## When NOT to Use TCR
❌ **Avoid TCR when:**
- Tests are slow (>5 seconds)
- You're learning a new domain/codebase
- You're exploring or spiking
- You're doing big design changes
✅ **Use TCR when:**
- Tests are fast (<2 seconds)
- You're refactoring
- You're implementing well-understood features
- You're practicing or training
- You're mob programming remotely
## The TCR Promise
If you stick with TCR through the initial discomfort:
- You'll discover steps can be smaller than you thought possible
- You'll build unshakeable trust in your tests
- You'll work at a sustainable, less tiring pace
- You'll naturally achieve 90%+ coverage
- You'll integrate continuously without thinking about it
- **You'll build a catalog of learned patterns from documented failures**
## Failure Documentation Template
Create a `TCR-LEARNINGS.md` file in your project:
```markdown
# 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 Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.