Rig is a modern, extensible Go CLI tool designed to streamline developer workflows. It replaces complex bash scripts with a maintainable, feature-rich application that automates:
- Git Worktrees: Automatic isolated workspaces per ticket/branch.
- Tmux Sessions: Configurable multi-window terminal sessions.
- Documentation: Markdown note creation (Obsidian-style) with JIRA and Beads integration.
- History Tracking: Command history analysis and timeline export using SQLite.
- AI Integration: Support for various AI providers (Anthropic, Gemini, Groq, Ollama) for workflow assistance.
- Language: Go (1.25+)
- CLI Framework: Cobra
- Configuration: Viper
- Database: SQLite (modernc.org/sqlite)
- Integrations: Git, Tmux, JIRA, Beads, Obsidian, GitHub
- Error Handling: cockroachdb/errors
cmd/: CLI command implementations (e.g.,work.go,hack.go,session.go).pkg/: Core logic packages.pkg/git/: Git worktree and repository management.pkg/tmux/: Tmux session automation.pkg/jira/: JIRA integration (API & CLI).pkg/beads/: Beads issue tracker integration.pkg/history/: Command history tracking (zsh-histdb/atuin).pkg/config/: Configuration handling and security warnings.pkg/notes/: Markdown note templates and management.pkg/ai/: AI provider implementations.pkg/github/: GitHub API and CLI client.
main.go: Application entry point.project.yaml: Project metadata and governance.
go build -o rig./rig --helpThe project emphasizes comprehensive test coverage using table-driven tests and mocks.
go test ./... # Run all tests
go test -v ./... # Verbose output
golangci-lint run # Run lintersRig uses a TOML configuration file, typically located at ~/.config/rig/config.toml. It also supports repository-local overrides via .rig.toml.
- [notes]: Path to Obsidian/Markdown notes and templates.
- [git]: Base branch configuration.
- [jira]: JIRA credentials and mode (API vs ACLI).
- [beads]: Beads integration settings.
- [tmux]: Session window layouts and commands.
- [history]: Database path for command history.
- [ai]: AI provider and model settings.
- Style: Follow standard Go idioms.
- Naming:
- Fields/Files:
snake_case - Directories:
kebab-case - Enums:
SCREAMING_SNAKE
- Fields/Files:
- Testing:
- Mandatory for new features.
- Prefer table-driven tests.
- Use interfaces for mocking external dependencies (Git, JIRA, Tmux).
- Architecture: Keep CLI logic in
cmd/minimal; delegate business logic topkg/. - Linting: Strict mode using
golangci-lint.
rig work <ticket>: Start a complete workflow (Worktree + Tmux + Note).rig hack <name>: Start a lightweight non-ticket workflow.rig list: Show active worktrees and sessions.rig clean: Remove old worktrees and sessions.rig sync <ticket>: Update notes with latest JIRA/Beads info.rig timeline <ticket>: Export command history for a ticket.rig history query: Search through command history.
- Lazy Initialization: Use
sync.Onceand aninit(ctx)method for providers requiring SDK setup or context. This avoids passingcontext.Contextto constructors and defers initialization until first use. - Interface-Based Mocking: Test AI providers by injecting and mocking the underlying SDK model interfaces (e.g., Genkit's
ai.Model). This enables fast, deterministic testing of message mapping and token usage. - Translation Layer: Maintain internal
ai.Messageandai.Responseabstractions. Map these to SDK-specific types within the provider implementation to protect the codebase from underlying SDK breaking changes.
Providers are configured in ~/.config/rig/config.toml.
Uses the native Genkit for Go SDK.
[ai]
provider = "gemini"
gemini_model = "gemini-1.5-flash" # Optional
gemini_api_key = "your-api-key" # Or use GOOGLE_GENAI_API_KEY[ai]
provider = "anthropic"
api_key = "your-api-key" # Or use ANTHROPIC_API_KEY / GROQ_API_KEY- Isolated Secret Resolution: Use isolated resolution functions for each provider to prevent "cross-provider contamination" (e.g., using an Anthropic key for Gemini).
- Security Warning Accuracy: When implementing security warnings for config-stored secrets, ensure all valid environment variable sources (e.g.,
RIG_AI_*) are checked to avoid false positives.
- SDK-First: Prefer official Go SDKs (like Genkit for Google AI) over CLI wrappers for stability and robust streaming support.
- Safe Deprecation: Use non-blocking configuration warnings (via
CheckSecurityWarnings) instead of silent removal when deprecating keys to ensure a smooth user migration.
- Historical Accuracy: Never modify old release notes or historical documentation to reflect current state. Always treat past records as immutable snapshots.
- Consolidated AI Context: Keep AI provider configuration examples and architectural truths in
GEMINI.mdto provide a single source of truth for future agent sessions.