contextplate 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. contextplate-0.1.0/.gitignore +23 -0
  2. contextplate-0.1.0/CHANGELOG.md +24 -0
  3. contextplate-0.1.0/LICENSE +21 -0
  4. contextplate-0.1.0/PKG-INFO +201 -0
  5. contextplate-0.1.0/README.md +174 -0
  6. contextplate-0.1.0/docs/adopting.md +40 -0
  7. contextplate-0.1.0/docs/concepts.md +81 -0
  8. contextplate-0.1.0/docs/configuration.md +107 -0
  9. contextplate-0.1.0/docs/harnesses.md +72 -0
  10. contextplate-0.1.0/pyproject.toml +60 -0
  11. contextplate-0.1.0/src/contextplate/__init__.py +7 -0
  12. contextplate-0.1.0/src/contextplate/__main__.py +5 -0
  13. contextplate-0.1.0/src/contextplate/adapters/__init__.py +50 -0
  14. contextplate-0.1.0/src/contextplate/adapters/aider.py +28 -0
  15. contextplate-0.1.0/src/contextplate/adapters/base.py +85 -0
  16. contextplate-0.1.0/src/contextplate/adapters/claude.py +181 -0
  17. contextplate-0.1.0/src/contextplate/adapters/codex.py +119 -0
  18. contextplate-0.1.0/src/contextplate/adapters/copilot.py +57 -0
  19. contextplate-0.1.0/src/contextplate/adapters/core.py +197 -0
  20. contextplate-0.1.0/src/contextplate/adapters/cursor.py +55 -0
  21. contextplate-0.1.0/src/contextplate/adapters/gemini.py +31 -0
  22. contextplate-0.1.0/src/contextplate/adopt.py +596 -0
  23. contextplate-0.1.0/src/contextplate/cli.py +308 -0
  24. contextplate-0.1.0/src/contextplate/config.py +306 -0
  25. contextplate-0.1.0/src/contextplate/doctor.py +147 -0
  26. contextplate-0.1.0/src/contextplate/frontmatter.py +226 -0
  27. contextplate-0.1.0/src/contextplate/globs.py +84 -0
  28. contextplate-0.1.0/src/contextplate/model.py +185 -0
  29. contextplate-0.1.0/src/contextplate/presets.py +165 -0
  30. contextplate-0.1.0/src/contextplate/scaffold.py +162 -0
  31. contextplate-0.1.0/src/contextplate/templates/check.sh +44 -0
  32. contextplate-0.1.0/src/contextplate/templates/hooks/format.py +74 -0
  33. contextplate-0.1.0/src/contextplate/templates/hooks/guard.py +121 -0
  34. contextplate-0.1.0/src/contextplate/templates/hooks/session_context.py +79 -0
  35. contextplate-0.1.0/src/contextplate/templates/scaffold/AGENTS.md +29 -0
  36. contextplate-0.1.0/src/contextplate/templates/scaffold/agents/agents/researcher.md +16 -0
  37. contextplate-0.1.0/src/contextplate/templates/scaffold/agents/agents/reviewer.md +20 -0
  38. contextplate-0.1.0/src/contextplate/templates/scaffold/agents/agents/test-runner.md +17 -0
  39. contextplate-0.1.0/src/contextplate/templates/scaffold/agents/rules/ai-assets.md +12 -0
  40. contextplate-0.1.0/src/contextplate/templates/scaffold/agents/rules/docs.md +11 -0
  41. contextplate-0.1.0/src/contextplate/templates/scaffold/agents/skills/adr/SKILL.md +12 -0
  42. contextplate-0.1.0/src/contextplate/templates/scaffold/agents/skills/adr/template.md +21 -0
  43. contextplate-0.1.0/src/contextplate/templates/scaffold/agents/skills/handoff/SKILL.md +17 -0
  44. contextplate-0.1.0/src/contextplate/templates/scaffold/agents/skills/plan-task/SKILL.md +15 -0
  45. contextplate-0.1.0/src/contextplate/templates/scaffold/agents/skills/plan-task/template.md +28 -0
  46. contextplate-0.1.0/src/contextplate/templates/scaffold/ai_app/data/README.md +5 -0
  47. contextplate-0.1.0/src/contextplate/templates/scaffold/ai_app/evals/README.md +7 -0
  48. contextplate-0.1.0/src/contextplate/templates/scaffold/ai_app/prompts/README.md +17 -0
  49. contextplate-0.1.0/src/contextplate/templates/scaffold/docs/agent-context.md +42 -0
  50. contextplate-0.1.0/src/contextplate/templates/scaffold/docs/architecture.md +27 -0
  51. contextplate-0.1.0/src/contextplate/templates/scaffold/docs/decisions/0001-record-architecture-decisions.md +22 -0
  52. contextplate-0.1.0/src/contextplate/templates/scaffold/docs/glossary.md +7 -0
  53. contextplate-0.1.0/src/contextplate/templates/scaffold/work/handoff.md +22 -0
  54. contextplate-0.1.0/src/contextplate/writer.py +396 -0
  55. contextplate-0.1.0/tests/__init__.py +0 -0
  56. contextplate-0.1.0/tests/conftest.py +52 -0
  57. contextplate-0.1.0/tests/test_adopt.py +142 -0
  58. contextplate-0.1.0/tests/test_frontmatter.py +75 -0
  59. contextplate-0.1.0/tests/test_globs.py +61 -0
  60. contextplate-0.1.0/tests/test_hooks_and_doctor.py +113 -0
  61. contextplate-0.1.0/tests/test_init.py +114 -0
  62. contextplate-0.1.0/tests/test_sync.py +150 -0
