/memory-tools:agentic-memory-managementfrom memory-tools
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.
Ships in memory-tools. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
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 seven 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-management/SKILL.md
@-import loads this file as memory text, not as a skill, so
${CLAUDE_SKILL_DIR} is not substituted there: when following the imported
copy, replace it with <plugin-dir>/skills/agentic-memory-management in the
verify command.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.
Verification gate — before writing, re-check the audited file's own frontmatter. If it opens with
---and that block is unterminated or contains a line that is not a YAML key/value, do not overwrite it: REPORT rather than write, naming the file and the offending line.
Run immediately after the Step 6 write, substituting the path written in Step 6 for the
placeholder. ${CLAUDE_SKILL_DIR} is replaced with this skill's absolute folder when the skill
loads. The script shows the resulting diff, then asserts the file still parses and still has a
body.
python3 "${CLAUDE_SKILL_DIR}/scripts/verify_write.py" <absolute-path-to-memory-file>
If the command exits non-zero, STOP. Report the failure with the file path and the printed
reason, tell the user to restore from their backup (git checkout -- <path> where the file is
tracked), and do not attempt a second write.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub shawn-sandy/agentics-kit --plugin memory-tools3 skills in this plugin
/implementing-insightsImplements usage-insights report findings across local repos. Triages against config; implements open items, each with a live record. Use when the user asks to implement insights findings./path-rules-advisorCreates path-specific rule files in .claude/rules/. Analyzes project structure and generates scoped rules for file types or directories. Use when the user wants to add path-specific rules.Other plugins' skills for the same job
2 plugins ship this exact skill · first indexed Oct 29, 2026