This file provides guidance to AI coding agents (Claude Code, GitHub Copilot, Cursor, etc.) when working with code in this repository.
TCR (Test && Commit || Revert) is a programming workflow tool written in Go that enforces baby-step development practices. The concept was originally developed by Kent Beck, Oddmund Strømme, Lars Barlindhaug, and Ole Johannessen. This tool automatically commits code changes when tests pass, or reverts them when tests fail, encouraging developers to work in small, incremental steps.
The project includes both a CLI tool written in Go and an experimental Angular web interface.
The project is organized as a multi-module monorepo with dependencies:
-
src/ - Main Go application (depends on webapp)
- Entry point:
main.go - CLI commands:
cmd/directory using Cobra framework - Core engine:
engine/directory - Language/toolchain support:
language/andtoolchain/directories - Version control integration:
vcs/directory - Web interface:
http/directory - Configuration:
config/andsettings/directories - Events:
events/directory for event-driven architecture - Filesystem:
filesystem/directory with fsnotify for watching - Reporting:
report/,xunit/,stats/directories
- Entry point:
-
webapp/ - Angular-based web interface (experimental)
- Angular 21+ TypeScript frontend
- Real-time communication via WebSocket
- Displays TCR cycle status, timer, and role management
- Built output embedded in Go binary via static assets
-
tcr-doc/ - Documentation generator (depends on src)
-
examples/ - Language/toolchain examples
- Supports multiple programming languages
- Multiple build tools per language (Maven, Gradle, Cargo, etc.)
- Each example includes README and sample code
- Serve as integration tests
-
doc/ - Generated command documentation (Markdown)
-
dev-doc/ - Development documentation
-
tools/ - Utility scripts and tools
-
auto-install/ - One-liner installation scripts
make help # Show available targets
make prepare # Full pipeline: deps, tidy, lint, build, doc, test
make build # Build all production modules (webapp + src)
make test # Run tests for all production modules
make lint # Run linter on all modules
make doc # Generate command line documentation
make release # Create release using GoReleaser
make snapshot # Create snapshot releasecd src
make build # Build TCR binary with version info
make test # Run all tests with coverage
make test-short # Run short tests only
make lint # Run golangci-lint
make run # Test locally built TCR on testdata
make tidy # Run go mod tidy
make cov # Show coverage report in browser
make deps # Download dependencies
make vet # Run go vetcd webapp
make setup # Install npm dependencies
make build # Build for production (output to Go's static assets)
make run # Start development server
make test # Run Vitest unit tests
make lint # Run ESLint
make cov # Run tests with coverage
make clean # Clean build artifacts
make deps # Update dependenciesUse ./src/tcr-local script to test locally built binary on example projects.
- Go 1.26+ (required)
- Cobra - CLI framework
- Viper - Configuration management
- Gin - Web framework for HTTP API
- go-git - Git operations
- fsnotify - File system watching
- WebSocket - Real-time communication with frontend
- testify - Testing framework
- Node.js 22 (for development)
- Angular 21+
- TypeScript
- Vitest - Testing
- GoReleaser - Release automation
- golangci-lint - Go linting
- gotestsum - Enhanced test output
- Use testify framework for assertions
- Tests tagged with
test_helperbuild tag - Coverage reports in
src/_test_results/ - Run specific tests:
go test -tags=test_helper ./path/to/package - Integration tests with real VCS operations
- Test data in
src/testdata/
- Vitest for unit tests
- Run with
npm testormake testin webapp/ - ESLint for code quality
- Coverage reporting
- Examples in
examples/directory serve as integration tests - Go test fixtures in
src/testdata/
TCR uses hierarchical YAML configuration:
- Built-in defaults (embedded in binary)
- Global config:
~/.tcr/config.yml - Repository config:
<repo>/.tcr/config.yml - Command-line flags (highest priority)
.tcr/config.yml- Main TCR settings.tcr/language/*.yml- Language definitions (source/test file patterns).tcr/toolchain/*.yml- Toolchain definitions (build/test commands)
Key configuration sections:
- Language and toolchain detection
- VCS integration (Git, Perforce)
- Commit message templates
- Test timeout settings
- File filtering rules
TCR supports multiple programming languages with multiple build tools:
- C++: cmake, bazel
- C#: dotnet
- Elixir: mix
- Go: go-tools, gotestsum, make, bazel
- Haskell: stack
- Java: gradle, gradle-wrapper, maven, maven-wrapper, make, bazel
- JavaScript: yarn
- Kotlin: gradle, gradle-wrapper, maven, maven-wrapper
- PHP: phpunit
- Python: pytest, bazel
- Rust: cargo, nextest
- Scala: sbt
- TypeScript: yarn
-
Create
.tcr/language/<name>.ymlwith:toolchains.default- Default toolchaintoolchains.compatible-with- List of compatible toolchainssource-files.directories- Where source files aresource-files.patterns- Regex patterns for source files (RE2 syntax)test-files.directories- Where test files aretest-files.patterns- Regex patterns for test files
-
Add language implementation in
src/language/if custom logic needed -
EXECUTE:
make lint && make test
- Create
.tcr/toolchain/<name>.ymlwith build and test commands for each OS/arch - Add toolchain implementation in
src/toolchain/if needed - EXECUTE:
make lint && make test
tcr solo- Run TCR in solo modetcr mob- Run TCR in mob programming modetcr one-shot- Run TCR once and exittcr web- Start web interface
tcr check- Check TCR configuration and environmenttcr config- Manage TCR configurationtcr info- Display TCR informationtcr log- Show TCR activity logtcr stats- Display TCR statisticstcr retro- Generate retrospective report
- Automatic commits on test pass
- Automatic reverts on test failure
- Full support with automatic commit/revert
- Note: TCR commits are deliberately unsigned (would be impractical with frequent auto-commits)
- Use
--vcs=p4flag - Requires P4 client configuration
- Limited support: no auto-push, log, or stats support
- Set
P4IGNORE=.gitignoreto avoid committing build artifacts
- Create
src/cmd/<command>.go - Define Cobra command with flags
- Wire up to root command in
src/cmd/root.go - Add implementation in appropriate package
- Regenerate docs:
cd tcr-doc && make doc - EXECUTE:
make lint && make test
- Core logic in
src/engine/ - Event-driven architecture via
src/events/ - Update tests in corresponding
_test.gofiles - EXECUTE:
make lint && make test
- Start Go backend:
cd src && ./tcr-local web -T=http - Start Angular dev:
cd webapp && npm start - Make changes in
webapp/src/ - EXECUTE:
cd webapp && make lint && make test
- Reproduce issue with test case
- Fix in appropriate module
- Ensure tests pass on all platforms
- Update documentation if needed
- EXECUTE:
make lint && make test
- Design with TCR principles in mind
- Add CLI command in
src/cmd/if needed - Implement core logic in appropriate module
- Add comprehensive tests
- Update web interface if applicable
- EXECUTE:
make lint && make test
CRITICAL: After ANY code change (modification, addition, deletion, refactoring, formatting, import organization, etc.), you MUST ALWAYS execute these quality gates to prevent regressions:
-
Run Linter:
make lint- Must pass with 0 issues
- Applies to both Go and TypeScript/Angular code
- Non-negotiable - fix all linting errors before proceeding
-
Run Tests:
make testormake test-shortfor Go changes- All tests must pass
- No skipped tests due to failures
- Verify test coverage is maintained
-
Verify Build:
make build(if significant changes)- Ensure project still compiles and builds successfully
- Check both webapp and Go modules
# After any Go code changes
cd src && make lint && make test-short # or make test for full suite
# After webapp changes
cd webapp && make lint && make test
# After project-wide changes
make lint && make test- Import organization/formatting (like
goimports) - Code refactoring or restructuring
- Adding/removing dependencies
- Modifying configuration files
- Updating documentation that affects code
- Any file modifications in
src/,webapp/, orexamples/
- If linter fails: Fix all issues before proceeding
- If tests fail: Investigate and fix, don't ignore
- If build fails: Resolve compilation errors immediately
- Document any issues encountered and their resolution
Remember: The TCR philosophy applies to development too - small, verified steps prevent large regressions.
Every AI agent MUST follow this pattern:
- Make the requested changes
- Execute quality gates:
make lint && make test - Report results with ✅ or ❌ status
- Fix any issues found
- Re-run quality gates until all pass
Never skip quality gates, even for "simple" changes like formatting or imports.
- Events defined in
src/events/ - Publishers emit events via event bus
- Subscribers listen for specific events
- Used for engine → UI communication
src/role/handles driver/navigator roles- Synchronized across participants in mob mode
- Timer in
src/timer/for driver rotation
src/filesystem/uses fsnotify- Monitors source and test directories
- Triggers TCR cycle on changes
src/report/handles test outputsrc/xunit/parses xUnit XML formatsrc/stats/tracks commit/revert statistics
- Build Order: webapp must build before src (embedded assets)
- Test Tags: Go tests require
-tags=test_helperflag - Coverage Files: Multiple coverage files for SonarCloud vs local use
- Version Info: Set via ldflags in build, defined in
src/settings/ - Cross-Platform: Commands defined per OS/arch in toolchain configs
- Web Port: Default 8483, configurable via
--port-number
- Go 1.26+
- Node.js 22 (for webapp)
- golangci-lint (for linting)
- gotestsum (optional, better test output)
- GoReleaser (for releases)
**/*_test.go- Go test files**/*.spec.ts- Angular test files**/testdata/**- Test fixtures and data directories**/.tcr/**- TCR configuration**/Makefile- Build configuration**/README.md- Documentation filessrc/_test_results/- Go test outputswebapp/dist/- Angular build output
Examples in examples/ demonstrate TCR usage with different language/toolchain combinations. Each example:
- Has a complete project setup
- Includes README with TCR usage
- Serves as integration test
- Can be run with locally built TCR using
./src/tcr-local
- GitHub Actions workflows in
.github/workflows/ - Go tests, linting, and builds
- Angular builds and tests
- SonarCloud quality scanning
- Coveralls coverage reporting
- GoReleaser for multi-platform releases
- Dependabot for dependency updates
- Automated: GitHub Actions with GoReleaser
- Manual:
make releaseormake snapshot - Platforms: Windows, macOS, Linux (multiple architectures)
- Distribution: GitHub releases + package managers
- Testing: All changes should include tests
- Documentation: Update relevant docs in
doc/anddev-doc/ - Linting: Code must pass all linters
- Baby Steps: Follow TCR principles during development
- Cross-Platform: Ensure compatibility across OS platforms
- Quality Gates: Always run
make lint && make testafter changes
This project emphasizes clean architecture, comprehensive testing, and cross-platform compatibility while maintaining the core philosophy of encouraging small, incremental development steps.