Paths: All file refs relative to skills repo root.
Agent Instructions Manager
Type: L3 Worker Category: 0XX Shared
Creates missing instruction files and audits them (AGENTS.md, CLAUDE.md) for quality, consistency, and best practices. AGENTS.md is the single canonical source of content; CLAUDE.md is a thin @AGENTS.md import stub 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 references/coordinator_summary_contract.md, references/environment_worker_runtime_contract.md, and references/worker_runtime_contract.md
MANDATORY READ: Load references/mcp_tool_preferences.md
MANDATORY READ: Load 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, dry_run flag, optional runId, optional summaryArtifactPath |
| Output | Structured summary envelope with payload.status = completed / skipped / error, plus created files, audit findings, and warnings in changes / detail |
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
run_idand write the default worker-family artifact path - managed runs require both
runIdandsummaryArtifactPathand must write the summary to the exact provided path - always write the validated summary artifact before terminal outcome
Output Contract
Always build a structured env-instructions summary envelope per:
references/coordinator_summary_contract.mdreferences/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 | CLAUDE.md | imports AGENTS.md via @AGENTS.md | .claude/settings.local.json |
| Codex / Cursor / Amp / Factory | AGENTS.md | canonical | .codex/instructions.md |
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
~/.claude/settings.json→ parseenabledPlugins - 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
plugins/*/skills/*/SKILL.mddescriptions from that install surface - 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
hooks/session-startdirectory in the active install surface first
- Score: 2+ signal categories → CONFLICT. 1 → WARN. 0 → safe
- CONFLICT:
"CONFLICT: {plugin} overlaps with ln-* pipeline ({signals}). Disable?"→ AskUserQuestion → if yes, set tofalsein settings.json - 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 is an @AGENTS.md import stub with bounded harness-specific deltas. Create in this order so the stub references a file that already exists.
Step 2a: Detect Project Context
| Field | Source | Fallback |
|---|---|---|
| PROJECT_NAME | package.json → name | basename(cwd) |
| PROJECT_DESCRIPTION | package.json → description | [TBD: Project description] |
| DATE | current date (YYYY-MM-DD) | — |
| ENABLE_WORKFLOW_PRINCIPLES | Caller input (default false) | — |
Step 2b: Create AGENTS.md (if missing) — canonical
- MANDATORY READ: Load
plugins/documentation-pipeline/skills/ln-111-root-docs-creator/references/templates/agents_md_template.md - Replace
{{PROJECT_NAME}},{{PROJECT_DESCRIPTION}},{{DATE}}, and{{DEV_COMMANDS_*}}placeholders - If
ENABLE_WORKFLOW_PRINCIPLES=true: replace{{WORKFLOW_PRINCIPLES_BLOCK}}with the full content ofplugins/documentation-pipeline/skills/ln-111-root-docs-creator/references/templates/agents_md_workflow_principles.md. Otherwise strip the placeholder line and its leading HTML comment. - Mark remaining
{{...}}as[TBD: placeholder_name] - Write to target project root
Step 2c: Create CLAUDE.md (if missing) — import stub
- MANDATORY READ: Load
plugins/documentation-pipeline/skills/ln-111-root-docs-creator/references/templates/claude_md_template.md - Replace
{{PROJECT_NAME}}only - Write to target project root
- Verify the file contains exactly one
@AGENTS.mdline and is ≤50 lines total - Do NOT copy any content from AGENTS.md into CLAUDE.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).
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 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 |
| 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 |
|---|