kit/plugins/memory-tools/skills/memory-doctor/SKILL.md
Use when the user asks to audit, optimize, clean up, or diagnose a CLAUDE.md / project memory file, or when Claude appears to ignore project instructions. Does not cover SKILL.md files, slash commands, or general markdown.
npx skillsauth add shawn-sandy/agentics 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.
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.
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."
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/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.
development
Turns a React component into a social card with preview, code, and props table. Builds a static preview and screenshots react-card.html via Playwright. Use when asked to share a React component.
data-ai
Refine-prompt: interviews users and assembles a structured AI prompt using Anthropic best-practice techniques. Use when the user runs /plan-agent:refine-prompt or asks to refine a prompt.
development
Plan review Agent Team. Reviews HTML implementation plans in parallel, synthesizes findings, and applies improvements in place. Use when the user asks to review or improve an implementation plan.
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.