Skip to content

Latest commit

Β 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌐 English | ν•œκ΅­μ–΄ | ζ—₯本θͺž | δΈ­ζ–‡ | EspaΓ±ol

ai-agency

Stop re-explaining your project to AI.

A vendor-neutral CLI that builds a persistent context layer for your project β€” so every AI session (Claude Code, Codex, Cursor, Gemini, Copilot, Windsurf, Aider) starts already knowing your codebase, conventions, and business rules.

License: MIT Platform Made with Bash PRs Welcome Sponsor

ai-agency init β€” scan, classify, scaffold, validate



Pick the PM, pick sub-agents β€” panes spawn and coordinate via task-board.md
Pick PM from the menu, pick which specialists to bring β€” panes spawn and coordinate through a shared task-board.md.

Try it in 60 seconds

brew install itdar/tap/ai-agency

cd ~/your-project
ai-agency init      # scans, generates AGENTS.md + .ai-agents/ context
ai-agency           # pick an agent β€” it's already briefed

No Homebrew? curl -fsSL https://raw.githubusercontent.com/itdar/ai-agency/main/src/install.sh | bash -s -- --global

Works on macOS and Linux. Don't like it? ai-agency uninstall removes the tool, and ai-agency clear removes everything it generated β€” no residue.


Why

Every new AI session starts from zero. The model burns tokens figuring out:

  • "What framework is this?" β€” reads 20 files
  • "What are the team conventions?" β€” guesses wrong
  • "Who approves deploys?" β€” skips the step

Research (ETH Zurich, reviewed 2026-03): agents re-analyzing a known project waste ~20% more tokens and produce worse results than agents primed with a curated context file. Review article β†—

ai-agency writes that context file once β€” vendor-neutral, under 300 tokens per agent β€” and your AI tool of choice loads it on every session.


What actually gets built

When you run ai-agency init, the tool classifies each directory, then generates a layered context:

your-project/
β”œβ”€β”€ AGENTS.md                     # Who am I? β€” role, rules, permissions (≀300 tokens)
β”œβ”€β”€ .ai-agents/
β”‚   β”œβ”€β”€ context/                  # What do I know? β€” only non-inferable facts
β”‚   β”‚   β”œβ”€β”€ domain-overview.md    #   business purpose, policies, constraints
β”‚   β”‚   β”œβ”€β”€ api-spec.json         #   endpoints map (JSON DSL β€” ~3Γ— cheaper than prose)
β”‚   β”‚   β”œβ”€β”€ data-model.md         #   entities + relationships
β”‚   β”‚   β”œβ”€β”€ business-metrics.md   #   KPIs, OKRs
β”‚   β”‚   β”œβ”€β”€ stakeholder-map.md    #   RACI, approval flows
β”‚   β”‚   └── planning-roadmap.md   #   milestones, decisions log
β”‚   β”œβ”€β”€ skills/                   # How do I work? β€” loaded on demand
β”‚   β”‚   └── develop/SKILL.md
β”‚   β”œβ”€β”€ roles/                    # Role-specific loading strategies
β”‚   β”‚   β”œβ”€β”€ pm.md
β”‚   β”‚   └── backend.md
β”‚   └── coordination/             # Cross-vendor task board (multi-agent mode)
β”‚       β”œβ”€β”€ task-board.md
β”‚       β”œβ”€β”€ messages.md
β”‚       └── agent-status.json
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ api/AGENTS.md             # per-service agent
β”‚   └── web/AGENTS.md
└── infra/AGENTS.md

Only what the AI can't derive from code gets stored. "This is a React app" is obvious from package.json. "We squash-merge and require QA approval before deploy" is not β€” that goes in.


It's not just code

Most AI tooling stops at the repo boundary. ai-agency treats your whole organization as the project:

my-product/              ← PM agent (coordinator)
β”œβ”€β”€ api/                 ← Backend agent
β”œβ”€β”€ web/                 ← Frontend agent
β”œβ”€β”€ planning/            ← Technical Writer (specs, ADRs, roadmap)
β”œβ”€β”€ business/            ← Business Analyst (GTM, KPIs, stakeholders)
└── infra/               ← Infra agent

