[Code Quality] Use when a workflow step or the user asks for AI code or plan review: LLM calls, prompts, agents, RAG, evals and guardrails. --mode={code|plan}; --report-only is read-only.
日本語の概要は準備中です。原文の説明を表示しています。
[Documentation] Use when generating, smart-merging or refactoring the root AI context (CLAUDE.md, AGENTS.md) and its Claude/Codex projections. Config file only: project-config.
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Goal: Refresh the portable project AI-context lifecycle — generate or update the Claude root context from project-config.json + template, preserve project instructions through smart merge/refactor, and refresh Codex projections.
Summary:
init, update, markerless smart-merge, or AI-only refactor mode.--skip=claude-md; verify every Codex mirror and report failures.Workflow:
--mode init), update (--mode update), refactor (--mode refactor)node .claude/skills/ai-context-refresh/scripts/generate-claude-md.cjs --mode <mode>--skip=claude-md so AGENTS.md, .agents/, and .codex/ are regenerated from the finished CLAUDE.md.Key Rules:
docs/project-config.json<!-- SECTION:key -->) enable incremental updates without overwriting user content/sync-codex owns Codex mirror generation; this skill owns the root AI-context lifecycle and calls the same runner only after its explicit init/update/refactor work is completeThis skill is the AI-runnable route the agent-files bootstrap gate offers when a portable
.claude install lands in a project without a root CLAUDE.md. A single hook detects the gap
and routes here (shared detection lib: .claude/hooks/lib/agent-files-state.cjs):
init-prompt-gate.cjs (UserPromptSubmit) — blocks the first prompt once project-config.json
is populated but CLAUDE.md / AGENTS.md is missing. This UserPromptSubmit gate is the sole
agent-files bootstrap router.Two-state detection per root file: missing → routes to --mode init (fresh from template);
present → no block. A root file with no SECTION:* markers is project-owned: nothing is generated
into it, and /ai-context-refresh --mode update runs an AI smart-merge that adds generated sections around the project's own text.
Run /ai-context-refresh (or the generator directly) to produce CLAUDE.md from
docs/project-config.json + template. The generated file holds project information only: the
tl;dr line, Doc Lookup, path-scoped rules, development commands and the skill-activation table. It
carries none of the framework's universal rules (workflow step advancement, task planning, evidence,
code hierarchy, lesson extraction, closing reminders) and no workflow-route pointer:
the universal hook delivers those protocols on the first prompt of a session and again after 150K
tokens of growth or a compaction. A host that runs no hook is unsupported.
Workflow routing is delivered only by hooks — workflow-route-inject for the gate and workflow-catalog-inject for the catalog (Claude, the mirrored Codex hooks, the OpenCode bridge) —
never written into tracked files. The hooks inject the route for each person's mode —
ask (default: the workflow question is asked only when the route is to start a catalog workflow; direct and custom-simple routes ask nothing), auto (the same question, recommending the full workflow first)
or off (only a short state notice; nothing starts without an explicit request). A team sets the default in tracked docs/project-config.json:
{ "portability": { "workflowRouteMode": "ask" } } // or "auto" | "off"; legacy { "workflowAutoDetect": false } reads as "off"
A person overrides it without touching shared files: ~/.claude/.ck.json (every project), .claude/.ck.local.json (this checkout; the
portable bundle's .claude/.gitignore excludes it) or env CK_WORKFLOW_ROUTE_MODE. Precedence, later wins: default ask → tracked team
value → ~/.claude/.ck.json → .claude/.ck.local.json → env. Missing, malformed and invalid layers fall through. The hook emits only on
UserPromptSubmit, never blocks a prompt, and records delivery per session and content hash (a mode change re-delivers). It re-injects
after compaction, a content change, or about 4.5 MB of transcript growth (the existing framework proxy for roughly 200k tokens); hosts
without a measurable transcript use a bounded age fallback. Explicitly named skills and workflows remain available in every mode.
The optional custom route protocol (portability.workflowRouteProtocol, team or developer-local)
is RUNTIME-ONLY: workflow-route-inject.cjs appends it at UserPromptSubmit, and it must NEVER be
stamped into tracked CLAUDE.md/AGENTS.md. A valid local value replaces the team
value. This skill ignores it entirely when generating tracked files.
Legacy roots — a root generated by an earlier version may still carry universal sections, managed
blocks (CK:CRITICAL-THINKING, CK:AI-MISTAKE-PREVENTION, CK:WORKFLOW-ROUTE-POINTER) or the
CK:UNIVERSAL-GUIDES sentinel. --mode update reports them as LEGACY_UNIVERSAL_CONTENT; run
--mode update --strip-legacy-universal (a backup is written first) to remove them while keeping
every SECTION:* block and all project-owned text. AGENTS.md and the other Codex surfaces are generated by the shared runner owned by
/sync-codex; this skill invokes that runner directly after its final source edit, rather than recursively invoking
the skill. A full /sync-codex invocation performs its own CLAUDE.md preflight before mirror generation.
Just-in-time path rules — when inlined contextGroups[].rules push the root past its byte budget, set
portability.inlinePathRules: false in docs/project-config.json (default true). SECTION:golden-rules then
names each rule-bearing group and points to the file-conventions hook, which injects the full rules when a
matching file is touched, and its --lookup CLI — the non-automatic carrier for shell reads
(the spec's BR-PFCI-13 exception). Compact form requires BOTH conventionInjection.enabled: true AND an available
conventions lib (.claude/hooks/lib/file-conventions.cjs), with every rule-bearing group deliverable (named,
unique) and ranked within the per-path class cap (conventionInjection.maxClassesPerEdit), and a worst-case digest (longest accepted path, the largest rule sets the cap admits) within conventionInjection.maxChars; otherwise the rules stay inline and the generator prints [WARN] INLINE_PATH_RULES naming the missing
precondition. Never hand-compact that section instead — --mode update regenerates it.
With conventionInjection.completeLookup: true, a library advertising complete lookup support can
replace the legacy rank/size proof. The mandatory pre-action CLI returns every matching read/edit class
in pages (including overflow); read all pages with --page N before file or shell access. Named/unique
groups and enabled delivery remain required; older libraries retain inline fallback. Automatic hook
digests stay bounded. This mode also replaces the generated path pre-read table with the lookup pointer.
ai-context-refresh and sync-codex remain separate user-facing skills with one executable pipeline:
ai-context-refresh owns root-context authoring and the AI smart-merge/refactor decision. After init/update/refactor and the
final AI fill, it runs node .claude/skills/sync-codex/scripts/run-codex-sync.mjs --skip=claude-md.sync-codex owns generated outputs and verification. Its full run starts with a claude-md preflight: missing
CLAUDE.md is initialized and marker-managed content is updated./ai-context-refresh --mode update to smart-merge generated sections around the project instructions, then rerun sync./sync-codex skill call, so there is no recursion or duplicate
source generation. If the runner fails, report the failing stage and do not claim that Codex mirrors are current.| Mode | When | Behavior |
|---|---|---|
init | No CLAUDE.md exists, or first-time setup | Generate fresh CLAUDE.md from template + config. Populates all markers. |
update | CLAUDE.md exists with markers | Replace only content between markers. Preserve everything else. |
refactor | CLAUDE.md exists, needs optimization | AI reads entire CLAUDE.md, optimizes for token efficiency, removes redundancy, improves structure. No script — pure AI. |
docs/project-config.json — primary data source (run /project-config first if missing)# Check CLAUDE.md state
node .claude/skills/ai-context-refresh/scripts/generate-claude-md.cjs --detect
Decision logic:
initupdatesmart-merge (see below)--mode flag → override detection# Init mode: generate fresh CLAUDE.md
node .claude/skills/ai-context-refresh/scripts/generate-claude-md.cjs --mode init
# Update mode: sync marked sections only
node .claude/skills/ai-context-refresh/scripts/generate-claude-md.cjs --mode update
# Update mode that also removes the universal sections and managed blocks an earlier version wrote
node .claude/skills/ai-context-refresh/scripts/generate-claude-md.cjs --mode update --strip-legacy-universal
Script behavior:
docs/project-config.jsonreferences/claude-md-template.md) for init, or existing CLAUDE.md for updateCLAUDE.md (creates backup .claude-md.backup first)When running update on an existing CLAUDE.md that has NO section markers:
## heading text against known section keys (see references/section-registry.md)After the script generates the mechanical parts, AI reviews and fills:
.claude/skills/shared/protocols/context-engineering-principles.md before the final root edit is accepted and mirrors are synced; fix generated-section findings at their source.{project-name}, TODO).claude/skills/ai-context-refresh/ implementation paths leak into generated project context (self-reference)SECTION:* block is fixed in its builder, the template or docs/project-config.json, then regenerated — never hand-edited; hand-owned prose that changed ran /prompt-enhanceWriting/updating CLAUDE.md makes the generated mirror surfaces stale — AGENTS.md (Codex), the
.codex/ mirrors, and other downstream surfaces are derived FROM CLAUDE.md. They must be regenerated
only after the final AI fill/refactor and verification, otherwise the mirrors can capture an intermediate
source state.
MUST add a final todo task — "Sync Codex mirrors from updated CLAUDE.md" — after init/update/refactor and verification complete. When CLAUDE.md content changed, execute the shared standalone runner directly:
TaskCreate: "Sync Codex mirrors from updated CLAUDE.md → invoke /sync-codex"
node .claude/skills/sync-codex/scripts/run-codex-sync.mjs --skip=claude-md
--skip=claude-md is intentional: this skill has just completed the root-source lifecycle, so the
runner must start at mirror generation and still execute every configured verification stage. The
direct node call is the authorized completion handoff of an explicit /ai-context-refresh request; it is
not an autonomous invocation of the user-facing /sync-codex skill. Skip the task only when no
CLAUDE.md content actually changed. If the runner fails, keep this task incomplete and report the
failing stage and exact recovery command.
When --mode refactor or user asks to optimize CLAUDE.md:
<!-- SECTION:tldr -->
Auto-generated content here...
<!-- /SECTION:tldr -->
Rules:
/learn writes short, broad, project-specific rules and context into the ## Project Rules & Context section, outside every marker fence — it survives update, and the Codex projection carries that heading into AGENTS.md. Keep that section intact in refactor and smart-merge (condense its entries, never delete them); a project note inside a fence is overwritten by the next updateSee references/section-registry.md for full mapping. Summary:
| Key | Source | Conditional? |
|---|---|---|
tldr | project.*, modules[], framework.* | No — always generated |
golden-rules | contextGroups[] project path/document map only | Yes — skip if no project docs |
decision-quick-ref | modules[], framework.* | Yes — skip if no modules |
key-locations | modules[].pathRegex | Yes — skip if no modules |
dev-commands | testing.commands, infrastructure.* | Yes — skip if no commands |
infra-ports | modules[].meta.port (infra) | Yes — skip if no ports |
api-ports | modules[].meta.port (services) | Yes — skip if no ports |
integration-testing | framework.integrationTestDoc | Yes — skip if no doc; doc declared N/A in referenceDocs → one-line skip notice |
e2e-testing | framework.e2eTestDoc / e2eTesting.guideDoc, testing.frameworks[], e2eTesting.framework, or e2eTesting.execution | Yes — skip only when no guide doc AND no E2E evidence/profile; guide declared N/A with no evidence → one-line skip notice |
doc-index | Scan docs/ directory | Yes — skip if no docs/ |
doc-lookup | modules[], spec rows, referenceDocs[] (N/A via notApplicable: true or an N/A purpose → named once as a skip), docs index, lessons.md, ADRs — project docs that exist; excludes framework navigation | No — always generated; heading ## Doc Lookup — What to Read When, back-filled onto older roots on --mode update, projected first into AGENTS.md |
Generator + bootstrap-gate coverage lives in the hooks test suite:
node .claude/hooks/tests/run-all-tests.cjs --filter=agent-files
<!-- PROTOCOL-GUIDES:START -->[IMPORTANT] Use
TaskCreateto break ALL work into small tasks BEFORE starting. This prevents context loss from long files. Keep task depth proportional to the work.
Protocol guides — Apply each protocol only when its read-when condition holds. If a protocol's text is not in your context, read its file below before you act on it.
context-engineering-principles — Prompt clarity and semantic retention principles; writing or enhancing prompts, skills or agents → .claude/skills/shared/protocols/context-engineering-principles.mdoutput-quality-principles — Readable guidance and verified contents for long skill/doc files; writing, updating or auditing a skill or reference document, or another Markdown artifact over 200 lines → .claude/skills/shared/protocols/output-quality-principles.mdIMPORTANT MUST ATTENTION lead with useful guidance and readable priorities; preserve action-changing conditions/numbers and required structures. When writing, updating or auditing Markdown skill/doc content, verify top, heading-linked contents over 200 lines (stricter owner thresholds remain); refresh after edits and report gaps in read-only audits. Remove report bulk; judge semantic value rather than word counts.
<!-- /SYNC:output-quality-principles:reminder -->IMPORTANT MUST ATTENTION Goal: Refresh the portable project AI-context lifecycle — generate or update the Claude root context from project-config.json + template, preserve project instructions through smart merge/refactor, and refresh Codex projections.
Protocols in force (concise digest of the SYNC/shared blocks this skill carries): MUST ATTENTION honor every protocol below.
IMPORTANT MUST ATTENTION break work into small todo tasks using TaskCreate BEFORE starting
IMPORTANT MUST ATTENTION search codebase for 3+ similar patterns before creating new code
IMPORTANT MUST ATTENTION cite file:line evidence for every claim (confidence >80% to act)
IMPORTANT MUST ATTENTION add a final review todo task to verify work quality
| Evasion | Rebuttal |
|---|---|
| "It is only a rename" | Trace canonical sources, generated mirrors, catalogs, routes, and tests. |
| "The mirrors are already current" | Run the sync and divergence gates; stale derived output is not completion. |
| "Hand-fix the Codex copy" | Edit .claude/** sources, then regenerate .agents/, .codex/, and AGENTS.md. |
[TASK-PLANNING] Before acting, analyze task scope and systematically break it into small todo tasks and sub-tasks using TaskCreate.
まだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
[Code Quality] Use when a workflow step or the user asks for AI code or plan review: LLM calls, prompts, agents, RAG, evals and guardrails. --mode={code|plan}; --report-only is read-only.
日本語の概要は準備中です。原文の説明を表示しています。
[Architecture] Use when a workflow step or the user asks for architecture design, compliance review, scalability grading or whole-project audit via --mode={design|review|scalability|full}.
日本語の概要は準備中です。原文の説明を表示しています。
[Content] Use when a workflow step or the user asks for product/feature ideation with ranked opportunities and validation tests. --mode={roadmap|scope}.
日本語の概要は準備中です。原文の説明を表示しています。
[Content] Use when a workflow step or the user asks for business viability: Business Model Canvas, financials, risks and go-to-market recommendation.
日本語の概要は準備中です。原文の説明を表示しています。
[Code Quality] Use when a workflow step or the user asks for a focused code-change review: staged, unstaged, branch diff or simple pull request. --fix-loop fixes and re-reviews. Complex pull request: workflow-review-changes; rationale: why-review.
日本語の概要は準備中です。原文の説明を表示しています。
[Code Quality] Use when evaluating received review feedback, reviewing named code on request, or verifying a completion claim. Current diffs: changes-review; rationale: why-review.
日本語の概要は準備中です。原文の説明を表示しています。