Codex compatibility note:
- Invoke repository skills with
$skill-namein Codex; this mirrored copy rewrites legacy Claude/skill-namereferences.- Task tracker mandate: BEFORE executing any workflow or skill step, create/update task tracking for all steps and keep it synchronized as progress changes.
- User-question prompts mean to ask the user directly in Codex.
- Ignore Claude-specific mode-switch instructions when they appear.
- Strict execution contract: when a user explicitly invokes a skill, execute that skill protocol as written.
- Subagent authorization: when a skill is user-invoked or AI-detected and its protocol requires subagents, that skill activation authorizes use of the required
spawn_agentsubagent(s) for that task.- Do not skip, reorder, or merge protocol steps unless the user explicitly approves the deviation first.
- For workflow skills, execute each listed child-skill step explicitly and report step-by-step evidence.
- If a required step/tool cannot run in this environment, stop and ask the user before adapting.
Codex Project-Reference Loading (No Hooks)
Codex does not receive Claude hook-based doc injection. When coding, planning, debugging, testing, or reviewing, open project docs explicitly using this routing.
Always read:
docs/project-config.json(project-specific paths, commands, modules, and workflow/test settings)docs/project-reference/docs-index-reference.md(routes to the fulldocs/project-reference/*catalog)docs/project-reference/lessons.md(always-on guardrails and anti-patterns)
Situation-based docs:
- Backend/CQRS/API/domain/entity changes:
backend-patterns-reference.md,domain-entities-reference.md,project-structure-reference.md - Frontend/UI/styling/design-system:
frontend-patterns-reference.md,scss-styling-guide.md,design-system/README.md - Spec/test-case planning or TC mapping:
feature-docs-reference.md - Integration test implementation/review:
integration-test-reference.md - E2E test implementation/review:
e2e-test-reference.md - Code review/audit work:
code-review-rules.mdplus domain docs above based on changed files
Do not read all docs blindly. Start from docs-index-reference.md, then open only relevant files for the task.
Quick Summary
Goal: Two-phase restoration of any caveman-compressed markdown file: (1) Language Expansion — reconstruct fluent, grammatically correct English from compressed text while preserving ALL semantic content; (2) Prompt Enhancement — apply AI attention anchoring so AI reads and follows all instructions.
Workflow:
- Read — Read the target file completely
- Expand — Apply language expansion pass (Phase 1)
- Enhance — Apply prompt enhancement transforms (Phase 2)
- Verify — No semantic loss, correct structure, rule density ≥ pre-expansion
Key Rules:
- Expand FIRST, enhance SECOND — expansion restores readability; enhancement then structures it for AI attention
- Preserve ALL facts, constraints, logical steps, numbers, and technical terms exactly — never invent or omit content
- Post-expansion rule density (MUST ATTENTION/NEVER/ALWAYS per 100 lines) must be ≥ pre-expansion
- Language expansion applies to prose only — never modify code blocks, YAML, structured tables, or SYNC tags
- Expand for clarity and flow, not verbosity — natural English, not padded English
Target File
Expand and enhance this file: $ARGUMENTS
If no file specified, ask via a direct user question. If raw caveman text is passed instead of a file path, apply language expansion directly and output the result.
Phase 1: Language Expansion
Convert caveman-compressed text back into proper, fluent English. The source text uses very short sentences, no connectives, active voice, concrete language, and minimal articles.
Expansion Rules
What to Add
| Category | Examples | Guidance |
|---|---|---|
| Articles | a, an, the | Add where natural; default to the for specific things, a/an for general |
| Connectives | because, therefore, however, additionally, which means, in order to | Use to show logical relationships between sentences |
| Auxiliary verbs | is, are, was, were, have, has, does | Restore where grammatically required |
| Prepositions | of, for, to, in, on, at | Add back when they clarify relationships |
| Pronouns | it, this, that, they | Restore when referencing a previously mentioned noun |
| Subordinate clauses | "which allows...", "so that...", "when..." | Use to merge short choppy sentences into natural flow |
What to Preserve Exactly
| Category | Why |
|---|---|
| All nouns and noun phrases | Core semantic units — never paraphrase |
| All main verbs | Actions must remain unchanged |
| All adjectives | Meaning-bearing; do not substitute synonyms |
| Numbers and quantifiers | at least 20, approximately 15%, more than 3 — exact values matter |
| Uncertainty qualifiers | appears to be, seems, might — these are intentional hedges |
| Negations | not, no, never, without — critical for correctness |
| Technical and domain terms | Never simplify or paraphrase domain language |
file:line references and paths |
Exact paths must be preserved verbatim |
| Names and titles | Dr., Senator, proper nouns — unchanged |
| Time and frequency words | every Tuesday, weekly, always, never |
Connective Selection Guide
Use connectives that accurately reflect the logical relationship — do not add connectives arbitrarily.
| Relationship | Connectives to use |
|---|---|
| Cause → Effect | because, since, which causes, leading to, as a result |
| Contrast | however, but, although, despite, on the other hand |
| Addition | additionally, furthermore, also, in addition, and |
| Sequence | first, then, next, finally, after, before |
| Purpose | in order to, so that, to enable, to ensure |
| Condition | if, when, unless, provided that, given that |
| Clarification | specifically, that is, in other words, which means |
Sentence Expansion Process
For each compressed sentence or bullet:
- Identify the core subject-verb-object — this is non-negotiable content
- Restore articles — add
thefor specific referents,a/anfor general - Restore auxiliary verbs —
was designed,is required,has been removed - Add connectives — merge related short sentences into one fluent sentence where natural
- Restore prepositions — add
of,for,towhere they clarify relationships - Check length — target 10-25 words per sentence for readability
Expansion Examples
| Compressed | Expanded | Notes |
|---|---|---|
| "System designed process data efficiently." | "The system was designed to process data efficiently." | Added: the, was, to |
| "Removes predictable grammar preserving unpredictable content." | "It removes predictable grammar while preserving the unpredictable content." | Added: It, while, the |
| "At least 20 people." | "There were at least 20 people." | Restored existential construction; kept quantifier exact |
| "Made from wood and metal." | "It is made from wood and metal." | Added: It, is; kept from (relationship preposition) |
| "Method compressing LLM contexts." | "This is a semantic compression method for LLM contexts." | Fully restored noun phrase |
| "Confidence >80% act." | "When confidence exceeds 80%, proceed to act." | Restored conditional structure |
Expansion Scope
Apply expansion to:
- Prose paragraphs and explanatory text
- Bullet point descriptions
- Rule statements (restore full imperative sentences)
- Section introductions and transitions
Do NOT modify:
- Code blocks (any language)
- YAML frontmatter
- Structured tables (expand cell values only if they are prose fragments)
<!-- SYNC -->tags and their contentsfile:linereferences and paths- Frontmatter fields
Phase 2: Prompt Enhancement
Applies after expansion. Source: Anthropic prompt engineering guide, Stanford "lost-in-the-middle" research, 2025-2026 LLM context optimization studies.
Transform 4: Structural Clarity Pass
After expansion, apply structural improvements:
Convert to structured format:
- Prose paragraphs listing rules → bullet lists
- Enumerated conditions → decision tables
- Before/after examples → two-column tables
Keep as prose:
- Explanatory context (why a rule exists)
- Narrative descriptions of workflows
- Anti-pattern stories and rationale
Process
Step 1: Read and Analyze
- Read the target file completely
- Record: current line count, rule density (MUST ATTENTION/NEVER/ALWAYS count per 100 lines)
- Identify compressed prose regions — very short sentences, missing articles, no connectives
- List all READ references → classify as
.claude/(needs inline summary) ordocs/(skip) - Note: missing Quick Summary, missing Closing Reminders, tables needing cell expansion
Step 2: Language Expansion Pass
- Work through each prose section sequentially
- For each compressed sentence or bullet: restore articles, auxiliary verbs, connectives, prepositions
- Merge short choppy sentences into natural flowing sentences where logical relationship is clear
- Skip code blocks, YAML, SYNC tags, and file paths entirely
- After each paragraph, verify that all original facts and constraints are still present
Step 3: Create Inline Summaries
For each .claude/ protocol reference:
- Read the referenced file
- Extract 2-3 key rules
- Write the blockquote inline summary
- Keep the MUST ATTENTION READ instruction on the next line
Step 4: Add/Fix Top Section
- If Quick Summary is missing → create one from the file's content
- If present but weak → strengthen with Goal, Workflow, Key Rules structure
- Ensure protocol summaries appear before the Quick Summary block
Step 5: Add/Fix Bottom Section
- If Closing Reminders are missing → add the standard section
- Choose rules that AI most commonly skips (evidence-based, task creation, pattern search)
- Remove old "IMPORTANT Task Planning Notes" sections if superseded by Closing Reminders
Step 6: Verify
| Check | Pass Condition |
|---|---|
| No YAML corruption | Frontmatter intact and parseable |
| No semantic loss | All original facts, constraints, numbers, paths present |
| Rule density | Post-expansion ≥ pre-expansion (count MUST ATTENTION/NEVER/ALWAYS) |
| Fluency | No remaining 2-5 word telegraphic sentences in prose regions |
| Formatting | Blank lines between sections, headers correct |
| READ classification | .claude/ → inline summary added, docs/ → skipped |
| Code blocks untouched | No changes inside ``` fences |
[IMPORTANT] Use task tracking to break ALL work into small tasks BEFORE starting.
Output Quality — Token efficiency without sacrificing quality.
- No inventories/counts — AI can
grep | wc -l. Counts go stale instantly- No directory trees — AI can
glob/ls. Use 1-line path conventions- No TOCs — AI reads linearly. TOC wastes tokens
- No examples that repeat what rules say — one example only if non-obvious
- Lead with answer, not reasoning. Skip filler words and preamble
- Sacrifice grammar for concision in reports
- Unresolved questions at end, if any
Context Engineering Principles — Research-backed principles for prompt quality. Source: Anthropic prompt engineering guide, Stanford "lost-in-the-middle" research, 2025-2026 LLM context optimization studies.
- Primacy-Recency Effect — LLM performance drops 15-47% for middle-context information (Stanford). AI attention peaks at first/last 10% of text. Action: Place the 3 most critical rules in both the first 5 lines AND the last 5 lines of every prompt. Queries at end improve quality by up to 30% (Anthropic).
- High-Signal Density — Anthropic: "Identify the smallest collection of high-signal tokens that maximize the probability of the desired outcome." Action: Every line should change AI behavior. If removing a line doesn't change output → cut it. Target ≥8 rules (MUST ATTENTION/NEVER/ALWAYS) per 100 lines.
- Context Rot — LLM performance degrades as context length grows — even when all content is relevant. Compression (5-20x) maintains or improves accuracy while saving 70-94% tokens. Action: Compress aggressively. Shorter, denser prompts outperform longer, diluted ones.
- Structured > Prose — Tables, bullets, XML/markdown parse faster than paragraphs. Constrained formats reduce error rates vs free-text. Action: Convert narrative to tables/bullets. Use markdown headers for semantic sections.
- RCCF Framework — Modern LLMs (2025+) already know how to reason. What they need: Role (personality), Context (grounding), Constraints (guardrails), Format (structure). Constraints and format matter more than verbose instructions.
- Checkbox Avoidance —
[ ]syntax triggers mechanical compliance — AI ticks boxes without reasoning. Bullet rules force reading and evaluation. Action: Replace- [ ] Check Xwith- MUST ATTENTION verify X.- Example Economy — 3-5 examples optimal for few-shot; diminishing returns after. Action: 1 best example per pattern. Use BAD→GOOD pairs (2-3 lines each) for anti-patterns.
- Deferred Tool Loading — Claude Code delays loading tool definitions when they exceed 10% of context window. Action: Keep injected docs well under 10% of context budget. Docs exceeding ~3,000 lines are too large for injection — split or compress.
- Rule Density Verification — Post-optimization rule count (MUST ATTENTION/NEVER/ALWAYS) must be ≥ pre-optimization count. Compression should preserve or increase density, never decrease it. Action: Count before and after every optimization pass.
- Affirmative Directives — Models comply with affirmative directives more reliably than prohibitions; a bare "don't X" leaves the correct action unspecified, so the model substitutes an arbitrary alternative. Action: State the action to take, not only the action to avoid. Keep
NEVER/forbidden guardrails for hard invariants — but pair each with the right path ("Do X" not just "Don't do Y").- Rationale-Carrying Instructions — A rule shipped with its reason generalizes to edge cases the rule never enumerated and survives compression; a bare imperative gets misapplied or silently dropped. Action: Append a terse
— why: …clause to every non-obvious rule. The reason names the failure prevented or outcome wanted — never restates the rule.
Prompt Enhancement Transforms (Base) — Transforms 1-3 are identical across
prompt-enhance/prompt-expand. Transform 4 is per-skill (conciseness pass for enhance; structural clarity pass for expand) and stays local to each skill.Transform 1: Inline Summaries for READ References
Problem: AI sees
MUST ATTENTION READ file.mdand skips it. Solution: Add a 2-3 line summary of key rules BEFORE the read instruction.Before:
MUST ATTENTION READ .claude/protocols/evidence.mdAfter:
> **Evidence-Based Reasoning** — Speculation is FORBIDDEN. Every claim requires `file:line` proof. > Confidence: >95% recommend freely, 80-94% with caveats, <80% DO NOT recommend. MUST ATTENTION READ .claude/protocols/evidence.md for full details.Scope rules:
.claude/protocol files → always add an inline summary (stable, belongs to framework)docs/project-reference/files → NO inline summary (project-specific). Add:(read directly when relevant; do not rely on hook-injected conversation text)Transform 2: Top Summary Section
Required structure (first 20 lines after frontmatter):
> **[IMPORTANT]** task tracking instruction... > **Protocol Name** — [inline summary]. MUST ATTENTION READ `path` for details. ## Quick Summary **Goal:** [One sentence — what this skill achieves] **Workflow:** 1. **[Step]** — [description] **Key Rules:** - [Most critical constraint]Transform 3: Bottom Closing Reminders
Add at the very end of the file:
--- ## Closing Reminders **IMPORTANT MUST ATTENTION** [echo rule #1 from the top section] **IMPORTANT MUST ATTENTION** [echo rule #2] **IMPORTANT MUST ATTENTION** [echo rule #3] **IMPORTANT MUST ATTENTION** add a final review task to verify work qualityPick 3-5 rules AI most commonly violates. Bottom section re-anchors attention after the long middle.
Shared Protocol Duplication Policy — Inline protocol content in skills (wrapped in
<!-- SYNC:tag -->) is INTENTIONAL duplication. Do NOT extract, deduplicate, or replace with file references. AI compliance drops significantly when protocols are behind file-read indirection. To update: edit.claude/skills/shared/sync-inline-versions.mdfirst, then grepSYNC:protocol-nameand update all occurrences.
AI Mistake Prevention — Failure modes to avoid on every task: Check downstream references before deleting. Deleting components causes documentation and code staleness cascades. Map all referencing files before removal. Verify AI-generated content against actual code. AI hallucinates APIs, class names, and method signatures. Always grep to confirm existence before documenting or referencing. Trace full dependency chain after edits. Changing a definition misses downstream variables and consumers derived from it. Always trace the full chain. Trace ALL code paths when verifying correctness. Confirming code exists is not confirming it executes. Always trace early exits, error branches, and conditional skips — not just happy path. When debugging, ask "whose responsibility?" before fixing. Trace whether bug is in caller (wrong data) or callee (wrong handling). Fix at responsible layer — never patch symptom site. Assume existing values are intentional — ask WHY before changing. Before changing any constant, limit, flag, or pattern: read comments, check git blame, examine surrounding code. Verify ALL affected outputs, not just the first. Changes touching multiple stacks require verifying EVERY output. One green check is not all green checks. Holistic-first debugging — resist nearest-attention trap. When investigating any failure, list EVERY precondition first (config, env vars, DB names, endpoints, DI registrations, data preconditions), then verify each against evidence before forming any code-layer hypothesis. Surgical changes — apply the diff test. Bug fix: every changed line must trace directly to the bug. Don't restyle or improve adjacent code. Enhancement task: implement improvements AND announce them explicitly. Surface ambiguity before coding — don't pick silently. If request has multiple interpretations, present each with effort estimate and ask. Never assume all-records, file-based, or more complex path.
Critical Thinking Mindset — Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act. Anti-hallucination: Never present guess as fact — cite sources for every claim, admit uncertainty freely, self-check output for errors, cross-reference independently, stay skeptical of own confidence — certainty without evidence root of all hallucination.
MUST ATTENTION apply critical thinking — every claim needs traced proof, confidence >80% to act. Anti-hallucination: never present guess as fact.
MUST ATTENTION apply AI mistake prevention — holistic-first debugging, fix at responsible layer, surface ambiguity before coding, re-read files after compaction.
Closing Reminders
IMPORTANT MUST ATTENTION apply language expansion FIRST before any structural enhancement — never skip Phase 1
IMPORTANT MUST ATTENTION preserve ALL facts, numbers, technical terms, and file:line references exactly — never invent or paraphrase content
IMPORTANT MUST ATTENTION never modify code blocks, YAML frontmatter, structured tables, or SYNC tags during expansion
IMPORTANT MUST ATTENTION verify rule density post-expansion ≥ pre-expansion — expansion must not dilute signal below the original
IMPORTANT MUST ATTENTION state the action to take, not only what to avoid — pair every NEVER with the right path, and append a terse — why: to each non-obvious rule — why: affirmative directives + carried rationale are followed more reliably and survive compression (principles #10/#11)
IMPORTANT MUST ATTENTION apply primacy-recency anchoring — 3 critical rules in first 5 AND last 5 lines of every enhanced file
IMPORTANT MUST ATTENTION add inline summaries only for .claude/ protocol files, never for docs/ project-specific files
IMPORTANT MUST ATTENTION cite file:line evidence for every claim (confidence >80% to act). NEVER speculate without proof.
IMPORTANT MUST ATTENTION READ CLAUDE.md before starting
[TASK-PLANNING] Before acting, analyze task scope and systematically break it into small todo tasks and sub-tasks using task tracking.
Hookless Prompt Protocol Mirror (Auto-Synced)
Source: .claude/hooks/lib/prompt-injections.cjs + .claude/.ck.json
[WORKFLOW-EXECUTION-PROTOCOL] [BLOCKING] Workflow Execution Protocol — MANDATORY IMPORTANT MUST CRITICAL. Do not skip for any reason.
Generic portability boundary: Reusable skills and protocol text stay project-neutral; project-specific conventions are discovered from docs/project-config.json and docs/project-reference/. Apply shared AI-SDD from shared/sdd-artifact-contract.md. Read docs/project-config.json and docs/project-reference/docs-index-reference.md, then open the project reference docs named there. Any supported AI tool may execute when this shared context and local docs are available.
- DETECT: Match prompt against workflow catalog
- ANALYZE: Find best-match workflow AND evaluate if a custom step combination would fit better
- ASK (REQUIRED FORMAT): Use a direct user question with this structure unless the user explicitly invoked a workflow/skill and the local protocol treats explicit invocation as confirmation:
- Question: "Which workflow do you want to activate?"
- Option 1: "Activate [BestMatch Workflow] (Recommended)"
- Option 2: "Activate custom workflow: [step1 → step2 → ...]" (include one-line rationale)
- ACTIVATE (if confirmed): Call
$workflow-start <workflowId>for standard; sequence custom steps manually - CREATE TASKS: task tracking for ALL workflow steps
- EXECUTE: Follow each step in sequence [CRITICAL-THINKING-MINDSET] Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act. Anti-hallucination principle: Never present guess as fact — cite sources for every claim, admit uncertainty freely, self-check output for errors, cross-reference independently, stay skeptical of own confidence — certainty without evidence root of all hallucination. AI Attention principle (Primacy-Recency): Put the 3 most critical rules at both top and bottom of long prompts/protocols so instruction adherence survives long context windows. Goal-driven execution: Define success criteria first, loop until verified, and stop only when observable checks pass. Tests verify intent: Tests must protect business rules/invariants and fail when the protected intent breaks, not only mirror current behavior.
[LESSON-LEARNED-REMINDER] [BLOCKING] Task Planning & Continuous Improvement — MANDATORY. Do not skip.
Break work into small tasks (task tracking) before starting. Add final task: "Analyze AI mistakes & lessons learned".
Extract lessons — ROOT CAUSE ONLY, not symptom fixes:
- Name the FAILURE MODE (reasoning/assumption failure), not symptom — "assumed API existed without reading source" not "used wrong enum value".
- Generality test: does this failure mode apply to ≥3 contexts/codebases? If not, abstract one level up.
- Write as a universal rule — strip project-specific names/paths/classes. Useful on any codebase.
- Consolidate: multiple mistakes sharing one failure mode → ONE lesson.
- Recurrence gate: "Would this recur in future session WITHOUT this reminder?" — No → skip
$learn. - Auto-fix gate: "Could
$code-review/$code-simplifier/$security/$lintcatch this?" — Yes → improve review skill instead. - BOTH gates pass → ask user to run
$learn. [TASK-PLANNING] [MANDATORY] BEFORE executing any workflow or skill step, create/update task tracking for all planned steps, then keep it synchronized as each step starts/completes.