The PM agent delegates to whichever specialist fits the task β€” code changes to backend, pricing questions to business, spec drafts to planning. Each specialist loads only its own context, so token usage stays predictable.

For multi-domain platforms, domains are auto-detected when a directory has 2+ sub-projects with their own build files:

platform/
β”œβ”€β”€ commerce/           ← Domain Coordinator (auto-detected)
β”‚   β”œβ”€β”€ order-api/
β”‚   └── storefront/
β”œβ”€β”€ social/             ← Domain Coordinator (auto-detected)
β”‚   β”œβ”€β”€ feed-api/
β”‚   └── chat-api/
└── infra/

Running agents

ai-agency                       # interactive menu
ai-agency --agent api           # jump straight to one agent
ai-agency --multi               # several agents in parallel tmux panes
ai-agency --detach              # background tmux session β€” survives SSH disconnects

Three session modes:

  • Single β€” pick any agent (e.g. backend, frontend) and it runs in your current terminal. No tmux needed.
  • Team β€” pick a coordinator (root PM or a domain coordinator), choose which specialists to bring along, and the PM spawns one tmux pane per teammate and delegates work. Uses Claude Code's native agent teams (Claude Code only for now).
  • Multi β€” pick any set of agents; each gets its own tmux pane, coordinating through .ai-agents/coordination/ β€” a plain-text task board, message log, and status JSON. Because everything is Markdown + JSON, a Claude Code agent in one pane can hand work off to a Codex agent in another. No proprietary protocol; just files.

Add --detach to any tmux mode and the session keeps running after you close the terminal β€” reattach with tmux attach -t <name>.


Supported AI tools

ai-agency writes AGENTS.md (the open standard) plus per-vendor bootstrap files:

Tool Reads context via Bootstrap file
OpenAI Codex AGENTS.md natively β€”
Gemini CLI AGENTS.md natively β€”
Claude Code bootstrap β†’ AGENTS.md CLAUDE.md (always generated)
Cursor bootstrap β†’ AGENTS.md .cursor/rules/agents.mdc (always generated)
GitHub Copilot bootstrap β†’ AGENTS.md .github/copilot-instructions.md (if .github/ exists)
Windsurf bootstrap β†’ AGENTS.md .windsurfrules (if already present)
Aider bootstrap β†’ AGENTS.md .aider.conf.yml (read directive appended)

If a bootstrap target already exists with your own content, it's backed up to <file>.pre-agents.bak first (and *.pre-agents.bak is added to .gitignore).

Switch tools anytime β€” the context layer doesn't change.


Keeping context fresh

Each AGENTS.md embeds maintenance triggers ("if the API contract changes, update api-spec.json"). The AI updates context in-session.

After each session, ai-agency compares a checksum of your code against the context files and warns if they drifted:

[ai-agency] Code changes detected but no context files updated.
  Run: ai-agency verify --staleness

Manual checks:

ai-agency verify                # structure + completeness
ai-agency verify --staleness    # drift between code and context

For major refactors, re-run ai-agency init β€” it offers an incremental mode that only regenerates context for new/changed directories.


CLI reference

# Setup
ai-agency init [path]            # scan β†’ classify β†’ generate β†’ validate
ai-agency classify [path]        # preview classification without generating

# Daily use
ai-agency                        # interactive launcher (single / team / multi)
ai-agency --agent <keyword>      # launch a specific agent without the menu
ai-agency --multi                # multi-agent tmux session (pick agents, one pane each)
ai-agency --detach               # detached tmux session; reattach with tmux attach
ai-agency --tool <claude|codex|gemini>
ai-agency --lang [code]          # UI language: en ko ja zh es fr de ru hi ar
ai-agency --list                 # print detected agents and exit

# Project registry (launch from anywhere)
ai-agency register [path]
ai-agency scan [dir]
ai-agency list
ai-agency unregister [path]

# Maintenance
ai-agency verify [path]          # validate structure + token budgets
ai-agency verify --staleness     # detect drift between code and context
ai-agency clear [path]           # remove generated files (interactive, per-directory)
ai-agency update                 # update ai-agency itself (brew / global / local)
ai-agency uninstall              # remove ai-agency from your system
ai-agency --version              # print installed version

