Skip to main content

Audit, generate, sync, and package repository context files for AI coding agents.

Project description

Agent Context Doctor

Audit, generate, sync, and package repository context files for AI coding agents.

agentctx helps you keep project instructions accurate across tools such as Codex, Claude Code, Gemini CLI, Cursor, and GitHub Copilot. It works locally, uses no LLM API, and has zero runtime dependencies.

Why?

AI coding agents work better when your repository has clear, current, and tool-readable instructions. Many projects now carry several context files:

  • AGENTS.md
  • CLAUDE.md
  • GEMINI.md
  • .github/copilot-instructions.md
  • .cursor/rules/
  • HANDOFF.md

Keeping those files synchronized by hand is easy to forget. Agent Context Doctor scans your repository, reports missing or stale context, generates starter files, safely syncs generated sections, and creates handoff/context packs for the next AI coding session.

Features

  • Scan repository context with a readable score and machine-readable JSON.
  • Generate starter files for AGENTS.md, Claude, Gemini, Copilot, Cursor, and handoff notes.
  • Safely sync generated sections without deleting user-written content outside markers, including Cursor rules.
  • Create handoff summaries from local Git state.
  • Package AI-ready context into PROJECT_CONTEXT.md.
  • Run safe repairs with agentctx doctor --fix.
  • Zero runtime dependencies; Python standard library only.

Installation

From PyPI, once published:

pip install agent-context-doctor

From source:

git clone https://github.com/lamguo/agent-context-doctor.git
cd agent-context-doctor
python -m pip install -e .

Quick start

# Audit the current repository
agentctx scan

# JSON output for scripts or CI
agentctx scan --json
agentctx scan --fail-under 80

# Generate AGENTS.md and HANDOFF.md if missing
agentctx init

# Generate all supported context files
agentctx init --all

# Sync AGENTS.md into Claude, Gemini, Copilot, and Cursor instruction files
agentctx sync --from AGENTS.md

# Check whether generated files are in sync
agentctx sync --check

# Generate a handoff file from local Git state
agentctx handoff

# Generate PROJECT_CONTEXT.md for a new AI coding session
agentctx pack

# Plan safe context repairs
agentctx doctor

# Apply safe context repairs
agentctx doctor --fix

Example scan output

Agent Context Doctor

Repository: my-project
Score: 82/100 (Good)

Found:
  ✅ README.md
  ✅ AGENTS.md
  ✅ tests/

Missing:
  ⚠️ HANDOFF.md
  ⚠️ GEMINI.md

Problems:
  ⚠️ Missing HANDOFF.md. Long AI coding sessions are easier to resume with a handoff file.
  ⚠️ Missing GEMINI.md.

Suggestions:
  - Run: agentctx init --all
  - Run: agentctx handoff

Commands

agentctx scan

Checks common AI context files, project files, referenced local paths, common test commands, and sync markers.

agentctx scan
agentctx scan --json
agentctx scan --fail-under 80
agentctx scan --root /path/to/repo

agentctx init

Creates starter templates. Existing files are skipped by default.

agentctx init
agentctx init --all
agentctx init --dry-run
agentctx init --force

agentctx sync

Copies AGENTS.md into generated sections in tool-specific files. It only replaces content between agentctx markers.

agentctx sync --from AGENTS.md
agentctx sync --to claude --to gemini
agentctx sync --to cursor
agentctx sync --dry-run
agentctx sync --check

agentctx handoff

Creates a handoff file using local Git metadata.

agentctx handoff
agentctx handoff --json
agentctx handoff --output HANDOFF.md

agentctx pack

Creates an AI-ready context package.

agentctx pack
agentctx pack --output PROJECT_CONTEXT.md

agentctx doctor

Plans or applies safe automatic repairs. Safe repairs can create missing starter files, generate HANDOFF.md, and create or refresh generated tool files from AGENTS.md. It does not delete files or overwrite user-authored content outside agentctx markers.

agentctx doctor
agentctx doctor --fix
agentctx doctor --json

Generated file safety

agentctx sync uses markers like this:

<!-- agentctx:source AGENTS.md -->
<!-- agentctx:hash abc123 -->
<!-- agentctx:begin -->
Generated content here.
<!-- agentctx:end -->

On later syncs, only the generated block is replaced. Content before or after the markers is preserved.

CI usage

- name: Check agent context
  run: agentctx scan --json

- name: Ensure generated agent files are synced
  run: agentctx sync --check

Development

python -m pip install -e .[dev]
pytest
agentctx scan

Roadmap

  • More stale-path detection rules.
  • Markdown table output option.
  • Context score badge helper.
  • Optional GitHub Action wrapper.
  • Optional --stdout mode for agentctx pack.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_context_doctor-0.2.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_context_doctor-0.2.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file agent_context_doctor-0.2.0.tar.gz.

File metadata

  • Download URL: agent_context_doctor-0.2.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for agent_context_doctor-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c712105ed6e8f76674aca0b86cf238bf8477db37f24e38704ad1c7fd5e6236e2
MD5 bad7612e35f45215dfb4046fc9a63876
BLAKE2b-256 c35be4bc44e2e8ac67dda62c4cbc8e16ef6d8c8ef9076a94d4502034035d13f7

See more details on using hashes here.

File details

Details for the file agent_context_doctor-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_context_doctor-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 940559e4b4068cb32431608fee61bfed15d9ef412e9b9693e8db2f36386463f6
MD5 2e2d6a3864f95c1e2f7f1f0752134142
BLAKE2b-256 4b2c77cc8a8b925e319b105b7449dba575797edd786e7ddee06f126092f78417

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page