fr8 Development Guide
You are working on fr8, a Go CLI for managing git worktrees as isolated dev workspaces. Use this context to make informed decisions about code changes.
Core Model
Workspace = git worktree + allocated port block + state entry + optional tmux session
Creation flow (createWorkspace() in cmd/new.go):
- •Generate or validate workspace name
- •Create git worktree (branch from HEAD, track remote, or resolve PR)
- •Allocate next available port block (base + N*range)
- •Record in state file (
.git/fr8.json) - •Register repo in global registry (
~/.config/fr8/repos.json) - •Sync
.worktreeincludefiles - •Run setup script if configured
Resolution: Workspace lookup follows CWD → global registry → explicit path. MCP tools skip CWD detection.
Development Workflow
Before any change
bash
go build ./... # Catch compile errors go vet ./... # Static analysis go test -race ./... # Tests with race detector
Adding a CLI command
- •Create
cmd/<name>.gowith command struct andrunXxxfunction - •Register via
init()withparentCmd.AddCommand() - •Use
RunE(neverRun), return errors (neveros.Exit()) - •Add tests
- •See
.claude/rules/cobra-commands.mdfor full pattern
Adding an MCP tool
- •Define tool in
registerMCPTools()incmd/mcp_tools.go - •Write handler function
- •Update
TestRegisterMCPToolsexpected tools list - •See
.claude/rules/mcp-server.mdfor full pattern
Adding a TUI view
- •Add
viewXxxto enum inmessages.go - •Create
xxx.gowithrenderXxx(m model) - •Add
handleXxxKeymethod - •Wire into
View()andhandleKey()switches - •See
.claude/rules/tui-components.mdfor full pattern
Modifying internal packages
- •Git ops →
internal/git/ - •State CRUD →
internal/state/ - •Registry CRUD →
internal/registry/ - •Never shell out to git from
cmd/directly - •See
.claude/rules/package-organization.md
Key Files
| What | Where |
|---|---|
| Workspace creation | cmd/new.go → createWorkspace() |
| Workspace resolution | internal/workspace/resolve.go |
| State persistence | internal/state/state.go |
| Git wrapper | internal/git/git.go |
| MCP tools | cmd/mcp_tools.go |
| TUI entry | internal/tui/model.go |
| Exit codes | internal/exitcode/exitcode.go |
| JSON output | internal/jsonout/jsonout.go |
| Error handling | cmd/root.go → Execute() |
Rules Reference
All project conventions are in .claude/rules/:
- •
go-style.md,cobra-commands.md,testing.md - •
error-handling.md,package-organization.md,ci.md - •
mcp-server.md,tui-components.md,pull-requests.md