Requirements

  • macOS or Linux β€” Bash 3.2+ (the stock macOS Bash works)
  • curl β€” for install and self-update
  • tmux β€” optional; only needed for --multi, team mode, and --detach
  • At least one AI CLI β€” Claude Code, Codex CLI, or Gemini CLI

No runtime dependencies beyond that β€” it's plain Bash. Nothing to compile, no Node/Python required.


Updating & uninstalling

ai-agency update                 # updates whichever install you have (brew / global / local)
ai-agency uninstall              # removes the tool + project registry (asks first)
ai-agency uninstall --keep-config  # keep the project registry
ai-agency clear                  # remove generated AGENTS.md / .ai-agents/ from a project

uninstall never touches your projects β€” generated AGENTS.md and .ai-agents/ files stay until you remove them with ai-agency clear (or keep them; they're plain Markdown and useful on their own).


FAQ

Does my code get sent anywhere? ai-agency itself makes no network calls except downloading its own files on install/update β€” no telemetry, no analytics. Context generation runs through whichever AI CLI you choose, under that tool's account and policies.

How much does init cost? The initial generation scans the whole project and can run into tens of thousands of tokens. That cost is paid once; every subsequent session loads the prebuilt context (≀300 tokens per agent) instead of re-analyzing the codebase.

I already have a CLAUDE.md / Cursor rules. Will they be overwritten? Your original is backed up to <file>.pre-agents.bak before the bootstrap pointer is written, and the backup is git-ignored. Merge anything you want to keep into AGENTS.md β€” that's the single source of truth all tools share.

ai-agency: command not found after install? The curl installer puts the binary in ~/.local/bin. Add it to your PATH: export PATH="$HOME/.local/bin:$PATH" (the installer prints this when needed).

Do I need tmux? Only for multi-pane modes (--multi, team, --detach). Single-agent sessions run in your current terminal with no extra dependencies.

Can I undo everything? Yes β€” ai-agency clear interactively removes generated AGENTS.md / .ai-agents/ files per directory, and your pre-existing vendor files can be restored from their *.pre-agents.bak backups. ai-agency uninstall removes the tool itself.


Design principles

  • Vendor-neutral. AGENTS.md is the shared standard; bootstrap files are thin pointers.
  • Only non-inferable facts. If the AI can learn it by reading the code, it doesn't belong in context.
  • Token budgets. Each AGENTS.md stays under ~300 tokens after template substitution. API/event specs use JSON DSL (~3Γ— cheaper than prose).
  • Separation of knowledge / behavior / role. Context (always loaded), skills (on demand), roles (per-agent loading strategy) β€” mixing them makes token usage unpredictable.
  • File-based coordination. Multi-agent handoffs use plain Markdown + JSON in .ai-agents/coordination/, so any tool can participate.
  • No lock-in, no phone-home. Plain Bash + plain text files. Delete the tool and your context still works.

How it works (internals)

  1. classify-dirs.sh applies 19 file-pattern rules to hint at each directory's type. The AI makes the final call.
  2. scaffold.sh creates .ai-agents/ at root and per sub-project.
  3. setup.sh launches your AI tool with HOW_TO_AGENTS.md β€” a 7-step meta-instruction that drives the generation.
  4. validate.sh enforces required sections, token limits, and reference integrity.
  5. sync-ai-rules.sh emits vendor bootstrap files (backing up anything it would replace).
  6. ai-agency.sh runs the interactive CUI, tracks session checksums, and injects the coordination protocol into multi-agent sessions.

Contributing

Bug reports, feature requests, and PRs are welcome β€” especially:

  • New vendor bootstraps (one function in sync-ai-rules.sh)
  • Classification rules for more stacks (classify-dirs.sh)
  • Translations β€” README and UI strings for more languages

Keep shell changes shellcheck-clean and set -euo pipefail-safe. Open an issue first for anything structural.

If ai-agency saves you tokens, a ⭐ helps others find it.


References


License

MIT


Set up once. Work forever.

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages