Claude-code-skills ln-014-agent-instructions-manager
Creates AGENTS.md canonical and CLAUDE.md/GEMINI.md/ANTIGRAVITY.md @AGENTS.md stubs; audits token budget, cache safety, import-pattern compliance. Use when instruction files need alignment.
git clone https://github.com/levnikolaevich/claude-code-skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/levnikolaevich/claude-code-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills-catalog/ln-014-agent-instructions-manager" ~/.claude/skills/levnikolaevich-claude-code-skills-ln-014-agent-instructions-manager && rm -rf "$T"
skills-catalog/ln-014-agent-instructions-manager/SKILL.mdPaths: All file refs relative to skills repo root.
Agent Instructions Manager
Type: L3 Worker Category: 0XX Shared
Creates missing instruction files and audits all of them (AGENTS.md, CLAUDE.md, GEMINI.md, ANTIGRAVITY.md) for quality, consistency, and best practices. AGENTS.md is the single canonical source of content; CLAUDE.md, GEMINI.md, and ANTIGRAVITY.md are thin
@AGENTS.md import stubs with bounded harness-specific deltas. This skill is the single owner of instruction-file creation and MCP Tool Preferences insertion or replacement.
MANDATORY READ: Load
shared/references/coordinator_summary_contract.md, shared/references/environment_worker_runtime_contract.md, and shared/references/worker_runtime_contract.md
MANDATORY READ: Load shared/references/mcp_tool_preferences.md
MANDATORY READ: Load shared/references/agent_instructions_writing_guide.md — canonical rationale for the @AGENTS.md import pattern, size budgets, and anti-patterns. All audit checks below trace back to this guide.
Input / Output
| Direction | Content |
|---|---|
| Input | project context, flag, optional , optional |
| Output | Structured summary envelope with = / / , plus created files, audit findings, and warnings in / |
If
summaryArtifactPath is provided, write the same summary JSON there. If not provided, return the summary inline and remain fully standalone. If runId is not provided, generate a standalone run_id before emitting the summary envelope.
Runtime
Runtime family:
environment-worker-runtime
Phase profile:
PHASE_0_CONFIGPHASE_1_DISCOVER_FILESPHASE_2_CREATE_MISSING_FILESPHASE_3_TOKEN_BUDGET_AUDITPHASE_4_PROMPT_CACHE_SAFETYPHASE_5_CONTENT_QUALITYPHASE_6_IMPORT_PATTERN_COMPLIANCEPHASE_7_WRITE_SUMMARYPHASE_8_SELF_CHECK
Runtime rules:
- emit
summary_kind=env-instructions - standalone runs generate their own
and write the default worker-family artifact pathrun_id - managed runs require both
andrunId
and must write the summary to the exact provided pathsummaryArtifactPath - always write the validated summary artifact before terminal outcome
Output Contract
Always build a structured
env-instructions summary envelope per:
shared/references/coordinator_summary_contract.mdshared/references/environment_worker_runtime_contract.md
Payload fields:
files_foundfiles_createdquality_findingstoken_budgetprompt_cache_safetyimport_pattern_statusstatus
When to Use
- After editing any instruction file
- After adding/removing MCP servers or hooks
- Before release or publishing
- When sessions degrade (context bloat symptoms)
- First-time project setup (instruction files missing)
Phase 1: Discover Files
Locate instruction files in target project:
| Agent | Primary | Canonical source | Fallback |
|---|---|---|---|
| Claude Code | | imports via | |
| Codex / Cursor / Amp / Factory | | canonical | |
| Gemini CLI | | imports via | (shared with Codex) |
| Google Antigravity | | imports via | (shared with Codex/Gemini/Claude) |
Report: which files exist (
found / missing), which harnesses share AGENTS.md directly vs via import.
Phase 1b: Plugin Conflict Check
Skip condition: No
enabledPlugins in settings OR all plugins are @levnikolaevich-skills-marketplace.
- Read
→ parse~/.claude/settings.jsonenabledPlugins - Filter: enabled=true AND publisher ≠
levnikolaevich-skills-marketplace - For each external plugin:
- Resolve active install first: matching plugin or marketplace under
~/.claude/plugins/marketplaces/* - Read active
descriptions from that install surfaceskills-catalog/*/SKILL.md - Only if no active install is available, fall back to the latest cache snapshot under
~/.claude/plugins/cache/{publisher}/{plugin}/*/skills/*/SKILL.md - Treat cache as forensic fallback only. Never count multiple cache snapshots as separate active conflicts.
- Match against conflict signal keywords:
- Resolve active install first: matching plugin or marketplace under
| Signal | Keywords in description | Overlap with |
|---|---|---|
| Orchestration | "orchestrat", "pipeline", "end-to-end", "lifecycle" | ln-1000 pipeline |
| Planning | "plan.*implement", "brainstorm", "design.*spec" | ln-300 task coordinator |
| Execution | "execut.*plan", "subagent.*task", "task-by-task" | ln-400/ln-401 executors |
| Code review | "code.review.*dispatch", "review.*quality.*spec" | ln-402/ln-310 |
| Quality gate | "quality.*gate", "verification.*complet", "test-driven.*always" | ln-500 quality gate |
| Debugging | "systematic.*debug", "root.*cause.*phase" | problem_solving.md |
| Git isolation | "worktree.*creat", "git.*isolat" | git_worktree_fallback.md |
- Check for
directory in the active install surface firsthooks/session-start
- Score: 2+ signal categories → CONFLICT. 1 → WARN. 0 → safe
- CONFLICT:
→ AskUserQuestion → if yes, set to"CONFLICT: {plugin} overlaps with ln-* pipeline ({signals}). Disable?"
in settings.jsonfalse - WARN: report, continue
Phase 2: Create Missing Files
Skip condition: All files exist OR
dry_run == true (report what would be created).
Canonical model: AGENTS.md is the single source of content. CLAUDE.md, GEMINI.md, and ANTIGRAVITY.md are
@AGENTS.md import stubs with bounded harness-specific deltas. Create in this order so the stubs reference a file that already exists.
Step 2a: Detect Project Context
| Field | Source | Fallback |
|---|---|---|
| PROJECT_NAME | → | |
| PROJECT_DESCRIPTION | → | |
| DATE | current date (YYYY-MM-DD) | — |
| ENABLE_WORKFLOW_PRINCIPLES | Caller input (default ) | — |
Step 2b: Create AGENTS.md (if missing) — canonical
- MANDATORY READ: Load
skills-catalog/ln-111-root-docs-creator/references/templates/agents_md_template.md - Replace
,{{PROJECT_NAME}}
,{{PROJECT_DESCRIPTION}}
, and{{DATE}}
placeholders{{DEV_COMMANDS_*}} - If
: replaceENABLE_WORKFLOW_PRINCIPLES=true
with the full content of{{WORKFLOW_PRINCIPLES_BLOCK}}
. Otherwise strip the placeholder line and its leading HTML comment.skills-catalog/ln-111-root-docs-creator/references/templates/agents_md_workflow_principles.md - Mark remaining
as{{...}}[TBD: placeholder_name] - Write to target project root
Step 2c: Create CLAUDE.md (if missing) — import stub
- MANDATORY READ: Load
skills-catalog/ln-111-root-docs-creator/references/templates/claude_md_template.md - Replace
only{{PROJECT_NAME}} - Write to target project root
- Verify the file contains exactly one
line and is ≤50 lines total@AGENTS.md - Do NOT copy any content from AGENTS.md into CLAUDE.md — the
import handles it at session load time@
Step 2d: Create GEMINI.md (if missing) — import stub
- MANDATORY READ: Load
skills-catalog/ln-111-root-docs-creator/references/templates/gemini_md_template.md - Replace
only{{PROJECT_NAME}} - Write to target project root
- Verify the file contains exactly one
line and is ≤50 lines total@AGENTS.md - Do NOT copy any content from AGENTS.md into GEMINI.md — the
import handles it at session load time@
Step 2d2: Create ANTIGRAVITY.md (if missing) — import stub
- MANDATORY READ: Load
skills-catalog/ln-111-root-docs-creator/references/templates/antigravity_md_template.md - Replace
only{{PROJECT_NAME}} - Write to target project root
- Verify the file contains exactly one
line and is ≤50 lines total@AGENTS.md - Do NOT copy any content from AGENTS.md into ANTIGRAVITY.md — the
import handles it at session load time@
Step 2e: Report Creations
List each created file with its source (template
agents_md_template.md, template claude_md_template.md stub, template gemini_md_template.md stub, template antigravity_md_template.md stub).
Phase 3: Token Budget Audit
Line-count budgets align with the Anthropic official target (
<200 lines per CLAUDE.md file) and the IFScale instruction-ceiling research. See shared/references/agent_instructions_writing_guide.md for the full rationale.
| Check | Pass | Warn | Fail |
|---|---|---|---|
| AGENTS.md line count | ≤150 | 151-200 | >200 |
| CLAUDE.md line count (stub) | ≤20 | 21-50 | >50 |
| GEMINI.md line count (stub) | ≤20 | 21-50 | >50 |
| ANTIGRAVITY.md line count (stub) | ≤20 | 21-50 | >50 |
| User-added imperative count in AGENTS.md | ≤100 | 101-150 | >150 |
Imperative counter: lines matching
^\s*- inside rule sections, plus any line containing MUST\|NEVER\|ALWAYS\|DO NOT. Cite the IFScale benchmark (arxiv 2507.11538) in WARN / FAIL messages.
Report table per file with line count and imperative count (for AGENTS.md).
Phase 4: Prompt Cache Safety
Check each file for content that breaks prefix-based prompt caching:
| # | Check | Pattern | Severity |
|---|---|---|---|
| 1 | No timestamps | | WARN |
| 2 | No dates in content | `grep -E '(January | February |
| 3 | No dynamic counts | (hardcoded counts change) | WARN |
| 4 | No absolute paths | `grep -E '[A-Z]:\ | /home/ |
| 5 | Stable structure | No conditional sections () | INFO |
Phase 5: Content Quality
| # | Check | Pass | Fail |
|---|---|---|---|
| 1 | Has build/test commands | Found commands in AGENTS.md | Missing — add essential commands |
| 2 | No abstract principles | No , | Found vague instructions |
| 3 | No redundant docs | No API docs, no full architecture description | Found content discoverable from code |
| 4 | Has hard boundaries | Found rules in AGENTS.md | Missing explicit prohibitions |
| 5 | Compact Instructions section | present in AGENTS.md with preservation priorities | Missing — sessions lose decisions on /compact |
| 6 | MCP Tool Preferences | Canonical policy section in AGENTS.md matches | Missing or outdated — agents use suboptimal tools |
| 7 | No tool output examples | No large code blocks or command outputs | Found — bloats every turn |
Checks #1–#6 evaluate AGENTS.md only because CLAUDE.md / GEMINI.md / ANTIGRAVITY.md inherit that content via the
@AGENTS.md import. Checks on the deltas themselves live in Phase 6.
Phase 5b: Auto-fix Fixable Issues
For each FAIL in Phase 5, attempt auto-fix before reporting:
Before any auto-fix insertion:
- Verify insertion point exists (exact heading found at specific line)
- If ambiguous (heading not found) — WARN and skip (report as manual fix needed)
- After insertion — verify no duplicate
or## Compact Instructions
sections exist in the file## MCP Tool Preferences
| # | Issue | Fix | Skip when |
|---|---|---|---|
| 5 | Missing Compact Instructions | Insert section before in AGENTS.md | |
| 6 | Missing or outdated MCP Tool Preferences | Insert or replace section in AGENTS.md from | |
| 1 | Missing build/test commands | WARN only (project-specific, cannot auto-generate) | -- |
| 2 | Abstract principles found | WARN only (requires human judgment) | -- |
Compact Instructions template (insert in AGENTS.md before
## Navigation or after last rules section):
## Compact Instructions Preserve during /compact: [Critical Rules], [MCP Tool Preferences table], [Navigation table], [language/communication rules], [hard boundaries (NEVER/ALWAYS)]. Drop examples and explanations first.
Because CLAUDE.md, GEMINI.md, and ANTIGRAVITY.md
@AGENTS.md, the preservation list propagates to all of them. The harness-specific terminology (/compact vs context compression) lives in each stub's delta.
Phase 6: Import Pattern Compliance
AGENTS.md is the canonical source per
DOC_ROLE metadata. CLAUDE.md, GEMINI.md, and ANTIGRAVITY.md must be thin @AGENTS.md import stubs with bounded harness-specific deltas.
| # | Check | Pass | Fail |
|---|---|---|---|
| 1 | CLAUDE.md has import | Exactly one line present | Missing or multiple — FAIL |
| 2 | GEMINI.md has import | Exactly one line present | Missing or multiple — FAIL |
| 3 | CLAUDE.md delta bounded | Total file ≤50 lines | >50 lines — FAIL with drift report |
| 4 | GEMINI.md delta bounded | Total file ≤50 lines | >50 lines — FAIL with drift report |
| 5 | No content duplication | No section or rule from AGENTS.md reappears in CLAUDE.md / GEMINI.md | Duplicate found — FAIL, name the specific overlapping lines |
Drift resolution rule: AGENTS.md is the canonical source. For each inconsistency:
- (a) If content is missing from AGENTS.md but present in CLAUDE.md / GEMINI.md → move it to AGENTS.md, then remove from the stub.
- (b) If CLAUDE.md / GEMINI.md duplicate AGENTS.md content → replace with a single
import line.@AGENTS.md - (c) If the stub delta exceeds 50 lines → split genuinely harness-specific content into
(for Claude) or modular.claude/rules/*.md
(for Gemini); everything else moves to AGENTS.md.@imports
Do not "suggest which file is source of truth" based on content volume — AGENTS.md is always the source.
If
.hex-skills/environment_state.json reports agents.codex.discovery_violation=true, emit a WARN that Codex skill discovery is drifted and duplicate skill counts from stale cache must not be used as evidence during instruction audits until ln-013-config-syncer repairs the mapping.
If
.hex-skills/environment_state.json reports agents.codex.permissions_default_ready=false, emit a WARN that Codex CLI startup permissions are drifted from the managed default and instruction audits must not assume full-access startup semantics until ln-013-config-syncer repairs ~/.codex/config.toml.
Phase 7: Report
Agent Instructions Manager: Created: (omit section if nothing created) - AGENTS.md (from template, context from package.json) - CLAUDE.md (import stub) - GEMINI.md (import stub) Audit: | File | Lines | Imperatives | Cache-safe | Quality | Import pattern | Issues | |------------|-------|-------------|------------|---------|----------------|--------| | AGENTS.md | 118 | 47 | OK | 7/7 | n/a | OK | | CLAUDE.md | 13 | 0 | OK | 7/7 | OK | OK | | GEMINI.md | 12 | 0 | OK | 7/7 | OK | OK | Import pattern: OK (or N drift issues listed) Recommendations: 1. Run /init (ln-100) for full context-aware AGENTS.md with project-specific rules
Cross-agent note: Codex CLI 0.120 (2026-04-11) now supports
SessionStart hook with /clear vs fresh/resume distinction, matching Claude Code behavior.
Definition of Done
- All instruction files discovered
- Missing files created (AGENTS.md from template first; CLAUDE.md and GEMINI.md as
import stubs second)@AGENTS.md - Token budget within limits: AGENTS.md ≤200 lines, CLAUDE.md and GEMINI.md each ≤50 lines, AGENTS.md imperative count ≤150
- No prompt cache breakers found (or reported as WARN)
- Content quality checks passed on AGENTS.md (or issues reported)
- Auto-fixable issues resolved in AGENTS.md (Compact Instructions, MCP Tool Preferences) or reported if dry_run
- Import pattern compliance verified: CLAUDE.md and GEMINI.md each contain exactly one
line and no duplicated AGENTS.md content@AGENTS.md - Report generated with creation log, drift findings, and actionable recommendations
- No conflicting external plugins detected (or user confirmed keep)
- Structured summary returned
- Summary artifact written to the managed or standalone runtime path
Critical Rule: Non-destructive file edits. Auto-fix inserts sections at verified positions only. Never rewrite the entire instruction file. Preserve all existing content outside the inserted section.
Version: 2.2.0 Last Updated: 2026-03-25