Harness fixer

From agentic-dev3o/devx-plugins · View interactive version

Harness fixer is an AI agent skill from the GitHub repository agentic-dev3o/devx-plugins. Audits a project's agentic harness (CLAUDE.md, AGENTS.md, .claude/rules, .claude/settings.json) and refactors it into a layered, path-scoped configuration that loads only what is relevant. Rewrites CLAUDE.md and AGENTS.md as a thin critical-rules layer, segments domain rules with `paths:` frontmatte

How to use this skill

Skill file

Fixing the Agentic Harness

Target: $ARGUMENTS (optional path; defaults to project root)

Objective

Refactor the project's harness so the model sees only the rules it needs for the files it touches. CLAUDE.md (and AGENTS.md when present) become a thin always-on critical-rules layer. Domain rules move to .claude/rules/*.md with paths: frontmatter. Permissions and MCP scope live in .claude/settings.json with explicit deny guardrails.

The goal is inference weight, not exhaustive documentation: 10 sharp directives the model references in reasoning beat 200 lines it half-skims.

Workflow

Progress checklist:

Harness Audit & Fix:
- [ ] Step 1: Inventory current harness
- [ ] Step 2: Audit against best practices
- [ ] Step 3: Produce gap analysis
- [ ] Step 4: Propose refactor plan (confirm with user)
- [ ] Step 5: Apply changes (CLAUDE.md, AGENTS.md, rules, settings)
- [ ] Step 6: Verify with /memory

Step 1: Inventory Current Harness

Read in parallel where present:

Capture the actual directory layout (top-level apps, packages, services). Use tokei if available, otherwise find or ls. The layout drives the path scopes proposed in Step 4 — generic globs that don't match real directories are dead weight.

Step 2: Audit Against Best Practices

Load references/audit-checklist.md and score each dimension:

  1. CLAUDE.md size and shape — under 30 lines, directives not prose, no domain dump
  2. AGENTS.md alignment — mirrors CLAUDE.md when present, no drift
  3. Rules segmentation — path-scoped, one domain per file, no overlap
  4. Permissions hygiene — explicit deny for destructive ops and secrets, scoped allow patterns, MCP tools narrowed
  5. Local overrides — .claude/settings.local.json and CLAUDE.local.md in .gitignore
  6. Memory ergonomics — no monolithic root CLAUDE.md drowning monorepo subtrees

Step 3: Produce Gap Analysis

Output a markdown table:

| Dimension | Status | Severity | Evidence | Suggested fix |

|-----------|--------|----------|----------|---------------|

Status values: Respected, Violated, Partially respected, N/A

Severity values:

End with a Top fixes list ordered by impact.

Step 4: Propose Refactor Plan

Present the proposed file layout before writing anything:

CLAUDE.md                       (X lines today -> Y lines after)
AGENTS.md                       (if other agents are in use)
.claude/rules/
├── <domain-1>.md   paths: <glob>
├── <domain-2>.md   paths: <glob>
└── ...
.claude/settings.json           (deny rules + scoped allow)
.gitignore                      (add .claude/*.local.*, CLAUDE.local.md)

Confirm with the user before applying. Path scopes must match real directories surfaced in Step 1.

Step 5: Apply Changes

For each file:

  1. Rewrite CLAUDE.md using references/claude-md-template.md. Keep only project-wide directives. Move domain-specific content to rules files. Target under 30 lines.
  1. Sync AGENTS.md using references/agents-md-template.md when other agents are in use. Mirror the critical rules; reference domain rules by path rather than duplicating them.
  1. Create path-scoped rules in .claude/rules/<domain>.md using patterns from references/path-scoping-patterns.md. Each rule file has paths: frontmatter listing globs and contains only directives that apply inside those paths.
  1. Harden .claude/settings.json using references/settings-recipes.md. Add deny for destructive ops and secret files. Tighten allow patterns. Scope MCP tools.
  1. Update .gitignore to include .claude/*.local.* and CLAUDE.local.md if missing.

Preserve concrete content the user relies on — package manager command, lint command, framework gates. Surface anything you plan to delete before deleting it.

Step 6: Verify

Validate the rewrite, then fix anything that fails and re-verify:

  1. Line budget — wc -l CLAUDE.md should be under 30. If not, return to Step 5 and move more content into rules.
  2. Path scope sanity — for each new rules file, confirm at least one file in the repo matches its paths: glob (git ls-files | grep -E <pattern>). If zero matches, the glob is wrong.
  3. Deny rules in place — grep -c '"deny"' .claude/settings.json should return ≥ 1. The deny list must include destructive ops and secret reads.
  4. .gitignore covers locals — grep -E '\.claude/\*\.local|CLAUDE\.local\.md' .gitignore should return matches.
  5. Memory check — ask the user to run /memory and confirm CLAUDE.md plus only the path-scoped rules relevant to the current cwd are listed as loaded.

If any check fails, fix it and re-run from check 1. Do not declare the refactor complete with a failing check.

Constraints

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.