Metadata-Version: 2.5
Name: contextplate
Version: 0.1.0
Summary: Boilerplate for agent context. Declare it once. Render it for Claude Code, Codex, Copilot, Cursor, Gemini CLI, and any AGENTS.md tool.
Project-URL: Homepage, https://github.com/deepskpathak/contextplate
Project-URL: Issues, https://github.com/deepskpathak/contextplate/issues
Project-URL: Changelog, https://github.com/deepskpathak/contextplate/blob/master/CHANGELOG.md
Project-URL: Documentation, https://github.com/deepskpathak/contextplate/tree/master/docs
Author: ContextPlate contributors
License-Expression: MIT
License-File: LICENSE
Keywords: AGENTS.md,agent-skills,agents,claude-code,codex,context-engineering,copilot,cursor,gemini-cli,scaffolding
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.11
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff==0.17.6; extra == 'dev'
Description-Content-Type: text/markdown

# ContextPlate

[![CI](https://github.com/deepskpathak/contextplate/actions/workflows/ci.yml/badge.svg)](https://github.com/deepskpathak/contextplate/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/contextplate)](https://pypi.org/project/contextplate/)
[![Python](https://img.shields.io/pypi/pyversions/contextplate)](https://pypi.org/project/contextplate/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)

**Boilerplate for agent context.** Declare it once; render it for every harness.

```bash
pipx install contextplate      # installs the `ctxplate` command
ctxplate init my-app
```

ContextPlate keeps one harness-neutral source of truth (`AGENTS.md` plus `.agents/`) and generates the native files each tool expects: Claude Code, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, and Aider. Any other tool that reads `AGENTS.md` works with no extra setup.

It scaffolds new projects, organizes existing ones, and never overwrites a file you edited.

```text
            you edit                          ctxplate sync                 each tool reads
 ┌───────────────────────────┐                                    ┌──────────────────────────────┐
 │ AGENTS.md                 │                                    │ CLAUDE.md, .claude/...       │
 │ .agents/contextplate.toml    │ ─────────────────────────────────► │ .cursor/rules/*.mdc, ...     │
 │ .agents/rules/*.md        │                                    │ .github/instructions/, ...   │
 │ .agents/skills/*/SKILL.md │                                    │ .codex/agents/*.toml, ...    │
 │ .agents/agents/*.md       │                                    │ .gemini/settings.json, ...   │
 └───────────────────────────┘                                    └──────────────────────────────┘
```

## Why

- **Every tool wants different files.** Scoped rules use `paths` in Claude Code, `globs` in Cursor `.mdc` files, and `applyTo` in Copilot. Subagents are Markdown in one tool and TOML in another. Keeping them in sync by hand drifts within a week.
- **Context is a budget.** Everything in an always-loaded file costs tokens on every turn. ContextPlate keeps the always-on layer small and moves the rest into rules, skills, and subagents that load only when relevant. `ctxplate doctor` measures it.
- **Instructions ask; config enforces.** Protected paths become real permission rules and a pre-edit guard hook, not a sentence the model may ignore.

## Quick start

Requires Python 3.11+. No runtime dependencies.

```bash
pipx install contextplate         # or: uvx contextplate ... (command: ctxplate)
# before the first PyPI release: pipx install git+https://github.com/deepskpathak/contextplate

# New project
ctxplate init my-app --preset python          # harnesses default to the agent CLIs on your PATH

# Existing repository (dry run first, then apply)
cd my-repo
ctxplate adopt                   # shows exactly what would change
ctxplate adopt --apply           # imports existing instructions, rules, skills, subagents, MCP servers

# Day to day
ctxplate sync                    # after editing anything in .agents/
ctxplate doctor                  # context budget, placeholders, portability, drift
ctxplate enable cursor           # add a harness later
```

## What you get

```text
my-app/
├── AGENTS.md                  # the always-on layer (you own it; two small blocks are managed)
├── CLAUDE.md                  # @AGENTS.md plus Claude-specific notes (managed block)
├── .agents/
│   ├── contextplate.toml         # harnesses, modules, commands, protected paths, MCP servers
│   ├── contextplate.lock.json    # what ContextPlate generated (commit it)
│   ├── rules/                 # scoped rules: `paths:` frontmatter, loaded on demand
│   ├── skills/                # Agent Skills (SKILL.md), read natively by Codex, Copilot, Cursor, Gemini
│   ├── agents/                # roles (subagents) in one neutral format
│   └── hooks/                 # guard, session snapshot, formatter (stdlib Python)
├── docs/                      # architecture, glossary, decisions/ (module: docs)
├── work/                      # handoff.md, plans/, scratch/ (module: work)
├── scripts/check.sh           # lint + types + tests, terse output (module: check_script)
└── generated per tool: .claude/  .cursor/  .github/{instructions,agents}/  .codex/  .gemini/  .aider.conf.yml
```

Optional `ai_app` module adds `prompts/`, `evals/`, and `data/` with matching rules and read protection.

## Supported harnesses

| | Instructions | Scoped rules | Skills | Subagents | MCP | Hooks |
|---|---|---|---|---|---|---|
| **Claude Code** | `CLAUDE.md` imports `AGENTS.md` | `.claude/rules/` | `.claude/skills/` (copied) | `.claude/agents/` | `.mcp.json` | guard, snapshot, format |
| **Codex** | `AGENTS.md` (native) | index in `AGENTS.md` | `.agents/skills/` (native) | `.codex/agents/*.toml` | `.codex/config.toml` block | |
| **Copilot** | `AGENTS.md` (native) | `.github/instructions/` | `.agents/skills/` (native) | `.github/agents/` | `.mcp.json` | |
| **Cursor** | `AGENTS.md` (native) | `.cursor/rules/*.mdc` | `.agents/skills/` (native) | `.cursor/agents/` | `.cursor/mcp.json` | |
| **Gemini CLI** | `.gemini/settings.json` points at `AGENTS.md` | index in `AGENTS.md` | `.agents/skills/` | `.gemini/agents/` | `.gemini/settings.json` | |
| **Aider** | `.aider.conf.yml` reads `AGENTS.md` | index in `AGENTS.md` | | | | |
| **Anything else** | `AGENTS.md` | index in `AGENTS.md` | `.agents/skills/` | read the role file | | |

Formats were checked against each vendor's documentation; see [docs/harnesses.md](docs/harnesses.md) for sources and caveats.

## How it stays safe

- **Your edits win.** ContextPlate records a hash for every file it writes. A generated file you changed is reported as a conflict and left alone unless you pass `--force`. Whitespace-only changes (formatters) are not conflicts.
- **Managed blocks, not takeovers.** In files you own (`AGENTS.md`, `CLAUDE.md`, `.gitignore`, `.codex/config.toml`), ContextPlate edits only its marked block. In JSON configs (`.claude/settings.json`, `.mcp.json`, `.gemini/settings.json`) it merges its keys and later removes only what it added.
- **Adopt is a dry run by default.** With `--apply`, originals that would be duplicated are moved to `.agents/imported/*.bak`, never deleted.
- **Hooks are small and local.** Standard-library Python, no network, no telemetry. Read them in `.agents/hooks/`.

## Concepts

- **Four context tiers:** always on (`AGENTS.md`), on demand (rules, skills, docs), session state (`work/handoff.md` plus a git snapshot injected at start), isolated (subagents return summaries). See [docs/concepts.md](docs/concepts.md).
- **Neutral formats:** rules use `paths:`; skills follow the Agent Skills spec with tool hints under `metadata`; roles use neutral `tools` (`read, search, web, shell, edit`) and model tiers (`fast, strong, inherit`). Tool-specific extras use prefixed keys such as `claude.memory: project`.
- **Lightly opinionated:** presets (`generic, python, node, go, rust, jvm`) and modules (`docs, work, ai_app, hooks, check_script`) are defaults, not requirements. Everything is a line in `.agents/contextplate.toml`.

## Commands

| Command | What it does |
|---|---|
| `ctxplate init [dir]` | Scaffold a new project. `--preset`, `--harness a,b\|all\|none`, `--with` / `--without` modules |
| `ctxplate adopt [dir]` | Organize an existing repo. Dry run unless `--apply`; `--minimal` imports only |
| `ctxplate sync` | Regenerate harness files. `--check` for CI, `--dry-run`, `--force` |
| `ctxplate doctor` | Budget, placeholders, skill portability, drift. `--strict` fails on warnings |
| `ctxplate enable/disable <harness>` | Edit the harness list and sync |
| `ctxplate list` | Show harnesses, presets, and modules |

### In CI and pre-commit

Fail builds when generated files drift: run `ctxplate sync --check` in CI, or add the hook to `.pre-commit-config.yaml`:

```yaml
- repo: https://github.com/deepskpathak/contextplate
  rev: v0.1.0
  hooks:
    - id: ctxplate-sync-check
    - id: ctxplate-doctor        # optional
```

## Configuration

See [docs/configuration.md](docs/configuration.md) for every key and the canonical file formats. A taste:

```toml
harnesses = ["claude", "codex", "copilot", "cursor", "gemini"]

[project]
name = "my-app"
preset = "python"

[commands]
test = "pytest -q"
lint = "ruff check ."

[protect]
no_read = [".env", ".env.*", "!.env.example"]
no_edit = [".env", ".env.*", "!.env.example", ".git/**", "uv.lock"]

[mcp.servers.docs]
url = "https://mcp.context7.com/mcp"
```

## FAQ

**Should I commit the generated files?** Yes. Teammates and cloud agents read them directly, and nobody needs ContextPlate installed to benefit. Run `ctxplate sync --check` in CI to catch drift.

**Can I edit a generated file?** You can, and ContextPlate will not overwrite it. The better path is to edit the source in `.agents/` so every tool gets the change.

**Why do Copilot and Cursor show a skill twice?** Both tools read `.claude/skills/` as well as `.agents/skills/`. Claude Code only reads `.claude/skills/`, so the copy is needed when Claude is enabled.

**Windows?** Supported. Set `[hooks] python = "py"` (or `"python"`) and run `scripts/check.sh` from Git Bash or WSL.

**A tool changed its format.** Open an issue with a link to the vendor's docs. Adapters are small, single-file modules; see [CONTRIBUTING.md](CONTRIBUTING.md).

**Related projects.** Other tools also sync rules across agents (for example ruler and rulesync). ContextPlate's focus is the whole context system: scaffolding, adopting existing repos, skills, subagents, MCP, enforcement, and a measured context budget.

## Contributing

Issues and pull requests are welcome. Start with [CONTRIBUTING.md](CONTRIBUTING.md). Security reports: [SECURITY.md](SECURITY.md).

## License

[MIT](LICENSE).

The files ContextPlate generates or copies into your project (AGENTS.md blocks, rules, skills, roles, hooks, configs, and starter docs) are yours. Use them under any license you like, with no attribution or license notice required.
