Git-native session capture for AI coding agents. Hooks into your Git workflow to capture AI agent sessions as you work. Sessions are indexed alongside commits, creating a searchable record of how code was written.
- Git-native — sessions stored as git objects, searchable with standard tools
- Non-intrusive — hooks into git without modifying your workflow
- Replayable — reconstruct any session from captured data
go test ./... # Run all tests
go test -race ./... # Race detector
go test -coverprofile=c.out ./... # Coverage
go vet ./... # Static analysis
gofumpt -w . # Formatcli/— the cobra command tree (capture, list, search, replay, investigate, …), built bycli.NewRootCmd()and mounted by Hawk ashawk trace ...redact/— secret/PII detection and redactioninternal/— private support packages (git ops, agent launch tracking, etc.)perf/— performance benchmarks
- Go 1.26+, pure Go, no CGO
- Table-driven tests
- Conventional Commits:
feat:,fix:,docs:,refactor:,test: - No
Co-authored-by:trailers (auto-stripped by githook) gofumptformatting enforced in CI- Investigate command has its own docs in
docs/
- Agent launch tests need careful nil handling (nilnil pattern)
- Perfsprint linter is strict — use
fmt.Errorfnoterrors.New(fmt.Sprintf(...)) - Session storage uses git objects — don't modify
.git/directly in tests
- CLI commands use cobra:
cli/contains the command root (NewRootCmd) and subcommands - Error sentinels:
Errprefix, package-levelvarwitherrors.New() - JSON tags on all exported fields:
json:"timestamp",json:"session_id"— snake_case in JSON, CamelCase in Go - Time formatting: use
time.RFC3339for display,"20060102_150405"for filenames - Redaction package:
redact/handles secret detection — pattern names usePatternsuffix:secretPattern,credentialedURIPattern
- Library, not a binary: trace ships inside Hawk; there is no standalone
tracebinary - Git-native storage: sessions stored as git objects on
trace/checkpoints/v1orphan branch — never on the working branch - Config in
.trace/directory:settings.json(committed) +settings.local.json(gitignored) - Redaction is multi-layered: entropy-based (
entropyThreshold = 4.5), pattern-based (JWT, base64, DB URIs), keyword-based (password, secret) - Mise-based dev tooling:
mise.tomldefines tasks —mise run test,mise run test:ci,mise run lint
- Integration tests:
cli/integration_test/(build tagintegration) — full command flows - Nilnil pattern: agent launch functions return
(T, error)where both can be nil — test with explicit nil checks - Git-dependent tests: some tests need a real git repo — use
t.TempDir()+git initfor isolation - Redaction tests:
redact/redact_test.gotests secret detection patterns — cover entropy edge cases, placeholder exclusion - Bench tests:
redact/redact_bench_test.go— performance-critical path, benchmark before changing regex patterns - Perfsprint linter: enforced in CI —
errors.New(fmt.Sprintf(...))must befmt.Errorf(...)instead
- Safe to refactor: redaction patterns in
redact/— add new patterns, tune entropy threshold - Safe to refactor: commands in
cli/— cobra command structure, add subcommands freely - Do not touch:
trace/checkpoints/v1branch name — hardcoded in consumers and git hooks - Do not touch:
.trace/settings.jsonschema — committed config, changing breaks existing repos - Do not touch: the
clipackage import path — Hawk importsgithub.com/GrayCodeAI/trace/cli - When adding agents: update
cli/agent/— each agent has its own integration file - When adding redaction patterns: add to
redact/redact.gowith corresponding test inredact/redact_test.go
| What | Where |
|---|---|
| Command tree root | cli/ (NewRootCmd); mounted by Hawk as hawk trace ... |
| CLI commands | cli/ (enable, disable, status, checkpoint, session, agent, doctor) |
| Secret redaction | redact/redact.go (entropy, patterns, DB URIs, JWT, base64) |
| Redaction pattern packs | redact/packs.go (vendor-specific patterns) |
| PII detection | redact/pii.go |
| Custom redaction rules | redact/custom.go |
| Agent launch detection | internal/ subpackages |
| Git operations | internal/ subdirectories |
| Integration tests | cli/integration_test/ (build tag integration) |
| Perf benchmarks | perf/ directory |
| Mise task definitions | mise.toml |
| Docs | docs/ (investigate command, security, privacy) |
| Linter config | .golangci.yaml (very strict: 40+ linters including perfsprint, nilnil, wrapcheck, gosec) |