ctx-init — context initialization in a repo
Creates the ctx structure in the current repo:
AGENTS.md from template with frontmatter (all @-imports are relative @./rules/...)
CLAUDE.md with @AGENTS.md import
rules/ with copies of shared plugin rules (language, dates, git, no-secrets, no-public-names) plus project-specific stubs (stack, testing, boundaries, focus)
Both shared rules and templates exist in two language variants: en/ (English) and ru/ (Russian). The user picks one at init time. Shared rules are copied rather than imported via ${CLAUDE_PLUGIN_ROOT} because Claude Code does not expand env variables in project-level @-imports (and this is needed for cross-agent compatibility: Codex/Gemini/Cursor all read the same AGENTS.md).
Input (ask the user before running)
- project — short name (e.g.
MYAPP, API, DOCS).
- description — one line describing the project topic.
- language —
en or ru (default en). Determines the language of AGENTS.md headers, the 5 shared rule files (language, dates, git, no-secrets, no-public-names), and the 4 project stubs (stack, testing, boundaries, focus).
Procedure
Pre-flight checks:
pwd must be the root of the repo being initialized.
- If
AGENTS.md already exists — stop and tell the user that migration is not supported. Ask the user to rename the old file manually (mv AGENTS.md AGENTS.md.legacy) and call ctx-init again.
Actions (replace <LANG> with the chosen en or ru):
- Copy
${CLAUDE_PLUGIN_ROOT}/templates/<LANG>/AGENTS.md.template to ./AGENTS.md.
- Substitute
{{PROJECT}}, {{DESCRIPTION}} via sed.
- Copy
${CLAUDE_PLUGIN_ROOT}/templates/<LANG>/CLAUDE.md.template to ./CLAUDE.md.
- Create
./rules/.
- Copy shared rules:
${CLAUDE_PLUGIN_ROOT}/rules/<LANG>/*.md to ./rules/.
- Copy project stubs:
${CLAUDE_PLUGIN_ROOT}/templates/<LANG>/stubs-repo-rules/*.md to ./rules/ (without overwriting shared files).
- Run
python3 ${CLAUDE_PLUGIN_ROOT}/lib/ctx-lint.py <repo> — verify all @-imports resolve (0 errors).
- Show the user what was created, and ask them to fill in the
rules/stack.md, rules/testing.md, rules/boundaries.md, rules/focus.md files.
- Do not commit automatically — user reviews and commits themselves.
Example invocation
User: /ctx-init
Agent: "Ready to initialize context. Answer 3 questions:
1. project name (MYAPP/API/DOCS/...)?
2. description (short project topic)?
3. language for rules and AGENTS.md headers (en/ru, default en)?"
After answers — executes steps 1–7 and shows the diff.
1---2name: ctx-init3description: Initialize AGENTS.md + CLAUDE.md + rules/ in a code repo (fresh mode). Triggers on "/ctx-init", "init context", "scaffold AGENTS.md", or when user asks to set up project context in a new repo.4---56# ctx-init — context initialization in a repo78Creates the `ctx` structure in the current repo:9- `AGENTS.md` from template with frontmatter (all `@`-imports are relative `@./rules/...`)10- `CLAUDE.md` with `@AGENTS.md` import11- `rules/` with copies of shared plugin rules (`language`, `dates`, `git`, `no-secrets`, `no-public-names`) **plus** project-specific stubs (`stack`, `testing`, `boundaries`, `focus`)1213Both shared rules and templates exist in two language variants: `en/` (English) and `ru/` (Russian). The user picks one at init time. Shared rules are copied rather than imported via `${CLAUDE_PLUGIN_ROOT}` because Claude Code **does not expand** env variables in project-level `@`-imports (and this is needed for cross-agent compatibility: Codex/Gemini/Cursor all read the same `AGENTS.md`).1415## Input (ask the user before running)16171. **project** — short name (e.g. `MYAPP`, `API`, `DOCS`).182. **description** — one line describing the project topic.193. **language** — `en` or `ru` (default `en`). Determines the language of `AGENTS.md` headers, the 5 shared rule files (`language`, `dates`, `git`, `no-secrets`, `no-public-names`), and the 4 project stubs (`stack`, `testing`, `boundaries`, `focus`).2021## Procedure2223**Pre-flight checks:**241. `pwd` must be the root of the repo being initialized.252. If `AGENTS.md` already exists — **stop and tell the user** that migration is not supported. Ask the user to rename the old file manually (`mv AGENTS.md AGENTS.md.legacy`) and call `ctx-init` again.2627**Actions** (replace `<LANG>` with the chosen `en` or `ru`):281. Copy `${CLAUDE_PLUGIN_ROOT}/templates/<LANG>/AGENTS.md.template` to `./AGENTS.md`.292. Substitute `{{PROJECT}}`, `{{DESCRIPTION}}` via `sed`.303. Copy `${CLAUDE_PLUGIN_ROOT}/templates/<LANG>/CLAUDE.md.template` to `./CLAUDE.md`.314. Create `./rules/`.325. Copy **shared rules**: `${CLAUDE_PLUGIN_ROOT}/rules/<LANG>/*.md` to `./rules/`.336. Copy **project stubs**: `${CLAUDE_PLUGIN_ROOT}/templates/<LANG>/stubs-repo-rules/*.md` to `./rules/` (without overwriting shared files).347. Run `python3 ${CLAUDE_PLUGIN_ROOT}/lib/ctx-lint.py <repo>` — verify all `@`-imports resolve (0 errors).358. Show the user what was created, and ask them to fill in the `rules/stack.md`, `rules/testing.md`, `rules/boundaries.md`, `rules/focus.md` files.369. Do not commit automatically — user reviews and commits themselves.3738## Example invocation3940```41User: /ctx-init42Agent: "Ready to initialize context. Answer 3 questions:43 1. project name (MYAPP/API/DOCS/...)?44 2. description (short project topic)?45 3. language for rules and AGENTS.md headers (en/ru, default en)?"46```4748After answers — executes steps 1–7 and shows the diff.