@@ -0,0 +1,23 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ venv/
5
+ dist/
6
+ build/
7
+ *.egg-info/
8
+ .pytest_cache/
9
+ .ruff_cache/
10
+ .coverage
11
+ htmlcov/
12
+
13
+ # ctxplate:begin agents (generated by ctxplate; edit .agents/ and run `ctxplate sync`)
14
+ # secrets
15
+ .env
16
+ .env.*
17
+ !.env.example
18
+ # personal agent settings
19
+ CLAUDE.local.md
20
+ .claude/settings.local.json
21
+ .claude/agent-memory-local/
22
+ .claude/worktrees/
23
+ # ctxplate:end agents
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ All notable changes are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project uses [Semantic Versioning](https://semver.org/).
4
+
5
+ Release process: set the date on the version heading below, then tag (see CONTRIBUTING.md). The release workflow refuses a tag whose version has no dated entry here.
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2026-11-28
10
+
11
+ ### Added
12
+ - `init`, `adopt`, `sync`, `doctor`, `enable`, `disable`, `list` commands (`ctxplate`, also installed as `contextplate`).
13
+ - Adapters for Claude Code, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, and Aider; any `AGENTS.md`-aware tool works without one.
14
+ - Neutral source formats: scoped rules (`paths`), Agent Skills with `metadata` hints, roles with neutral tools and model tiers, one MCP server definition for every harness.
15
+ - Ownership tracking (`.agents/contextplate.lock.json`), managed blocks, and JSON merging so user edits are never overwritten.
16
+ - Claude Code hooks: protected-path and generated-file guard, session snapshot, per-file formatter.
17
+ - Presets: generic, python, node, go, rust, jvm. Modules: docs, work, ai_app, hooks, check_script.
18
+ - `adopt` importers for CLAUDE.md, .cursorrules, Claude/Cursor/Copilot rules, skills, commands, subagents, and MCP configs, with backups.
19
+ - `doctor` checks for context budget, unfilled placeholders, skill portability, and drift.
20
+ - pre-commit hooks for other repos: `ctxplate-sync-check` and `ctxplate-doctor`.
21
+ - MIT license. Files ContextPlate generates in your project carry no license or attribution requirement.
22
+
23
+ [Unreleased]: https://github.com/deepskpathak/contextplate/compare/v0.1.0...HEAD
24
+ [0.1.0]: https://github.com/deepskpathak/contextplate/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ContextPlate contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,201 @@
1
+ Metadata-Version: 2.5
2
+ Name: contextplate
3
+ Version: 0.1.0
4
+ Summary: Boilerplate for agent context. Declare it once. Render it for Claude Code, Codex, Copilot, Cursor, Gemini CLI, and any AGENTS.md tool.
5
+ Project-URL: Homepage, https://github.com/deepskpathak/contextplate
6
+ Project-URL: Issues, https://github.com/deepskpathak/contextplate/issues
7
+ Project-URL: Changelog, https://github.com/deepskpathak/contextplate/blob/master/CHANGELOG.md
8
+ Project-URL: Documentation, https://github.com/deepskpathak/contextplate/tree/master/docs
9
+ Author: ContextPlate contributors
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: AGENTS.md,agent-skills,agents,claude-code,codex,context-engineering,copilot,cursor,gemini-cli,scaffolding
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Code Generators
22
+ Requires-Python: >=3.11
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=8; extra == 'dev'
25
+ Requires-Dist: ruff==0.17.6; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # ContextPlate
29
+
30
+ [![CI](https://github.com/deepskpathak/contextplate/actions/workflows/ci.yml/badge.svg)](https://github.com/deepskpathak/contextplate/actions/workflows/ci.yml)
31
+ [![PyPI](https://img.shields.io/pypi/v/contextplate)](https://pypi.org/project/contextplate/)
32
+ [![Python](https://img.shields.io/pypi/pyversions/contextplate)](https://pypi.org/project/contextplate/)
33
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
34
+
35
+ **Boilerplate for agent context.** Declare it once; render it for every harness.
36
+
37
+ ```bash
38
+ pipx install contextplate # installs the `ctxplate` command
39
+ ctxplate init my-app
40
+ ```
41
+
42
+ 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.
43
+
44
+ It scaffolds new projects, organizes existing ones, and never overwrites a file you edited.
45
+
46
+ ```text
47
+ you edit ctxplate sync each tool reads
48
+ ┌───────────────────────────┐ ┌──────────────────────────────┐
49
+ │ AGENTS.md │ │ CLAUDE.md, .claude/... │
50
+ │ .agents/contextplate.toml │ ─────────────────────────────────► │ .cursor/rules/*.mdc, ... │
51
+ │ .agents/rules/*.md │ │ .github/instructions/, ... │
52
+ │ .agents/skills/*/SKILL.md │ │ .codex/agents/*.toml, ... │
53
+ │ .agents/agents/*.md │ │ .gemini/settings.json, ... │
54
+ └───────────────────────────┘ └──────────────────────────────┘
55
+ ```
56
+
57
+ ## Why
58
+
59
+ - **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.
60
+ - **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.
61
+ - **Instructions ask; config enforces.** Protected paths become real permission rules and a pre-edit guard hook, not a sentence the model may ignore.
62
+
63
+ ## Quick start
64
+
65
+ Requires Python 3.11+. No runtime dependencies.
66
+
67
+ ```bash
68
+ pipx install contextplate # or: uvx contextplate ... (command: ctxplate)
69
+ # before the first PyPI release: pipx install git+https://github.com/deepskpathak/contextplate
70
+
71
+ # New project
72
+ ctxplate init my-app --preset python # harnesses default to the agent CLIs on your PATH
73
+
74
+ # Existing repository (dry run first, then apply)
75
+ cd my-repo
76
+ ctxplate adopt # shows exactly what would change
77
+ ctxplate adopt --apply # imports existing instructions, rules, skills, subagents, MCP servers
78
+
79
+ # Day to day
80
+ ctxplate sync # after editing anything in .agents/
81
+ ctxplate doctor # context budget, placeholders, portability, drift
82
+ ctxplate enable cursor # add a harness later
83
+ ```
84
+
85
+ ## What you get
86
+
87
+ ```text
88
+ my-app/
89
+ ├── AGENTS.md # the always-on layer (you own it; two small blocks are managed)
90
+ ├── CLAUDE.md # @AGENTS.md plus Claude-specific notes (managed block)
91
+ ├── .agents/
92
+ │ ├── contextplate.toml # harnesses, modules, commands, protected paths, MCP servers
93
+ │ ├── contextplate.lock.json # what ContextPlate generated (commit it)
94
+ │ ├── rules/ # scoped rules: `paths:` frontmatter, loaded on demand
95
+ │ ├── skills/ # Agent Skills (SKILL.md), read natively by Codex, Copilot, Cursor, Gemini
96
+ │ ├── agents/ # roles (subagents) in one neutral format
97
+ │ └── hooks/ # guard, session snapshot, formatter (stdlib Python)
98
+ ├── docs/ # architecture, glossary, decisions/ (module: docs)
99
+ ├── work/ # handoff.md, plans/, scratch/ (module: work)
100
+ ├── scripts/check.sh # lint + types + tests, terse output (module: check_script)
101
+ └── generated per tool: .claude/ .cursor/ .github/{instructions,agents}/ .codex/ .gemini/ .aider.conf.yml
102
+ ```
103
+
104
+ Optional `ai_app` module adds `prompts/`, `evals/`, and `data/` with matching rules and read protection.
105
+
106
+ ## Supported harnesses
107
+
108
+ | | Instructions | Scoped rules | Skills | Subagents | MCP | Hooks |
109
+ |---|---|---|---|---|---|---|
110
+ | **Claude Code** | `CLAUDE.md` imports `AGENTS.md` | `.claude/rules/` | `.claude/skills/` (copied) | `.claude/agents/` | `.mcp.json` | guard, snapshot, format |
111
+ | **Codex** | `AGENTS.md` (native) | index in `AGENTS.md` | `.agents/skills/` (native) | `.codex/agents/*.toml` | `.codex/config.toml` block | |
112
+ | **Copilot** | `AGENTS.md` (native) | `.github/instructions/` | `.agents/skills/` (native) | `.github/agents/` | `.mcp.json` | |
113
+ | **Cursor** | `AGENTS.md` (native) | `.cursor/rules/*.mdc` | `.agents/skills/` (native) | `.cursor/agents/` | `.cursor/mcp.json` | |
114
+ | **Gemini CLI** | `.gemini/settings.json` points at `AGENTS.md` | index in `AGENTS.md` | `.agents/skills/` | `.gemini/agents/` | `.gemini/settings.json` | |
115
+ | **Aider** | `.aider.conf.yml` reads `AGENTS.md` | index in `AGENTS.md` | | | | |
116
+ | **Anything else** | `AGENTS.md` | index in `AGENTS.md` | `.agents/skills/` | read the role file | | |
117
+
118
+ Formats were checked against each vendor's documentation; see [docs/harnesses.md](docs/harnesses.md) for sources and caveats.
119
+
120
+ ## How it stays safe
121
+
122
+ - **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.
123
+ - **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.
124
+ - **Adopt is a dry run by default.** With `--apply`, originals that would be duplicated are moved to `.agents/imported/*.bak`, never deleted.
125
+ - **Hooks are small and local.** Standard-library Python, no network, no telemetry. Read them in `.agents/hooks/`.
126
+
127
+ ## Concepts
128
+
129
+ - **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).
130
+ - **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`.
131
+ - **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`.
132
+
133
+ ## Commands
134
+
135
+ | Command | What it does |
136
+ |---|---|
137
+ | `ctxplate init [dir]` | Scaffold a new project. `--preset`, `--harness a,b\|all\|none`, `--with` / `--without` modules |
138
+ | `ctxplate adopt [dir]` | Organize an existing repo. Dry run unless `--apply`; `--minimal` imports only |
139
+ | `ctxplate sync` | Regenerate harness files. `--check` for CI, `--dry-run`, `--force` |
140
+ | `ctxplate doctor` | Budget, placeholders, skill portability, drift. `--strict` fails on warnings |
141
+ | `ctxplate enable/disable <harness>` | Edit the harness list and sync |
142
+ | `ctxplate list` | Show harnesses, presets, and modules |
143
+
144
+ ### In CI and pre-commit
145
+
146
+ Fail builds when generated files drift: run `ctxplate sync --check` in CI, or add the hook to `.pre-commit-config.yaml`:
147
+
148
+ ```yaml
149
+ - repo: https://github.com/deepskpathak/contextplate
150
+ rev: v0.1.0
151
+ hooks:
152
+ - id: ctxplate-sync-check
153
+ - id: ctxplate-doctor # optional
154
+ ```
155
+
156
+ ## Configuration
157
+
158
+ See [docs/configuration.md](docs/configuration.md) for every key and the canonical file formats. A taste:
159
+
160
+ ```toml
161
+ harnesses = ["claude", "codex", "copilot", "cursor", "gemini"]
162
+
163
+ [project]
164
+ name = "my-app"
165
+ preset = "python"
166
+
167
+ [commands]
168
+ test = "pytest -q"
169
+ lint = "ruff check ."
170
+
171
+ [protect]
172
+ no_read = [".env", ".env.*", "!.env.example"]
173
+ no_edit = [".env", ".env.*", "!.env.example", ".git/**", "uv.lock"]
174
+
175
+ [mcp.servers.docs]
176
+ url = "https://mcp.context7.com/mcp"
177
+ ```
178
+
179
+ ## FAQ
180
+
181
+ **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.
182
+
183
+ **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.
184
+
185
+ **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.
186
+
187
+ **Windows?** Supported. Set `[hooks] python = "py"` (or `"python"`) and run `scripts/check.sh` from Git Bash or WSL.
188
+
189
+ **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).
190
+
191
+ **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.
192
+
193
+ ## Contributing
194
+
195
+ Issues and pull requests are welcome. Start with [CONTRIBUTING.md](CONTRIBUTING.md). Security reports: [SECURITY.md](SECURITY.md).
196
+
197
+ ## License
198
+
199
+ [MIT](LICENSE).
200
+
201
+ 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.
@@ -0,0 +1,174 @@
1
+ # ContextPlate
2
+
3
+ [![CI](https://github.com/deepskpathak/contextplate/actions/workflows/ci.yml/badge.svg)](https://github.com/deepskpathak/contextplate/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/contextplate)](https://pypi.org/project/contextplate/)
5
+ [![Python](https://img.shields.io/pypi/pyversions/contextplate)](https://pypi.org/project/contextplate/)
6
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
7
+
8
+ **Boilerplate for agent context.** Declare it once; render it for every harness.
9
+
10
+ ```bash
11
+ pipx install contextplate # installs the `ctxplate` command
12
+ ctxplate init my-app
13
+ ```
14
+
15
+ 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.
16
+
17
+ It scaffolds new projects, organizes existing ones, and never overwrites a file you edited.
18
+
19
+ ```text
20
+ you edit ctxplate sync each tool reads
21
+ ┌───────────────────────────┐ ┌──────────────────────────────┐
22
+ │ AGENTS.md │ │ CLAUDE.md, .claude/... │
23
+ │ .agents/contextplate.toml │ ─────────────────────────────────► │ .cursor/rules/*.mdc, ... │
24
+ │ .agents/rules/*.md │ │ .github/instructions/, ... │
25
+ │ .agents/skills/*/SKILL.md │ │ .codex/agents/*.toml, ... │
26
+ │ .agents/agents/*.md │ │ .gemini/settings.json, ... │
27
+ └───────────────────────────┘ └──────────────────────────────┘
28
+ ```
29
+
30
+ ## Why
31
+
32
+ - **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.
33
+ - **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.
34
+ - **Instructions ask; config enforces.** Protected paths become real permission rules and a pre-edit guard hook, not a sentence the model may ignore.
35
+
36
+ ## Quick start
37
+
38
+ Requires Python 3.11+. No runtime dependencies.
39
+
40
+ ```bash
41
+ pipx install contextplate # or: uvx contextplate ... (command: ctxplate)
42
+ # before the first PyPI release: pipx install git+https://github.com/deepskpathak/contextplate
43
+
44
+ # New project
45
+ ctxplate init my-app --preset python # harnesses default to the agent CLIs on your PATH
46
+
47
+ # Existing repository (dry run first, then apply)
48
+ cd my-repo
49
+ ctxplate adopt # shows exactly what would change
50
+ ctxplate adopt --apply # imports existing instructions, rules, skills, subagents, MCP servers
51
+
52
+ # Day to day
53
+ ctxplate sync # after editing anything in .agents/
54
+ ctxplate doctor # context budget, placeholders, portability, drift
55
+ ctxplate enable cursor # add a harness later
56
+ ```
57
+
58
+ ## What you get
59
+
60
+ ```text
61
+ my-app/
62
+ ├── AGENTS.md # the always-on layer (you own it; two small blocks are managed)
63
+ ├── CLAUDE.md # @AGENTS.md plus Claude-specific notes (managed block)
64
+ ├── .agents/
65
+ │ ├── contextplate.toml # harnesses, modules, commands, protected paths, MCP servers
66
+ │ ├── contextplate.lock.json # what ContextPlate generated (commit it)
67
+ │ ├── rules/ # scoped rules: `paths:` frontmatter, loaded on demand
68
+ │ ├── skills/ # Agent Skills (SKILL.md), read natively by Codex, Copilot, Cursor, Gemini
69
+ │ ├── agents/ # roles (subagents) in one neutral format
70
+ │ └── hooks/ # guard, session snapshot, formatter (stdlib Python)
71
+ ├── docs/ # architecture, glossary, decisions/ (module: docs)
72
+ ├── work/ # handoff.md, plans/, scratch/ (module: work)
73
+ ├── scripts/check.sh # lint + types + tests, terse output (module: check_script)
74
+ └── generated per tool: .claude/ .cursor/ .github/{instructions,agents}/ .codex/ .gemini/ .aider.conf.yml
75
+ ```
76
+
77
+ Optional `ai_app` module adds `prompts/`, `evals/`, and `data/` with matching rules and read protection.
78
+
79
+ ## Supported harnesses
80
+
81
+ | | Instructions | Scoped rules | Skills | Subagents | MCP | Hooks |
82
+ |---|---|---|---|---|---|---|
83
+ | **Claude Code** | `CLAUDE.md` imports `AGENTS.md` | `.claude/rules/` | `.claude/skills/` (copied) | `.claude/agents/` | `.mcp.json` | guard, snapshot, format |
84
+ | **Codex** | `AGENTS.md` (native) | index in `AGENTS.md` | `.agents/skills/` (native) | `.codex/agents/*.toml` | `.codex/config.toml` block | |
85
+ | **Copilot** | `AGENTS.md` (native) | `.github/instructions/` | `.agents/skills/` (native) | `.github/agents/` | `.mcp.json` | |
86
+ | **Cursor** | `AGENTS.md` (native) | `.cursor/rules/*.mdc` | `.agents/skills/` (native) | `.cursor/agents/` | `.cursor/mcp.json` | |
87
+ | **Gemini CLI** | `.gemini/settings.json` points at `AGENTS.md` | index in `AGENTS.md` | `.agents/skills/` | `.gemini/agents/` | `.gemini/settings.json` | |
88
+ | **Aider** | `.aider.conf.yml` reads `AGENTS.md` | index in `AGENTS.md` | | | | |
89
+ | **Anything else** | `AGENTS.md` | index in `AGENTS.md` | `.agents/skills/` | read the role file | | |
90
+
91
+ Formats were checked against each vendor's documentation; see [docs/harnesses.md](docs/harnesses.md) for sources and caveats.
92
+
93
+ ## How it stays safe
94
+
95
+ - **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.
96
+ - **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.
97
+ - **Adopt is a dry run by default.** With `--apply`, originals that would be duplicated are moved to `.agents/imported/*.bak`, never deleted.
98
+ - **Hooks are small and local.** Standard-library Python, no network, no telemetry. Read them in `.agents/hooks/`.
99
+
100
+ ## Concepts
101
+
102
+ - **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).
103
+ - **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`.
104
+ - **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`.
105
+
106
+ ## Commands
107
+
108
+ | Command | What it does |
109
+ |---|---|
110
+ | `ctxplate init [dir]` | Scaffold a new project. `--preset`, `--harness a,b\|all\|none`, `--with` / `--without` modules |
111
+ | `ctxplate adopt [dir]` | Organize an existing repo. Dry run unless `--apply`; `--minimal` imports only |
112
+ | `ctxplate sync` | Regenerate harness files. `--check` for CI, `--dry-run`, `--force` |
113
+ | `ctxplate doctor` | Budget, placeholders, skill portability, drift. `--strict` fails on warnings |
114
+ | `ctxplate enable/disable <harness>` | Edit the harness list and sync |
115
+ | `ctxplate list` | Show harnesses, presets, and modules |
116
+
117
+ ### In CI and pre-commit
118
+
119
+ Fail builds when generated files drift: run `ctxplate sync --check` in CI, or add the hook to `.pre-commit-config.yaml`:
120
+
121
+ ```yaml
122
+ - repo: https://github.com/deepskpathak/contextplate
123
+ rev: v0.1.0
124
+ hooks:
125
+ - id: ctxplate-sync-check
126
+ - id: ctxplate-doctor # optional
127
+ ```
128
+
129
+ ## Configuration
130
+
131
+ See [docs/configuration.md](docs/configuration.md) for every key and the canonical file formats. A taste:
132
+
133
+ ```toml
134
+ harnesses = ["claude", "codex", "copilot", "cursor", "gemini"]
135
+
136
+ [project]
137
+ name = "my-app"
138
+ preset = "python"
139
+
140
+ [commands]
141
+ test = "pytest -q"
142
+ lint = "ruff check ."
143
+
144
+ [protect]
145
+ no_read = [".env", ".env.*", "!.env.example"]
146
+ no_edit = [".env", ".env.*", "!.env.example", ".git/**", "uv.lock"]
147
+
148
+ [mcp.servers.docs]
149
+ url = "https://mcp.context7.com/mcp"
150
+ ```
151
+
152
+ ## FAQ
153
+
154
+ **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.
155
+
156
+ **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.
157
+
158
+ **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.
159
+
160
+ **Windows?** Supported. Set `[hooks] python = "py"` (or `"python"`) and run `scripts/check.sh` from Git Bash or WSL.
161
+
162
+ **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).
163
+
164
+ **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.
165
+
166
+ ## Contributing
167
+
168
+ Issues and pull requests are welcome. Start with [CONTRIBUTING.md](CONTRIBUTING.md). Security reports: [SECURITY.md](SECURITY.md).
169
+
170
+ ## License
171
+
172
+ [MIT](LICENSE).
173
+
174
+ 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.
@@ -0,0 +1,40 @@
1
+ # Adopting an existing repository
2
+
3
+ ```bash
4
+ ctxplate adopt # dry run: prints every move and create
5
+ ctxplate adopt --apply # do it
6
+ ctxplate adopt --minimal # import only; add no starter docs, roles, or skills
7
+ git diff # review
8
+ ```
9
+
10
+ ## What gets imported
11
+
12
+ | Found | Becomes | Original |
13
+ |---|---|---|
14
+ | `CLAUDE.md`, `.claude/CLAUDE.md`, `.github/copilot-instructions.md`, `GEMINI.md`, `.cursorrules`, `.windsurfrules` (first one found, when there is no `AGENTS.md`) | `AGENTS.md` | moved to `.agents/imported/*.bak` |
15
+ | Other instruction files | left in place, with a note to merge them | kept |
16
+ | `.claude/rules/**/*.md` | `.agents/rules/` (`paths` kept) | backed up, regenerated |
17
+ | `.cursor/rules/**/*.mdc` with `globs` or `alwaysApply` | `.agents/rules/` | backed up, regenerated |
18
+ | `.cursor/rules/*.mdc` with only a description ("apply intelligently") | a skill in `.agents/skills/` | backed up |
19
+ | `.github/instructions/*.instructions.md` | `.agents/rules/` (`applyTo` becomes `paths`) | backed up, regenerated |
20
+ | `.claude/skills/`, `.cursor/skills/`, `.github/skills/` | `.agents/skills/` (Claude-only keys move under `metadata`) | backed up, regenerated |
21
+ | `.claude/commands/*.md` | manual skills in `.agents/skills/` | backed up |
22
+ | `.claude/agents/`, `.cursor/agents/`, `.github/agents/`, `.gemini/agents/`, `.codex/agents/*.toml` | `.agents/agents/` (neutral tools; tool-specific keys kept as `<harness>.<key>`) | backed up, regenerated |
23
+ | MCP servers in `.mcp.json`, `.cursor/mcp.json`, `.gemini/settings.json`, `.vscode/mcp.json`, `.codex/config.toml` | `[mcp.servers]` in the config | files kept and merged |
24
+ | `.claude/settings.json` | kept; ContextPlate merges its keys | kept |
25
+ | `scripts/check.sh` | kept and used as the check command | kept |
26
+
27
+ Harnesses are enabled based on what was found (override with `--harness`). The preset is detected from `pyproject.toml`, `package.json`, `go.mod`, `Cargo.toml`, or Gradle/Maven files.
28
+
29
+ ## Fidelity notes
30
+
31
+ - Claude subagents that use Claude-only tools (`TodoWrite`, MCP tools, and so on) keep their exact tool list for Claude through a `claude.tools` override. Other harnesses get the neutral subset.
32
+ - Harness-specific model names become overrides (`claude.model: sonnet`) and are never copied to other tools.
33
+ - If your Claude settings already run a PostToolUse hook, ContextPlate does not add its formatter.
34
+ - `@imports` inside an imported `CLAUDE.md` are only expanded by Claude Code and Copilot. Inline anything other tools need.
35
+
36
+ ## After adopting
37
+
38
+ 1. Review `git diff`.
39
+ 2. Merge anything still useful from `.agents/imported/` into `AGENTS.md` or `.agents/`, then delete `.agents/imported/`.
40
+ 3. Run `ctxplate doctor`. An inherited `CLAUDE.md` is often over the context budget; move detail into scoped rules or skills.
@@ -0,0 +1,81 @@
1
+ # Concepts
2
+
3
+ ## Sources and outputs
4
+
5
+ ContextPlate separates what you write from what each tool reads.
6
+
7
+ | | Who edits it | Examples |
8
+ |---|---|---|
9
+ | **Sources** | You (and your agents) | `AGENTS.md`, `.agents/contextplate.toml`, `.agents/rules/`, `.agents/skills/`, `.agents/agents/` |
10
+ | **Outputs** | `ctxplate sync` | `.claude/rules/`, `.cursor/rules/*.mdc`, `.github/instructions/`, `.codex/agents/*.toml`, `.gemini/agents/` |
11
+ | **Shared files** | Both, in separate regions | `AGENTS.md` and `CLAUDE.md` (managed blocks), `.claude/settings.json` and `.mcp.json` (merged keys) |
12
+
13
+ `.agents/contextplate.lock.json` records every output and a hash of what was written. That is how ContextPlate knows a file is safe to update or remove, and how it notices you edited one.
14
+
15
+ ## Write strategies
16
+
17
+ | Strategy | Used for | Behavior |
18
+ |---|---|---|
19
+ | **owned** | Whole generated files (rules, skills, agents, hooks, `scripts/check.sh`) | Written in full. If you edited it, sync reports a conflict and leaves it alone (`--force` overwrites). Whitespace-only differences are accepted, so formatters do not cause conflicts. |
20
+ | **block** | Files you own (`AGENTS.md`, `CLAUDE.md`, `.gitignore`, `.prettierignore`, `.codex/config.toml`, `.aider.conf.yml`) | Only the region between `ctxplate:begin <id>` and `ctxplate:end <id>` markers is rewritten. |
21
+ | **json** | `.claude/settings.json`, `.mcp.json`, `.cursor/mcp.json`, `.gemini/settings.json` | ContextPlate's keys are merged in. On the next sync, entries it added last time are removed before the new ones are added, so your own keys survive. |
22
+
23
+ When a harness or module is turned off, unmodified outputs are deleted, blocks are removed, and merged keys are taken back out. Anything you edited is kept and reported.
24
+
25
+ ## Four context tiers
26
+
27
+ | Tier | What | Loads | Cost |
28
+ |---|---|---|---|
29
+ | 1. Always on | `AGENTS.md` (and `CLAUDE.md`, which imports it) | Every session | Every token, every turn |
30
+ | 2. On demand | Scoped rules, skills, `docs/` | When a matching file is touched, a skill fits, or the agent decides to read | Only when relevant |
31
+ | 3. Session state | `work/handoff.md`, git snapshot, active plans | Session start, `/clear`, and after compaction (Claude Code hook) | About 40 lines |
32
+ | 4. Isolated | Roles in `.agents/agents/`, run as subagents | Their own context window; only a summary returns | Near zero in the main session |
33
+
34
+ `ctxplate doctor` estimates tier 1 (about 4 characters per token) and warns when it exceeds `[context].budget_tokens`.
35
+
36
+ ## The AGENTS.md index
37
+
38
+ Tools without native scoped rules, skills, or subagents (Codex for rules, Gemini for rules, Aider, and anything unknown) still need to know those files exist. ContextPlate maintains a short "Load on demand" block in `AGENTS.md` that points at them.
39
+
40
+ - `index = "compact"` (default): rule paths plus skill and role names. Tools with native support already inject descriptions, so repeating them wastes tokens.
41
+ - `index = "full"`: adds one-line descriptions.
42
+ - `index = "off"`: no block.
43
+
44
+ ## Neutral formats
45
+
46
+ **Rule** (`.agents/rules/<name>.md`)
47
+
48
+ ```markdown
49
+ ---
50
+ description: Test conventions
51
+ paths: ["tests/**", "**/*.test.*"]
52
+ ---
53
+
54
+ # Test rules
55
+
56
+ - One behavior per test.
57
+ ```
58
+
59
+ No `paths` means always on. Brace patterns (`*.{ts,tsx}`) are expanded for tools that do not support them.
60
+
61
+ **Skill** (`.agents/skills/<name>/SKILL.md`): the [Agent Skills](https://agentskills.io) format. Keep top-level keys portable (`name`, `description`, `license`, `compatibility`, `metadata`, `allowed-tools`). Tool hints go under `metadata`:
62
+
63
+ - `invocation: manual`: user-invoked only (Claude Code `disable-model-invocation`)
64
+ - `argument-hint: "<arg>"`
65
+ - `claude-<key>: value`: copied to Claude's frontmatter as `<key>`
66
+
67
+ **Role** (`.agents/agents/<name>.md`)
68
+
69
+ ```markdown
70
+ ---
71
+ name: reviewer
72
+ description: Reviews the current diff. Use before reporting a task as done.
73
+ tools: [read, search, shell] # read, search, web, shell, edit; omit for all
74
+ model: inherit # fast, strong, inherit (mapped per harness in [models])
75
+ claude.memory: project # <harness>.<key>: passed through to that harness only
76
+ ---
77
+
78
+ You are a senior reviewer...
79
+ ```
80
+
81
+ A role is read-only when its tools include neither `edit` nor `shell`. That becomes `readonly: true` in Cursor and `sandbox_mode = "read-only"` in Codex.