Paths: All file refs relative to skills repo root.
Agent Instructions Manager
Type: L3 Worker
Category: 0XX Shared
Creates missing instruction files and audits all (CLAUDE.md, AGENTS.md, GEMINI.md) for quality, consistency, and best practices.
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 | Fallback |
|---|
| Claude | | .claude/settings.local.json
|
| Codex | | |
| Gemini | | (shared with Codex) |
Report: which files exist (
/
), which agents share files.
Phase 1b: Plugin Conflict Check
Skip condition: No
in settings OR all plugins are
@levnikolaevich-skills-marketplace
.
- Read → parse
- Filter: enabled=true AND publisher ≠
levnikolaevich-skills-marketplace
- For each external plugin:
- Locate cache:
~/.claude/plugins/cache/{publisher}/{plugin}/*/skills/*/SKILL.md
- Read each skill description (frontmatter field)
- Match against conflict signal keywords:
| 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 (competing SessionStart injection)
- Score: 2+ signal categories → CONFLICT. 1 → WARN. 0 → safe
- CONFLICT:
"CONFLICT: {plugin} overlaps with ln-* pipeline ({signals}). Disable?"
→ AskUserQuestion → if yes, set to in settings.json
- WARN: report, continue
Phase 2: Create Missing Files
Skip condition: All files exist OR
(report what would be created).
Step 2a: Detect Project Context
| Field | Source | Fallback |
|---|
| PROJECT_NAME | → | |
| PROJECT_DESCRIPTION | → | [TBD: Project description]
|
| DATE | current date (YYYY-MM-DD) | — |
Step 2b: Create CLAUDE.md (if missing)
- MANDATORY READ: Load
skills/ln-111-root-docs-creator/references/templates/claude_md_template.md
- Replace , ,
- Mark remaining as
- Write to target project root
Step 2c: Create AGENTS.md (if missing)
Source: target project's CLAUDE.md (just created or pre-existing).
| # | Transformation | Find | Replace |
|---|
| 1 | Title | First H1 line | |
| 2 | SCOPE | docs/`` | docs/`. Skill workflows in individual `SKILL.md` files. Public documentation in `README.md`.` |
| 3 | Agent name | / in intro line | |
| 4 | DAG entry | | |
| 5 | Add rule | After last Critical Rules row | Add: | **Code Comments 15-20%** | Writing code | WHY not WHAT. No historical notes. Task/ADR IDs as spec refs only |
|
Step 2d: Create GEMINI.md (if missing)
Source: target project's AGENTS.md (just created or pre-existing).
| # | Transformation | Find | Replace |
|---|
| 1 | Title | First H1 line | |
| 2 | Agent name | in intro line | |
| 3 | DAG entry | | |
| 4 | Compact | | during context compression:
|
| 5 | Remove rule | row | Delete row |
Step 2e: Report Creations
List each created file with its source (template / derived from CLAUDE.md / derived from AGENTS.md).
Phase 3: Token Budget Audit
For each instruction file:
| Check | Pass | Warn | Fail |
|---|
| Line count | ≤100 lines | 101-150 lines | >150 lines |
| Estimated tokens | ≤2,500 tokens | 2,501-3,500 | >3,500 |
| Sections count | ≤8 sections | 9-12 | >12 |
Token estimation: × 1.3 (English average tokens/word ratio).
Report table per file with line count, word count, estimated tokens.
Phase 4: Prompt Cache Safety
Check each file for content that breaks prefix-based prompt caching:
| # | Check | Pattern | Severity |
|---|
| 1 | No timestamps | grep -E '\d{4}-\d{2}-\d{2}.\d{2}:\d{2}'
| WARN |
| 2 | No dates in content | `grep -E '(January | February |
| 3 | No dynamic counts | grep -E '\d+ skills|\d+ tools|\d+ servers'
(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 | 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 | Missing explicit prohibitions |
| 5 | Compact Instructions section | present with preservation priorities | Missing — sessions lose decisions on /compact |
| 6 | MCP Tool Preferences | Table mapping built-in → MCP tools | Missing — agents use suboptimal tools |
| 7 | No tool output examples | No large code blocks or command outputs | Found — bloats every turn |
Phase 6: Cross-Agent Consistency
Compare content across all found instruction files:
| Check | Pass | Fail |
|---|
| MCP Tool Preferences | Same table in all files | Missing in some files |
| Critical Rules | Same core rules | Divergent rules |
| Build/test commands | Same commands | Different or missing |
| Structural sections | Same section order | Inconsistent structure |
Sync action: For each inconsistency, show diff and suggest which file is source of truth (usually CLAUDE.md).
Phase 7: Report
Agent Instructions Manager:
Created: (omit section if nothing created)
- CLAUDE.md (from template, context from package.json)
- AGENTS.md (derived from CLAUDE.md)
Audit:
| File | Lines | ~Tokens | Cache-safe | Quality | Issues |
|------------|-------|---------|------------|---------|--------|
| CLAUDE.md | 80 | 2,100 | OK | 6/7 | Missing Compact Instructions |
| AGENTS.md | 77 | 2,000 | OK | 7/7 | OK |
| GEMINI.md | 75 | 1,950 | OK | 7/7 | OK |
Cross-agent: OK (or N inconsistencies listed)
Recommendations:
1. Run /init (ln-100) for full context-aware CLAUDE.md with project-specific rules
2. Add ## Compact Instructions to CLAUDE.md
Definition of Done
Version: 2.1.0
Last Updated: 2026-03-24