kit/plugins/memory-tools/skills/agentic-memory-doctor/SKILL.md
Audits and optimizes CLAUDE.md project memory files. Checks adherence to Claude Code best practices and produces actionable fixes. Use when the user asks to audit, optimize, or diagnose a CLAUDE.md.
npx skillsauth add shawn-sandy/agentics agentic-memory-doctorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Audit and optimize a CLAUDE.md / project memory file against Claude Code best practices.
Optimization principle — Keep only rules that would change Claude's behavior versus its built-in defaults; cut everything else. Tighten the rules that survive so each load-bearing instruction reads crisply: verb-first, one idea per bullet, no hedging. This principle governs both the audit (what to flag) and the rewrite (what to keep or cut in Step 5).
Freedom level: Rigid — Execute all six steps in the order listed. Do not skip, combine, or reorder them. Plan-mode pre-check — If the system indicates plan mode is active when reaching Step 5, defer all write-related prompts and actions (Steps 5–6, including rule-file creation and CLAUDE.md overwrites) until the user exits plan mode. Read-only steps (1–4) may proceed in plan mode. Operational rules — Audit only the file specified. Do not scan the entire project unless asked. Steps 5 and 6 are opt-in — do not rewrite the file without explicit confirmation. Memory load order: project rules → project memory → user memory →
CLAUDE.local.md. Combined instruction count across all loaded files is what matters. Use@path/to/fileimport syntax to reference external docs without embedding their full content.
Does not cover SKILL.md files, slash commands, or general markdown.
Determine which CLAUDE.md to audit using this priority order:
CLAUDE.md in the current working directory (primary project location).claude/CLAUDE.md in the current working directory (alternate, checked if primary absent)~/.claude/CLAUDE.md (global user-level)If both CLAUDE.md and .claude/CLAUDE.md exist, audit CLAUDE.md (root takes priority) and note that the alternate location was skipped.
Tell the user which file will be audited before continuing. If none of the four locations has a file and no argument was given, stop and ask the user to provide a path.
If a path was given but the file does not exist, stop and report the error clearly.
Read the target file in full (Read), then collect these metrics:
**Always**, **Never**). Acknowledge a ±30–50 variance in your estimate.## heading presentGrep -nE on the target file with the pattern sk-|ghp_|AKIA|xoxb-|-----BEGIN|[A-Z_]+=[[:alnum:]_]{20,}. Report each match with its line number and a masked value (never print full secret text). Masking rule: if token length ≥ 8, show first 4 + *** + last 4 (e.g. sk-a***b3x4); if length 4–7, show first 2 + *** + last 2; if length < 4, show ****. If no matches, report "No secrets found."@path/to/file references in the file. List each one found. Determine the import root: if the audited file is inside the workspace (current working directory), use the workspace root; if it is outside (e.g., ~/.claude/CLAUDE.md), use the audited file's own directory as the root. Resolve each import relative to the audited file's directory, then reject any path that is absolute, contains .. traversal, or resolves outside the import root; for rejected paths report "import <path> rejected: outside project root" and skip Read. For each allowed imported file, attempt to Read it and report its line count — do not follow imports found inside those files (strictly one level deep). If the imported file exceeds 500 lines, skip counting it but include a warning: "import <path> has N lines — exceeds 500-line cap, not counted." Sum the counts of all imports under the cap and report as "effective lines (incl. imports): N (approximate, one level deep)." Note that imported content counts toward effective instruction load but is not visible in the raw line count.Report all five metrics before proceeding to Step 3.
Score each dimension 0, 1, or 2. Maximum score: 12.
Full dimension definitions, scoring tables, and example audit output are in
references/audit-steps.md. Load that file before scoring.
Output a structured report in this format:
## CLAUDE.md Audit Report
**File:** [path audited]
**Lines:** [n] | **Estimated instructions:** [n ± 30–50]
### Scores
| Dimension | Score | Max |
|------------------------|-------|-----|
| Instruction Budget | [n] | 2 |
| Section Quality | [n] | 2 |
| 80% Rule Compliance | [n] | 2 |
| Progressive Disclosure | [n] | 2 |
| Safety & Hygiene | [n] | 2 |
| Structure | [n] | 2 |
| **Total** | **[n]** | **12** |
**Grade:** [see scale below]
Grade scale:
| Total | Grade | |-------|--------------| | 10–12 | Optimized | | 7–9 | Functional | | 4–6 | Needs work | | 0–3 | Rewrite |
After the table:
When Progressive Disclosure scores 0 or 1, include as a Top 3 item: "Consider invoking the sibling
memory-tools:path-rules-advisorskill to break path-specific content into.claude/rules/files — it is purpose-built for this workflow. You can also use Step 5's inline rule-file generation as a fallback."
When Safety & Hygiene scores below 2 due to default-restating rules, name them explicitly in the per-dimension finding: quote one or two examples from the file and label them "default-restating" so the user can recognise the pattern and apply the same cut test to the rest.
Use AskUserQuestion to ask: "Would you like me to generate an optimized version of this file in the chat?" (Yes / No)
If the user says yes, generate the optimized content in a code block in the chat (do not write to disk yet). Apply these transformations:
[REDACTED - move to .env]).claude/rules/ files below, not embedded in the CLAUDE.md outputOffer to generate .claude/rules/ files:
For each section removed as an 80%-rule violation or path-specific content:
paths: frontmatter:---
paths:
- "<glob>"
---
# <Descriptive Title>
- Rule bullet 1
- Rule bullet 2
- Rule bullet 3
.claude/rules/ exists. If not, use AskUserQuestion to ask: "The .claude/rules/ directory does not exist. Should I create it?" (Yes / No)AskUserQuestion to ask: "Should I write this to .claude/rules/<name>.md?" (Yes / No) Wait for explicit confirmation before writing each file.Path-rules delegation: If Progressive Disclosure scored ≤ 1, recommend invoking
memory-tools:path-rules-advisorinstead of manually creating rule files here. Keep the inline flow above as a fallback if the user prefers to stay in this skill.
After the CLAUDE.md code block, show a separate callout:
To make this skill always available in your project, add the following to your CLAUDE.md
(replace <plugin-dir> with the path passed to --plugin-dir when loading this plugin):
@<plugin-dir>/skills/agentic-memory-doctor/SKILL.md
If the user says no, stop here.
Use AskUserQuestion to ask: "Should I write this to disk? Commit or back up your current CLAUDE.md first — this will overwrite it." (Yes / No)
If the user says yes, use AskUserQuestion again with: "Final confirmation: overwrite <audited file path> with the optimized version now?" (Yes / No)
Write only the file that was audited in Step 1, and only after both confirmations are affirmative.
data-ai
Craft-prompt: interviews users and assembles a structured AI prompt using Anthropic best-practice techniques. Use when the user runs /plan-agent:craft-prompt or asks to craft a prompt.
development
Generates a SOCIAL.md project sharing config by analyzing the codebase. Use when asked to set up social sharing preferences or create a SOCIAL.md file.
development
Explains how any project file, component, or concept works. Reads source files and synthesizes developer-friendly principles, social copy, and a dark-mode card. Use when asked 'how does X work' or 'explain X'.
development
Generate an HTML implementation-plan document. Produces a self-contained .html plan file with steps, acceptance criteria, and metadata. Use when the user asks to create a plan document, generate an HTML plan, or write a plan file — not for general planning questions.