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, 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, clean, copy-config)cmd/script/— Script management commandscmd/docs/— Documentation scaffolding commandscmd/task.go— Top-level task commands in the rootcmd/packagecmd/witr.go— Process diagnostics bridge
internal/— Business logic, separated by domain:config/— Configuration loading and managementgit/— Core Git operations (find repos, update, remote management, submodule, URL conversion, scanner)github/— GitHub API interactions (list org repos, parse org URLs)gitlab/— GitLab API interactions (batch-clone)script/— Script discovery (from config andscripts/dir) and executiontask/— Task init/dispatch/sync, issue CRUD, and implementation viakimiCLItemplates/— Embedded dotfiles (nvim, ghostty) formagic copy-configtui/— Shared terminal UI components (spinner, dialogs, selector)witr/— Why-Is-This-Running process diagnostics engine
docs/usage/— Usage documentation per command
spark
├── git [init|clone|update|submodule [add|init|status|ensure-ssh]|sync|gitcode|config|url|batch-clone|issues|update-org-status|push-all|scan]
├── task [list|init|dispatch|sync|create|delete|impl]
├── script [list|run]
├── magic [flush-dns|clean|copy-config|pip|go|node]
├── docs [init|site]
└── witr
- TUI mode:
taskand 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, scanner db), 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)
- The docs site (
docs/) is bilingual: Chinese is the default locale rendered at the site root; the English mirror lives under/en/. When adding or changing a doc, update bothdocs/zh/...anddocs/en/...and keep the per-localenavigation.jsonfiles (docs/zh/navigation.json,docs/en/navigation.json) in sync. Seedocmd.config.jsfor the i18n config.