AGENTS.md · diff
git:20260708.5f08192 to git:20260710.ba92170
38 added, 119 removed. Audit A to A.
# Agent Instructions
## What This Is
- Monorepo for **my-ai-tools** — configuration management for 14+ AI coding assistants (Claude Code, OpenCode, Amp, CCS, Gemini CLI, Antigravity CLI, Pi, Codex CLI, Kilo CLI, Kimi Code, CommandCode, Cursor, Factory Droid, Cline, Grok CLI). Exports configs to `~/.claude/`, `~/.config/opencode/`, `~/.pi/`, etc.
+ Monorepo for **my-ai-tools** — source-of-truth configs for 14+ AI coding assistants (Claude Code, OpenCode, Amp, Codex, Gemini, Antigravity, Cursor, Cline, Grok, etc.). It exports configs to `~/.claude/`, `~/.config/opencode/`, `~/.pi/`, etc. and imports them back via `generate.sh`. Per-tool configs live in `configs/<tool>/`.
## Essential Commands
- Use microsandbox when testing or working with shell scripts.
-
```bash
- # Validate shell scripts (CI and local)
- bash -n cli.sh generate.sh
-
- # Preview changes, then apply
- ./cli.sh --dry-run # Preview install
- ./cli.sh # Install to home
-
- # Export local configs back to repo
- ./generate.sh --dry-run # Preview export
- ./generate.sh # Export
-
- # Code quality
- biome check . # Check formatting
- biome check --write . # Format in-place
- bats tests/ # Run functional tests
- bats tests/cli.bats # Run a single test file
+ bash -n cli.sh generate.sh # Syntax-validate shell scripts (CI runs this)
+ ./cli.sh --dry-run # Preview install plan (run this FIRST)
+ ./cli.sh # Install configs into $HOME
+ ./generate.sh --dry-run # Preview export
+ ./generate.sh # Export local configs from $HOME back to repo
+ biome check . # Format check (tabs, 120 width, double quotes)
+ biome check --write . # Format in place
+ bats tests/ # Run all functional tests locally
+ bats tests/cli.bats # Run a single test file
```
## Workflow
```bash
./cli.sh --dry-run → git diff → ./cli.sh → git diff → commit
```
Never run `./cli.sh` without `--dry-run` first. Config validation runs automatically and warns on failures.
- ## Shell Script Conventions
-
- These are enforced across `cli.sh`, `generate.sh`, and `lib/`:
-
- - **Re-exec guard**: Every entry-point script must `source lib/require_bash.sh` before `lib/common.sh`. This is non-negotiable — `lib/common.sh` uses bash-only syntax that crashes under `sh`/`dash`.
- - **Error handling**: `set -e` goes _after_ the re-exec guard.
- - **Dry-run**: Use `execute()` or `execute_quoted()` wrapper for any side-effecting command. Never run destructive commands directly.
- - **Paths**: Use `$HOME`, relative paths. **No absolute paths** in configs or scripts.
- - **Quoting**: Always quote variables: `"$variable"`.
- - **Locals**: Use `local` for function-scoped variables.
- - **Colors/logging**: Use `log_info`, `log_success`, `log_warning`, `log_error` from `lib/common.sh`.
-
- ## Testing
+ ## Testing — read this carefully
- - `bash -n cli.sh generate.sh` — syntax validation (CI runs this)
- - `bats tests/` — functional tests (requires `bats-core`: `brew install bats-core`)
- - `biome check .` — TS/JS/JSON formatting (tabs, 120 line width, double quotes)
- - `pre-commit run --all-files` — trailing whitespace, YAML check, oxfmt
+ - CI only runs a **subset**: `bats tests/pr_*.bats tests/generate.bats tests/sh_reexec.bats`. Running `bats tests/` locally runs many more files (skill/tool-specific tests) that CI does NOT execute — don't assume CI covers them.
+ - `bats` is required (`brew install bats-core`). On the cloud VM it is preinstalled — run `bats tests/` directly.
+ - `bash -n cli.sh generate.sh` is the cheapest check and is what CI gates on first.
+ - `biome check .` and `configs/claude/hooks` typecheck report pre-existing formatting/`tsconfig` deviations (tsconfig omits node/dom libs). These are repo-state issues, not environment failures.
+ - `pre-commit run --all-files` runs: trailing-whitespace, end-of-file-fixer, check-yaml, check-added-large-files, oxfmt.
- ### Running bats tests in microsandbox
+ ### macOS host: run bats via microsandbox
- Use microsandbox to avoid macOS `getcwd` / directory-access issues that can break `bats` on the host:
+ macOS `getcwd`/directory issues can break `bats` on the host. Use a read-only sandbox:
```bash
- # Run all tests
msb run -m 512M -v "$(pwd):/project:ro" ubuntu -- \
bash -c 'apt-get update -qq && apt-get install -y -qq bats && cd /project && bats tests/'
-
- # Run a single test file
- msb run -m 512M -v "$(pwd):/project:ro" ubuntu -- \
- bash -c 'apt-get update -qq && apt-get install -y -qq bats && cd /project && bats tests/pr_codiff.bats'
-
- # Run syntax validation only (no bats install needed)
- msb run -m 256M -v "$(pwd):/project:ro" ubuntu -- \
- bash -c 'cd /project && bash -n cli.sh generate.sh lib/install.sh'
```
- The `:ro` mount flag keeps the project read-only inside the sandbox, preventing accidental writes.
- The sandbox is ephemeral (no `--name` flag) — it's destroyed automatically after the command exits.
-
- ## Prerequisites
-
- - Bash 3.0+ (scripts use process substitution, arrays, `${var//pat/repl}`)
- - Git
- - Bun (preferred) or Node.js
- - `jq` for JSON parsing
-
- ## Directory Structure
+ ## Shell Script Conventions (enforced in cli.sh, generate.sh, lib/)
- ```text
- cli.sh, generate.sh # Entry points
- lib/common.sh # Shared utilities (execute(), logging, validation)
- lib/require_bash.sh # Re-exec guard for sh/dash
- lib/install.sh # Installation helpers
- configs/<tool>/ # Source configs per tool
- claude/, opencode/, amp/, codex/, gemini/, etc.
- configs/mcp-registry.json # Central MCP server registry
- configs/best-practices.md # Exported to ~/.ai-tools/
- configs/git-guidelines.md # Git safety rules
- skills/ # Local marketplace plugins
- wiki/ # LLM Wiki — persistent, compounding knowledge base
- tests/ # BATS functional tests
- ```
+ - **Re-exec guard**: every entry point sources `lib/require_bash.sh` _before_ `lib/common.sh`. `common.sh` uses bash-only syntax (`<()`, arrays, `${var//pat/repl}`) that crashes under `sh`/`dash`.
+ - `set -e` goes _after_ the re-exec guard.
+ - **Dry-run**: wrap every side-effecting command in `execute()` / `execute_quoted()` (defined in `lib/common.sh`). Never run destructive commands directly.
+ - Paths: use `$HOME` / relative. **No absolute paths** in configs or scripts.
+ - Quote all variables, use `local`, and use `log_info`/`log_success`/`log_warning`/`log_error` for output.
## Key Gotchas
- - `cli.sh` auto-detects installed tools and skips missing ones. It won't install configs for tools you don't have.
- - `generate.sh` exports _from_ your home directory _to_ the repo. Only copies configs for tools it finds installed.
- - MCP server installation uses a central registry (`configs/mcp-registry.json`). Legacy fallback exists but prefer registry.
- - Config files are validated with `jq` before install. Failures warn but don't block (unless you say no to the prompt).
- - `safe_copy_dir()` excludes `node_modules`, `cache`, `*.sqlite`, and other runtime dirs automatically.
- - Backup location: `$HOME/ai-tools-backup-{timestamp}`. Auto-cleanup keeps last 5.
+ - `cli.sh` auto-detects installed tools and skips missing ones — it won't install configs for tools you don't have.
+ - `generate.sh` exports _from_ `$HOME` _to_ the repo; it only copies tools it finds installed.
+ - MCP servers come from the central registry `configs/mcp-registry.json`. Prefer it over the legacy fallback.
+ - Configs are validated with `jq` before install; failures warn but don't block (unless you decline the prompt).
+ - `safe_copy_dir()` (lib/common.sh) auto-excludes `node_modules`, `cache`, `*.sqlite`, etc.
+ - Backups go to `$HOME/ai-tools-backup-{timestamp}`; last 5 are kept.
- Gemini CLI is deprecated for Google One/unpaid tiers (June 18, 2026 cutoff). Migrate to Antigravity CLI.
- ## Working with Advanced Models
-
- See `configs/fable-guide.md` for comprehensive guidance on:
- - **Capability Overhang**: Understanding what's newly possible
- - **Finding Unknowns**: Discovery techniques before implementation
- - **Context over Constraints**: Positive guidance patterns
- - **Being Unreasonable**: Challenging false tradeoffs
-
- Key skills for discovery-first development:
- - `skills/blindspot-pass/` - Find unknown unknowns before starting
- - `skills/context-discovery/` - Proactively gather context using MCP tools
- - `skills/git-context/` - Search git history for patterns and decisions
- - `skills/doc-search/` - Find ADRs, wiki entries, and project documentation
- - `skills/capability-experiments/` - HTML reports, embedded UIs, proactive research
- - `skills/spec-interview/` - Clarify requirements through targeted questions
- - `skills/implementation-logger/` - Track decisions and deviations
- - `skills/quiz-me/` - Verify understanding after implementation
-
- ## Learning Recording
-
- After fixing a bug (confirmed by human), introducing a new tech choice, or encountering something important, ask the user:
-
- > "Would you like me to record this as a learning?"
-
- If yes, decide which lane (see `~/.ai-tools/MEMORY.md`):
- - **qmd** (durable) — project-specific gotchas, architecture decisions, conventions
- - **agentmemory** (session) — transient context only the current session needs
-
- Read `@~/.ai-tools/agent-memory.md` and `@~/.ai-tools/MEMORY.md` for the full decision rule.
-
## Git Safety
- - Prefer `git add <specific-files>` over `git add -A`
- - Never force push, rewrite history, or run destructive resets without explicit approval
- - See `configs/git-guidelines.md` for full rules
+ - Prefer `git add <specific-files>` over `git add -A`.
+ - Never force-push, rewrite history, or run destructive resets without explicit approval. See `configs/git-guidelines.md`.
## Cursor Cloud specific instructions
- This is a Bash CLI tool, not a long-running server — there is nothing to keep running. You verify it by invoking commands and checking exit codes / file output. The Linux VM already has `bash`, `git`, `jq`, `node`, `bun`, and `bats` provisioned (bun is on PATH via `~/.bashrc`; the update script refreshes `configs/claude/hooks` deps).
+ This is a Bash CLI tool, not a server — verify by invoking commands and checking exit codes / output. The VM has `bash`, `git`, `jq`, `node`, `bun`, `bats` preinstalled.
- - **Ignore the microsandbox (`msb`) guidance above** on the cloud VM — it only exists to dodge macOS `getcwd`/directory issues. Run `bats tests/` directly.
- - **Tests / lint / typecheck** — see the `## Testing` section above for the canonical commands (`bash -n cli.sh generate.sh`, `bats tests/`, `biome check .` via `npx @biomejs/biome`, and `bun run typecheck` in `configs/claude/hooks`).
- - `biome check .` and the hooks `typecheck` report pre-existing formatting/`tsconfig` deviations (the tsconfig omits node/dom lib types); these are repo-state issues, not environment failures. The toolchains themselves run fine.
- - **Running the app safely** — `./cli.sh` / `./generate.sh` mutate `$HOME`. In a non-TTY/CI shell `cli.sh` auto-enables `--yes`, which tries to network-install ~20 external CLIs (many will fail/hang without network) *before* the core config copy at the very end. To exercise the core config-sync deterministically without that noise, source the script and call its copy functions against a throwaway `HOME`, exactly like the bats tests do:
+ - **Ignore the microsandbox guidance above** on the cloud VM — run `bats tests/` directly.
+ - `./cli.sh` / `./generate.sh` mutate `$HOME`. In a non-TTY/CI shell, `cli.sh` auto-enables `--yes`, which tries to network-install ~20 external CLIs (many fail/hang without network) _before_ the core config copy at the end. To exercise the core sync deterministically, source the script and call its copy functions against a throwaway `HOME`, like the bats tests do:
```bash
H=$(mktemp -d); mkdir -p "$H/.cursor" "$H/.config/opencode" "$H/.codex"
( export HOME="$H" DRY_RUN=false YES_TO_ALL=false; source ./cli.sh; copy_configurations )
- find "$H" -type f # verify configs landed in the sandbox home
+ find "$H" -type f # verify configs landed
```
- `copy_claude_configs` always runs; other tools only copy when detected (their CLI is on PATH or their config dir exists — hence pre-creating dirs above). Do NOT run the copy functions with `set -u`; `lib/common.sh` references optional vars like `MSYSTEM`.
- - Use `./cli.sh --dry-run` for a full, side-effect-free preview of the install plan.
+ `copy_claude_configs` always runs; other tools only copy when detected. Do NOT run copy functions with `set -u` — `lib/common.sh` references optional vars like `MSYSTEM`.
+ - Use `./cli.sh --dry-run` for a full, side-effect-free preview.