How axsmak/aim works
Purpose and Entry Point
AIM Loadout is a local-first, Git-backed Go CLI (aiman) that manages reusable AI-agent skills and MCP server definitions, then installs them into Claude Code, Cursor, and Codex CLI. Process startup is cmd/aim/main.go; command registration and shared CLI wiring are in internal/cli/root.go.
CLI Workflow Orchestration
The CLI separates offline local application from Git-backed distribution:
• apply reads the active inventory and updates AI-tool environments without Git mutation: internal/cli/apply.go.
• push validates inventory/loadouts, protects local secrets, commits, and pushes: internal/cli/push.go.
• sync fetches the configured repository, applies it, then updates local sync state: internal/cli/sync.go.
• Repository connection and selection are handled by internal/cli/init.go and internal/cli/switch.go.
Inventory Domain Model
Inventory is filesystem-based: Markdown skills, YAML MCP definitions, optional YAML loadouts, and repository metadata. Domain parsing and validation are split by type:
• Skills: internal/skill/skill.go, internal/skill/parse.go
• MCP definitions and environment requirements: internal/mcp/mcp.go, internal/mcp/validate.go
• Loadout parsing, resolution, and reference integrity: internal/loadout/parse.go, internal/loadout/resolve.go, internal/loadout/refcheck.go
Loadouts select an exact managed subset for reconciliation; normal apply/sync remain additive.
Adapter Boundary and Environment Reconciliation
internal/adapter/adapter.go defines the abstraction translating one inventory model into tool-specific filesystem/configuration surfaces. internal/adapter/registry.go discovers supported targets, while internal/adapter/scanner.go inspects installed state. Concrete adapters are internal/adapter/claude_code.go, internal/adapter/cursor.go, and internal/adapter/codex.go.
Adapters own external-format details: skill installation paths plus JSON/TOML MCP config changes. Core inventory logic should not depend on any individual AI tool format.
Apply, Add, and Import Operations
The application layer coordinates parsed inventory and adapters, including managed-item removals during loadout reconciliation:
• internal/adder/adder.go and internal/adder/skill.go install skills.
• internal/adder/mcp.go applies MCP definitions.
• internal/importer/skill.go and internal/importer/mcp.go ingest existing tool configuration into inventory-oriented forms.
This boundary preserves unmanaged environment content where adapters support it, while AIM controls inventory-known names.
Configuration, Secrets, and Git Transport
Repository-shared configuration is represented in internal/repoconfig/repoconfig.go; machine-local repository path, sync markers, and MCP environment values reside in internal/localconfig/localconfig.go. Global active-inventory selection is handled by internal/globalconfig/globalconfig.go.
Required MCP values are resolved locally through internal/mcp/envresolver.go; secrets stay in aim.local.yaml rather than the Git inventory. Git clone/fetch/status/commit/push behavior is isolated in internal/gitops/gitops.go, making Git the only inventory transport and external network dependency.
Runtime and Distribution
The runtime is a Go command-line binary with local filesystem and Git executable integration; it has no hosted service or web runtime. Release automation uses GoReleaser and GitHub Actions: .goreleaser.yaml, .github/workflows/release.yaml. Current packaging also includes Arch Linux metadata at packaging/arch/PKGBUILD.
Main entry points: apply.go Apply, push, sync · adder.go Apply operations · root.go Command wiring · .goreleaser.yaml Release automation
Components 18
CLI
- aiman binary
cmd/aim/main.go - Command wiring
internal/cli/root.go - Apply, push, sync · Apply is local; push and sync use Git.
internal/cli/apply.go - Repository selection
internal/cli/init.go
Inventory domain
- Filesystem inventory · Markdown skills, YAML MCP definitions, loadouts, and metadata.
- Skills parser
internal/skill/parse.go - MCP validation · Validates definitions and required environment values.
internal/mcp/validate.go - Loadout resolution · Resolves selected items and checks references.
internal/loadout/resolve.go
Reconciliation
- Apply operations · Installs known items and removes managed items outside a loadout.
internal/adder/adder.go - Adapter boundary · Converts inventory into target-specific files and configuration.
internal/adapter/adapter.go - Installed-state scanner
internal/adapter/scanner.go - Environment importer · Ingests existing skills and MCP configuration into inventory forms.
internal/importer/skill.go
State and transport
- Configuration layers · Shared repo config; local paths, sync markers, secrets, and active selection.
internal/repoconfig/repoconfig.go - MCP env resolver · Resolves required MCP values from local configuration.
internal/mcp/envresolver.go - Git transport · Clone, fetch, status, commit, and push are the only network dependency.
internal/gitops/gitops.go
AI tool targets
- Claude, Cursor, Codex · Skills plus JSON/TOML MCP configuration surfaces.
internal/adapter/claude_code.go
Distribution
- Release automation
.goreleaser.yaml - Arch package
packaging/arch/PKGBUILD
Connections 21
- aiman binary → Command wiring: starts
- Command wiring → Apply, push, sync: registers
- Command wiring → Repository selection: registers
- Repository selection → Configuration layers: stores selection
- Apply, push, sync → Filesystem inventory: reads and validates
- Filesystem inventory → Skills parser: skill files
- Filesystem inventory → MCP validation: MCP definitions
- Filesystem inventory → Loadout resolution: optional subset
- Apply, push, sync → Apply operations: apply or sync
- Loadout resolution → Apply operations: managed selection
- Apply operations → Adapter boundary: reconciles through
- Installed-state scanner → Apply operations: installed state
- Adapter boundary → Claude, Cursor, Codex: writes target formats
- Claude, Cursor, Codex → Environment importer: existing configuration
- Environment importer → Filesystem inventory: inventory-oriented forms
- MCP validation → MCP env resolver: required values
- MCP env resolver → Configuration layers: local secrets
- Apply, push, sync → Git transport: push and sync
- Git transport → Filesystem inventory: clone, fetch, commit
- Release automation → aiman binary: builds binary
- Release automation → Arch package: packages