agent-context CLI manages your Agent Context System from the terminal. It initializes the file structure in a project, validates your setup, and moves proven patterns from your personal scratchpad into the shared AGENTS.md. All commands operate within your current working directory — the CLI never writes outside the project root.
Main commands
agent-context init
agent-context init
Sets up the Agent Context System in your current project. Run this once per clone. It is safe to re-run — it will not overwrite files that already exist.What it does:
- Creates
.agents.local.mdfrom the bundled template (or a minimal fallback if the template is not found). - Adds
.agents.local.mdto.gitignore, creating the file if it does not exist. - Creates a
CLAUDE.mdsymlink pointing toAGENTS.mdso Claude Code picks up your context. - Creates the
agent_docs/directory with starter files (conventions.md,architecture.md,gotchas.md) ifAGENTS.mdis present butagent_docs/is not.
init immediately after cloning a project that uses the Agent Context System, or when setting up a new project for the first time.Expected output:If
AGENTS.md is not present when you run init, the CLAUDE.md symlink step is skipped. Copy AGENTS.md to your project first, then re-run init.agent-context validate
agent-context validate
Checks that your Agent Context System setup is correct. Use this after What it checks:The command exits with a non-zero status if any errors are found, making it suitable for use in scripts and CI pipelines.
init and any time you want to verify nothing has drifted.AGENTS.mdexists and is under 120 lines..agents.local.mdexists..agents.local.mdis listed in.gitignore.CLAUDE.mdis a symlink pointing toAGENTS.md.agent_docs/directory exists (warning if missing, not an error).AGENTS.mddoes not contain obvious secrets (API keys, tokens, passwords).
AGENTS.md, or as part of a CI check to catch accidental secret commits.Expected output (all passing):agent-context promote
agent-context promote
Shows patterns that your agent has flagged in the What it does:Reads If no patterns have been flagged yet, it prints
## Ready to Promote section of .agents.local.md, and displays stats about how many sessions have been logged. Use this to decide what to move into AGENTS.md..agents.local.md and prints anything in the ## Ready to Promote section. Also shows the total number of sessions logged so you can judge how much history has accumulated.When to use it: Periodically — after several sessions have built up, or when your agent tells you it has flagged new patterns during compression.Expected output:(none flagged yet).agent-context promote --autopromote
agent-context promote --autopromote
Automatically appends all patterns from the What it does:
## Ready to Promote section of .agents.local.md into AGENTS.md, then clears the promoted items from the scratchpad.- Reads the
## Ready to Promotesection of.agents.local.md. - Checks that
AGENTS.mdis under 120 lines before proceeding. - Appends each pipe-delimited pattern to
AGENTS.md(creating a## Patternssection if one does not exist). - Clears the promoted patterns from the scratchpad and logs the promotion date.
agent-context promote and are ready to commit them to AGENTS.md without manually copying each line.Expected output:You can adjust the recurrence threshold with
--threshold N. The default is 3 sessions. Patterns with fewer recurrences are still shown by promote but are not auto-appended.agent-context help
agent-context help
Prints usage information for all commands.
Helper scripts
These scripts live inscripts/ and handle memory consolidation and migration. Run them from your project root.
auto-consolidation-trigger.sh
auto-consolidation-trigger.sh
Checks whether automatic memory consolidation should run, based on time elapsed and session count, then triggers consolidation if the conditions are met.Gates checked:
- Time gate: At least 24 hours since the last consolidation.
- Session gate: At least 5 sessions accumulated since last consolidation.
- Lock gate: No consolidation already running (checked via
.agents/.consolidation-lock).
--check to a shell hook or run it manually when you want to let the system decide whether consolidation is warranted. Use --force when you want consolidation to run immediately regardless of thresholds.consolidate-memory.sh
consolidate-memory.sh
Runs the full 4-phase memory consolidation: orient, gather, consolidate, prune. Reads recent daily logs from What it produces:
.agents/logs/ and merges them into the curated topic files under .agents/topics/.- Updated
.agents/topics/patterns.md,.agents/topics/gotchas.md,.agents/topics/preferences.md. - An updated
.agents/local.mdindex (kept under 200 lines / 25 KB). - Approximately a 9:1 compression ratio on accumulated session logs.
migrate-to-daily-logs.sh
migrate-to-daily-logs.sh
Migrates an older flat When to use it: If you set up the Agent Context System before the daily logs format was introduced and your project still uses the legacy flat
.agents.local.md scratchpad to the structured daily logs format (.agents/logs/YYYY-MM-DD.md and .agents/topics/)..agents.local.md file. Run once — the script exits early if it detects the migration has already happened.