A modern, extensible Go CLI tool for Site Reliability Engineering workflow automation. This tool replaces a complex bash script with a maintainable, feature-rich application that integrates with Git worktrees, Tmux sessions, Markdown documentation, and command history tracking.
- Ticket-based workflows: Initialize complete work environments with a single command
- Git worktree integration: Automatic isolated workspaces per ticket
- Tmux session management: Configurable multi-window terminal sessions
- Markdown note creation: Template-based documentation with JIRA integration
- Command history tracking: SQLite-based timeline export and analysis
sre init <ticket> # Initialize complete workflow
sre hack <name> # Lightweight workflow for non-ticket work
sre list # Show all worktrees and tmux sessions
sre clean # Remove old worktrees and sessions
sre session list/attach/kill # Manage tmux sessions
sre timeline <ticket> # Export command history timeline
sre history query [pattern] # Query command database
sre sync <ticket> # Update notes and JIRA info
sre config --show/--init # Manage configuration- Git: Automatic worktree and branch creation with base branch detection
- JIRA: Ticket metadata fetching via configurable CLI tools (
acli) - Markdown: Rich note templates, daily note updates, timeline export
- Tmux: Session automation with environment variables and window layouts
- History Databases: Support for both zsh-histdb and atuin SQLite schemas
-
Clone the repository:
git clone <repository-url> cd sre
-
Build the CLI:
cd main/ go build -o sre -
Initialize configuration:
./sre config --init
-
Edit configuration at
~/.config/sre/config.yaml:vault: path: "~/Documents/Second Brain" repository: owner: "your-org" name: "your-repo" base_path: "~/src"
-
Start working on a ticket:
./sre init proj-123
This creates:
- Git worktree at
~/src/your-org/your-repo/proj/proj-123 - Markdown note with JIRA details
- Tmux session with note/code/terminal windows
- Daily note entry with timestamp
- Git worktree at
-
Export your work timeline:
./sre timeline proj-123
-
Sync latest information:
./sre sync proj-123
The CLI uses TOML configuration at ~/.config/sre/config.toml:
[vault]
path = "~/Documents/Second Brain"
templates_dir = "templates"
areas_dir = "Areas/Work"
daily_dir = "Daily"
default_subdir = "Tickets" # Default subdir for ticket notes
incident_subdir = "Incidents" # Subdir for incident tickets
hack_subdir = "Hacks" # Subdir for hack sessions
[repository]
owner = "myorg"
name = "myrepo"
base_path = "~/src"
base_branch = "main"
[history]
database_path = "~/.histdb/zsh-history.db"
ignore_patterns = ["ls", "cd", "pwd", "clear"]
[jira]
enabled = true
cli_command = "acli"
[tmux]
session_prefix = ""
[[tmux.windows]]
name = "note"
command = "nvim {note_path}"
[[tmux.windows]]
name = "code"
command = "nvim"
working_dir = "{worktree_path}"
[[tmux.windows]]
name = "term"
working_dir = "{worktree_path}"For working with multiple repositories, use the repositories table with ticket_types to route tickets:
[vault]
path = "~/Documents/Second Brain"
templates_dir = "templates"
areas_dir = "Areas/Work"
daily_dir = "Daily"
default_subdir = "Tickets"
incident_subdir = "Incidents"
hack_subdir = "Hacks"
# Define multiple repositories
[repositories.main-repo]
owner = "myorg"
name = "main-service"
base_path = "~/src/myorg"
base_branch = "main"
[repositories.infra-repo]
owner = "myorg"
name = "infrastructure"
base_path = "~/src/myorg"
base_branch = "main"
# Map ticket prefixes to repositories
[ticket_types]
proj = "main-repo"
feat = "main-repo"
ops = "infra-repo"
infra = "infra-repo"
[history]
database_path = "~/.histdb/zsh-history.db"
ignore_patterns = ["ls", "cd", "pwd", "clear"]
[jira]
enabled = true
cli_command = "acli"
[tmux]
session_prefix = ""
[[tmux.windows]]
name = "note"
command = "nvim {note_path}"
[[tmux.windows]]
name = "code"
command = "nvim"
working_dir = "{worktree_path}"
[[tmux.windows]]
name = "term"
working_dir = "{worktree_path}"With multi-repo config, sre init proj-123 routes to main-repo while sre init ops-456 routes to infra-repo.
Initialize complete workflow for a ticket.
Example:
sre init proj-123What it does:
- Creates git worktree and branch
- Fetches JIRA ticket details (if configured)
- Creates Markdown note from template
- Updates daily note with timestamp
- Launches tmux session with configured windows
Lightweight workflow for non-ticket work (experiments, spikes, etc.).
Example:
sre hack winter-cleanup
sre hack --notes experiment-authOptions:
--notes- Also create an Markdown note for the hack session
What it does:
- Creates git worktree at
hack/<name>with branchhack/<name> - Creates tmux session
- Skips JIRA integration (no ticket needed)
- Optionally creates Markdown note with
--notesflag
Show all worktrees and tmux sessions across configured repositories.
Options:
--worktrees- Show only worktrees--sessions- Show only tmux sessions
Remove old worktrees and associated tmux sessions.
Options:
--dry-run- Show what would be removed without removing--force- Skip confirmation prompts
Generate and export command timeline to Markdown.
Options:
--since "2025-08-10 09:00"- Start time filter--until "2025-08-10 18:00"- End time filter--failed-only- Show only failed commands--directory /path- Filter by directory--limit 1000- Max commands to retrieve--output file.md- Write to file instead of note--no-update- Only output to console
Examples:
sre timeline proj-123
sre timeline proj-123 --since "2025-08-10" --failed-only
sre timeline proj-123 --output /tmp/timeline.mdList all active tmux sessions.
Attach to existing tmux session for a ticket.
Kill tmux session for a ticket.
Query command history database.
Options:
--since "2025-08-10"- Start time filter--until "2025-08-10"- End time filter--directory /path- Filter by directory--session name- Filter by session name--failed-only- Show only failed commands--limit 50- Max results to show
Examples:
sre history query "git"
sre history query --since "2025-08-10" --failed-only
sre history query --directory "/Users/me/src/myproject"Show information about the history database.
Update ticket note with fresh JIRA information and daily notes.
Options:
--jira- Force refresh of JIRA information--daily- Update today's daily note only--force- Force update even if recently modified
Update today's daily note.
Display current configuration.
Create default configuration file.
- Git: For repository and worktree management
- Tmux: For session management
- Neovim: For editing (configurable)
- JIRA CLI:
aclior similar for ticket metadata - History Database: zsh-histdb or atuin for command tracking
- Obsidian: For note management and templates
Your Markdown vault should have this structure (subdirs are configurable):
Second Brain/
├── templates/
│ └── Jira.md # Template for tickets
├── Areas/Work/ # Configurable via areas_dir
│ ├── Tickets/ # Configurable via default_subdir
│ ├── Incidents/ # Configurable via incident_subdir
│ └── Hacks/ # Configurable via hack_subdir
└── Daily/ # Daily notes (YYYY-MM-DD.md)
main/
├── cmd/ # CLI commands (with comprehensive test coverage)
│ ├── clean.go # Worktree and session cleanup
│ ├── config.go # Configuration management
│ ├── hack.go # Lightweight non-ticket workflow
│ ├── history.go # History database queries
│ ├── init.go # Ticket workflow initialization
│ ├── list.go # List worktrees and sessions
│ ├── root.go # Root command setup
│ ├── session.go # Tmux session management
│ ├── sync.go # Markdown note synchronization
│ ├── timeline.go # Command history export
│ └── *_test.go # Unit tests for each command
├── pkg/ # Core packages (with unit tests)
│ ├── config/ # Configuration handling with Viper
│ ├── git/ # Git worktree operations (mock-based testing)
│ ├── history/ # SQLite history queries (zsh-histdb + atuin)
│ ├── jira/ # JIRA integration via CLI (acli)
│ ├── obsidian/ # Markdown note/template management
│ └── tmux/ # Tmux session automation
├── go.mod # Dependencies
└── main.go # Entry point
github.com/spf13/cobra- CLI frameworkgithub.com/spf13/viper- Configuration managementgithub.com/mattn/go-sqlite3- SQLite database accessgopkg.in/yaml.v3- YAML parsing
cd main/
go build -o sreThe project has comprehensive test coverage across all packages.
cd main/
# Run all tests
go test ./...
# Run tests with verbose output
go test -v ./...
# Run a specific test
go test -run TestParseTicket ./cmd/...
# Run tests for a specific package
go test ./pkg/git/...- Table-driven tests: Most tests use Go's table-driven pattern for comprehensive coverage
- Mock-based unit tests:
pkg/gitusesCommandRunnerinterface for mocking git commands - Integration tests: Some tests create real git repos in temp directories (skipped if git unavailable)
cmd/- 9 test files covering all commands except root.gopkg/config/- Configuration loading and validationpkg/git/- Mock-based worktree operations testingpkg/history/- Database schema detection and query buildingpkg/jira/- JIRA CLI output parsingpkg/obsidian/- Note and template managementpkg/tmux/- Session parsing and management
- Create new command file in
cmd/ - Add command to root command in
init() - Implement business logic in appropriate
pkg/package - Add corresponding
_test.gofile with table-driven tests
This CLI tool replaces the original sre.sh bash script with the following improvements:
- Better error handling: Graceful degradation and detailed error messages
- Rich configuration: YAML-based with validation and path expansion
- Advanced querying: SQLite database integration with filtering
- Timeline export: Formatted command history with metadata
- Extensible architecture: Easy to add new commands and integrations
- Install and configure the Go CLI
- Test with existing tickets to ensure compatibility
- Gradually replace bash script usage
- Remove bash script once comfortable with CLI
- Command history analysis and export
- Advanced tmux session management
- Configurable window layouts
- Multiple history database support
- Rich timeline formatting
- Fork the repository
- Create a feature branch
- Make changes with tests
- Submit a pull request
- Follow Go best practices
- Use the existing package structure
- Add comprehensive error handling
- Include appropriate logging
[Add your license here]
For issues and questions:
- Check existing issues in GitHub
- Create new issue with detailed description
- Include configuration and error logs
Note: This tool is designed for SRE workflow automation and integrates with multiple external tools. Ensure all prerequisites are installed and configured for full functionality.