This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
make build # Build for current OS + install to ~/.local/bin/spark
make build-linux # Cross-compile for Linux amd64
make build-darwin # Cross-compile for macOS amd64
make test # Run all unit tests (go test ./... -v)
make test-bdd # Run BDD-style tests with Ginkgo (internal/...)
make lint # Static analysis (go vet ./...)
make clean # Remove binary and build artifactsRun a single test:
go test ./internal/git/... -v -run TestFunctionNameSpark is a Go CLI tool (module spark, binary spark) for managing multiple Git repositories, AI agent configs, scripts, and task workflows. Built with Cobra (CLI), Viper (config), PTerm + Bubble Tea (TUI), tested with Ginkgo/Gomega (BDD).
main.go→ callscmd.Execute()cmd/— Cobra command definitions.root.goloads config from~/.spark.yamland auto-migrates from legacy~/.monolize.yaml. Subdirectories group commands:cmd/git/— Git repo management commandscmd/magic/— System utility commands (DNS flush, mirror switching)cmd/script/— Script management commandscmd/agent.go,cmd/agent_profile.go,cmd/task.go— Top-level commands in the rootcmd/package
internal/— Business logic, separated by domain:agent/— AI agent config management (Claude Code, Codex, Kimi, GLM) and profile templatesconfig/— Configuration loading and managementgit/— Core Git operations (find repos, update, remote management, URL conversion)github/— GitHub API interactions (list org repos, parse org URLs)mono/— Mono-repo creation and submodule managementscript/— Script discovery (from config andscripts/dir) and executiontask/— Task init/dispatch/sync, feature CRUD, and implementation viakimiCLItui/— Shared terminal UI components (spinner, dialogs, selector)
docs/usage/— Usage documentation per command
spark
├── git [update|mono|gitcode|config|url|batch-clone|update-org-status]
│ └── mono [add|sync]
├── agent [list|view|edit|reset] + agent profile [list|add|edit]
├── task [list|init|dispatch|sync|create|delete|impl]
├── script [list|run]
└── magic [flush-dns|pip|go|node] # Mirror source switching + DNS
- TUI mode:
task,agent, and other commands accept--tuiflag for interactive mode with Bubble Tea selectors and PTerm spinners. CLI mode is the default. - Config binding: Flags are bound to Viper via
viper.BindPFlag()ininit()functions. Config keys use snake_case in YAML but camelCase in struct tags. - Script sources: Scripts can come from
~/.spark.yaml(spark.scriptsor top-levelscripts) or from ascripts/directory. Config scripts take precedence.
User config at ~/.spark.yaml. Key sections: repo-path (list of directories to scan), git (default username/email), task_dir, github_owner, work_dir, spark.scripts.
- Follow standard Go conventions; no comments unless explicitly requested
- New features require BDD-style tests using Ginkgo/Gomega
- Test files use
_test.gosuffix, live alongside source ininternal/ - Test suite files (
*_suite_test.go) register the Ginkgo test runner for each package - Keep
Makefileas the single source of truth for build/test commands - New commands should have usage docs in
docs/usage/ - The UI language is primarily Chinese (documentation, user-facing messages)