neat-freak
kkkkhazix/khazix-skills
End-of-session knowledge cleanup—reconciles project docs, agent memory, and code to prevent documentation rot.
What is neat-freak?
Neat-freak is a knowledge base editor skill that maintains project documentation (CLAUDE.md, README.md, docs/) and agent memory in sync with code changes. Trigger it when a development milestone completes or when docs feel stale, using phrases like "sync up", "tidy up docs", "整理一下", or similar. It works across Claude Code, OpenAI Codex, OpenCode, and OpenClaw.
- Audits and reconciles three knowledge layers: agent memory, project root markdown (CLAUDE.md/AGENTS.md), and docs/ to prevent inconsistency
- Enforces size limits (CLAUDE.md ~300 lines, memory index ≤25KB/200 lines) to prevent bloat and context loss
- Promotes stable knowledge from memory into docs via a "graduation" mechanism—deletes or shrinks memory files once facts are documented
- Detects and fixes common sync failures: stale docs, contradictory memories, missing integration guides, and cross-project misalignment
- Applies a change-impact matrix to identify which documentation layers need updates (API changes → routes table + architecture + integration guide)
- Removes historical narratives and event logs from CLAUDE.md, migrating them to changelogs or docs/CHANGES.md
How to install neat-freak
npx skills add https://github.com/kkkkhazix/khazix-skills --skill neat-freak- Access to agent memory system (location varies by platform: Claude Code uses ~/.claude/projects/<...>/memory/, Codex uses AGENTS.md, OpenCode uses .opencode/, OpenClaw uses ~/.openclaw/)
- Existing project structure with at least README.md and CLAUDE.md or AGENTS.md
- File editing capability (Edit, Write, Delete commands)
How to use neat-freak
- 1.Trigger the skill by saying "sync up", "tidy up docs", "整理一下", or similar milestone-completion phrases
- 2.The skill performs a mechanical audit: lists all memory files, docs/, and root markdown; reads each file
- 3.Identifies what changed in the current session using a change-impact matrix (new API → update routes, architecture, integration guide, etc.)
- 4.Edits files in priority order: docs/ first (external impact), then CLAUDE.md/AGENTS.md, then memory
- 5.Applies size checks and removes bloat: deletes historical narratives from CLAUDE.md, promotes stable memory facts into docs/, compresses memory index to ≤25KB
- 6.Runs a self-check: verifies no file was missed, CLAUDE.md net growth ≤30 lines, memory index ≤25KB/200 lines, no contradictions between layers
Use cases
- After implementing a new API endpoint: update route tables in CLAUDE.md, integration guide in docs/, and architecture diagrams
- When memory files accumulate (>25KB): promote stable patterns into docs/, delete single-incident records, keep only recent lessons and reference pointers
- Before handing off a project to teammates or another AI agent: ensure CLAUDE.md rules are current, docs/ is complete and newcomer-friendly, and memory doesn't contradict docs
- When environment variables, database schema, or deployment procedures change: sync CLAUDE.md, runbook, integration guide, and downstream project docs simultaneously
- Quarterly knowledge audit: compress memory index, delete completed tasks and obsolete decisions, verify docs/ matches current code state
- AI agents (Claude Code, Codex, OpenCode, OpenClaw) managing multi-session projects
- Development teams coordinating handoffs between sessions or between different AI agents
- Projects with cross-dependencies where docs in one project affect integration in another
- Teams that want to prevent documentation drift and keep onboarding guides current
neat-freak FAQ
CLAUDE.md is a rules handbook for the AI itself—hard boundaries, environment variables, command shortcuts, and warnings it must see to avoid mistakes. docs/ is for external readers (humans, downstream teams, future agents)—architecture, integration guides, runbooks, and onboarding. CLAUDE.md is not a changelog; historical narratives belong in docs/CHANGES.md or git log.
Claude Code loads only the first 200 lines or 25KB of MEMORY.md at session start; anything beyond that is silently not loaded. Exceeding the limit means your knowledge is effectively lost. Prevent this by promoting stable facts into docs/ and deleting single-incident records, keeping memory thin and recent.
Graduation is moving a memory fact into docs/ or CLAUDE.md once it's stable and reusable. After graduation, delete or shrink the original memory file to a one-line pointer. This prevents memory from bloating and ensures knowledge reaches the right audience (docs for external readers, CLAUDE.md for AI rules).
Ask: "If the AI doesn't see this next session, will it make a mistake?" If yes → CLAUDE.md (rules, red lines, warnings). If no → docs/ (detailed mechanisms, examples, architecture). Avoid duplicating docs content in CLAUDE.md; use a pointer table instead.
Check the change-impact matrix for cross-project dependencies. If project A's API changes and project B consumes it, update both projects' docs. This is the most common sync failure. Always verify downstream projects' integration guides match the upstream change.
Full instructions (SKILL.md)
Source of truth, from kkkkhazix/khazix-skills.
name: neat-freak description: > End-of-session knowledge cleanup with OCD-level rigor — reconciles project docs (CLAUDE.md, README.md, docs/) and agent memory against the code so nothing rots. 会话结束后对项目文档和记忆进行洁癖级审查与同步。MUST trigger when the user says: "sync up", "tidy up docs", "update memory", "clean up docs", "/sync", "/neat", "同步一下", "整理文档", "整理一下", "更新记忆", "梳理一下", "收尾", "这个阶段做完了", "新人能直接上手", or any phrase suggesting a dev milestone where knowledge needs reconciliation. Also trigger when the user reports stale docs, conflicting memories, or wants a clean handoff to teammates or other agents. Bare "整理" / "tidy" with prior dev context counts — do not under-trigger. Cross-platform: works on Claude Code, OpenAI Codex, OpenCode, and OpenClaw.
洁癖 — Knowledge Base Neat-Freak
Cross-platform Agent Skill — Claude Code · OpenAI Codex · OpenCode · OpenClaw 通用。 跨平台 SKILL.md,遵循开放 Agent Skill 规范。
你是一个知识库编辑,不是记录员。记录员只会往后追加,编辑会审查全局、合并重复、修正过期、删除废弃。你的工作是让整个项目的知识体系始终保持干净、准确、对新人友好的状态——像有洁癖一样。
为什么这件事重要
在 AI 协作开发中,代码可以随时重写,但文档和记忆是跨会话、跨 Agent 的唯一桥梁。如果记忆里有过期信息,下一个 Agent(无论它是 Claude、Codex 还是别的)会基于错误前提做决策。如果 docs/ 混乱或缺失,接手者(尤其是下游项目的同事)会浪费大量时间搞清楚这套系统怎么用。
这个 Skill 的价值就在于:让知识体系的每一层都跟得上代码的变化。
关键概念:三类知识,三种受众
必须先理解这件事,否则你会只改 CLAUDE.md 就结束,把下游同事和其他 agent 晾在那儿。
| 位置 | 受众 | 职责 | 不同步的代价 |
|---|---|---|---|
| Agent 记忆系统(若 agent 支持) | Agent 自己跨会话复用 | 个人偏好、非显而易见的项目事实、跨项目 reference | 下次会话 Agent 忘记历史决策 |
项目根 CLAUDE.md / AGENTS.md | 当前项目里的 AI(下次会话自己) | 项目约定、结构、红线、环境变量、路由清单 | 下次 AI 在这个项目里走弯路 |
项目 docs/ + README.md | 其他人(人类同事、下游开发者、未来接手的 AI) | 接入指南、架构图、运维手册、交接说明、API 参考 | 其他人或系统无法正确接入或运维 |
这三层受众不同,职责不重叠。CLAUDE.md 里写"新增了 device flow 五个路由" ≠ docs/integration-guide.md 里"下游怎么接这套 flow" —— 前者是提醒自己,后者是教别人。两份都要写。
Agent 记忆系统的具体位置因平台而异(Claude Code 在
~/.claude/projects/<...>/memory/,Codex 用AGENTS.md,OpenCode 用.opencode/,OpenClaw 用~/.openclaw/)。完整路径速查见 references/agent-paths.md。如果当前 agent 没有独立的记忆系统,直接跳过这一层,把功夫全花在 docs 和项目根 markdown 上。
记忆只增不改、docs 就地编辑——要靠「毕业」机制把知识往上泵(膨胀头号根因)
必须理解这条不对称,否则记忆永远在膨胀:docs 靠就地编辑收敛(系统改 10 次,还是那一份 ARCHITECTURE.md),而 agent 记忆天生只追加(每条教训生一个新文件,旧的不删)。没有反向阀门,memory 会一路堆到比 docs 还大,真正稳定的知识被困在几十个松散文件里——既进不了 prompt(索引 25KB 截断),也没沉淀成给别人看的文档。高速开发的项目尤其明显:每天 2-3 条教训 × 数周 = 上百个记忆文件。
反向阀门 = 毕业(promote)。 一条记忆满足下面任一条,就把它「毕业」:内容并进对应的 docs/ 或 CLAUDE.md,然后把原记忆文件删掉或缩成一行指针:
- 同一主题的教训反复出现到第 3 次 → 它已是稳定知识而非「最近踩的坑」,归 docs。
- 它讲的是「系统怎么工作」而非「我们踩过什么坑 / 做过什么决策」 → 本就是 docs 的职责,memory 顶多留指针。
- 它是「X 上线 / 落地 / 就位」的事件记录 → 现役事实进 docs,过程进 git log /
docs/CHANGES.md,memory 不留常驻文件。
判据一句话:「下一个接手的人(不只是我自己)需要知道这件事吗?」需要 → 它属于 docs,不是 memory。
记忆文件若用类型前缀(如
feedback_=教训 /project_=决策事件 /reference_=速查),生命周期不同:reference_通常合法长期常驻;feedback_稳定后毕业;project_多数是事件记录,是优先毕业 / 删除的对象——决策结论进 docs,过程进 changelog。
CLAUDE.md / AGENTS.md 是规则手册,不是变更日志(重要)
最常见的 skill 翻车模式:每次开发完都在 CLAUDE.md 顶部加一段 blockquote 历史叙事——"2026-05-08 X 功能上线,详见 docs/Y.md"。一次很爽,半年后顶部就是 200 行 blockquote 把真正的规则推到看不见。这种叙事不属于 CLAUDE.md,它的归宿是 git log / /changelog 页 / docs/CHANGES.md。
判断一条信息该不该进 CLAUDE.md,问一句:下次 AI 写代码时如果没看到这条,会不会犯错?
| 例子 | 进 CLAUDE.md? | 理由 |
|---|---|---|
"Prisma 查询只写在 modules/**/data/" | ✅ | 违反就是边界破坏,AI 必须看到 |
| "rsync 单文件部署必须用完整 target 路径" | ✅ | 踩坑警示,会再次踩 |
| "禁止裸跑 systemctl stop aihot-worker" | ✅ | 红线,事故级 |
| "2026-05-08 timelineAt 上线,详见 docs/ARCHITECTURE.md §5.4" | ❌ | 详细机制在 docs;AI 改到这块自然会读 docs;「深入文档」指针表已做这件事 |
| "2026-04-30 起公网开放,匿名可访 /、/all" | ❌ | 既是历史也是事实,但事实归 docs/ARCHITECTURE.md §8 + 项目概览一句话足矣 |
| "5/8 修了 X bug 的复盘细节" | ❌ | 单次事故记忆,归 memory 或干脆删 |
✅ 该进 CLAUDE.md 的内容:硬边界规则、禁止事项、命令速查、权限模型、协作流程、深入文档指针表、踩坑警示。 ❌ 不该进的:历史叙事("X 时刻起 Y 上线")、详细机制说明、单次事故复盘、bug fix 流水账、"详见 docs/Z.md" 的指针句子(这个角色已经被「深入文档」指针表占掉了)。
执行流程
第零步:尺寸体检(防膨胀)
任何同步动作之前,先 wc -l 关键文件:
| 文件 | 上限 | 超过怎么办 |
|---|---|---|
CLAUDE.md / AGENTS.md | ~300 行 / ~15KB(软,看 adherence) | 先精简:扫顶部 blockquote / 历史叙事段 → 删 / 迁 docs;项目概览只留 1-3 行 + 速查表,不做"提醒下次会话"用。(CLAUDE.md 是全量加载,不会被截断,但越长 adherence 越差) |
记忆索引 MEMORY.md | ≤200 行 且 ≤25KB(硬) | Claude Code 只加载 MEMORY.md 的前 200 行或前 25KB(先到先算),超出部分在会话开始时静默不加载——等于没记。务必压在 ~150 行 / ~18KB 留缓冲。压法不是硬删,是下面的「毕业」机制:详细机制提升进 docs、索引只留一行指针 |
| 单条 memory 文件 | ~100 行(软) | 通常在塞多件事 / 写成事故复盘 → 拆 / 删;若是稳定机制说明,提升进 docs 再把记忆缩成 reference 指针 |
docs/<single>.md | ~1500 行(软) | 切分成多文件,加目录索引 |
额外做一次「体量倒挂」体检:du -sh <memory 目录> 对比 du -sh docs/。健康态是 docs 厚、memory 薄——docs 是沉淀的权威层,memory 是流动的「最近教训 + 指针」层。若 memory 反而比 docs 大,几乎一定是「本该毕业进 docs 的稳定知识还赖在松散记忆文件里」,按「毕业」机制往上泵,别只在 memory 内部挪。
超尺寸是这个 skill 的最高优先级,大于"补本次会话漏掉的同步"。 原因:MEMORY.md 超 25KB 的部分根本不进上下文(静默丢失),超尺寸的 CLAUDE.md 让真正的规则被叙事段挤出 adherence——两种情况下,同步再补都徒劳。
执行顺序:先精简(破除膨胀)→ 再做本次会话增量同步(补漏)。两件事不能合并——精简时心态是"什么不该在这",补漏时心态是"什么该补到这",混着做会两头不到位。
第一步:盘点现状(强制机械式枚举,不能跳过)
先做 ls,再做判断。
- 列出 agent 的记忆文件(如有):
- Claude Code:
ls ~/.claude/projects/<...>/memory/并读MEMORY.md及所有被引用的.md - Codex / OpenCode / 其他:找该 agent 的等价位置(见 references/agent-paths.md)
- Claude Code:
- 对本次对话涉及的每一个项目:
ls <project-root>/→ 确认根目录结构ls <project-root>/docs/ 2>/dev/null→ 枚举所有 docs(缺失也要确认)find <project-root> -maxdepth 2 -name "*.md" -not -path "*/node_modules/*" -not -path "*/.git/*"→ 兜底抓散落的 .md- 读
README.md、CLAUDE.md/AGENTS.md、每一个docs/*.md
- 读全局 agent 配置(若有,如
~/.claude/CLAUDE.md、~/.codex/AGENTS.md) - 回顾本次对话全部内容
输出一张文件清单(内部用,不用给用户看),对每个文件标:「评估过 / 要改 / 不用改」。漏一个不行——这是这个 skill 最容易翻车的地方。
第二步:识别变更——用"变更影响矩阵"思考
不要只看对话增量有什么新事实,要看新事实会波及哪些文档层级。
常见模式速览:
- 新增 API / 路由 → CLAUDE.md 路由清单 + integration-guide + architecture 的 Routes
- 新增 / 改名 环境变量 → CLAUDE.md 环境变量表 + runbook + 下游 integration-guide
- 新增数据库表 → CLAUDE.md + architecture 的 Data Model
- 新增大特性(跨多文件) → 以上全部 + architecture 新章节 + handoff 已完成清单
- 跨项目改动 → 上下游两边的 docs 都要对齐(最常见的漏改场景)
- 记忆层面:相对时间→绝对日期、过期事实→改、重复→合并、已完成待办→删
完整映射表(覆盖更多变更类型与对应文档)见 references/sync-matrix.md——遇到不确定的改动先查这张表。
关键检查:这次对话是不是跨项目的?如果改了项目 A 且项目 B 依赖它(通过 SDK、API、子域、环境变量),项目 B 的 docs 也要改。这是历次同步最常翻的车。
第三步:实际修改(用工具,不只是描述)
你必须真的用 Edit 修改现有文件、用 Write 创建新文件、用删除命令清理废弃文件。"我会怎么改"的描述不算完成。
顺序建议:先改 docs/(改错影响外部)→ 再改 CLAUDE.md/AGENTS.md → 最后理记忆。先动外部优先级最高的,即使中途被打断,读者看到的也是对齐的最新状态。
编辑原则:
- 减优于加(最重要):每次同步动作结束后,CLAUDE.md / AGENTS.md 净涨幅 > 30 行就是红灯——很可能在写历史叙事而不是补规则。回头审:这条加的是"下次 AI 写代码时必须看到"的规则,还是"上次会话告诉下次会话发生了什么"的便条?后者就是病。能删的先删,不能删的迁去 docs,最后剩下的才是规则。
- 合并优于追加:新信息是对旧信息的更新,改旧条目;新加条目前先 grep 同关键字,看现有条目能不能并
- 删除优于保留:完成的临时计划、推翻的决策、已被新版本取代的项目记忆、单次事故的流水账复盘——删
- 毕业优于内部挪腾(针对 memory):一条记忆稳定、复用、或本属「系统怎么工作」时,别在 memory 里搬来搬去——并进 docs / CLAUDE.md,原文件缩成一行指针或删。这是把 memory 压回「薄」的唯一治本手段(见上「毕业」机制)
- 精确优于冗长:一条记忆说清楚一件事,别塞三件
- 绝对时间:永远
2026-04-29,不写"今天"、"最近" - 面向读者:docs/ 的读者是"第一次接触这个项目的外部人",写的时候想象对方只有 5 分钟能看完
- 受众不混:CLAUDE.md 里不抄 docs/ 的全文,docs/ 里不写"我记得上次……"——这是记忆的事
- 指针不重复:同一条事实如果 docs/ 里已详写,CLAUDE.md 只在「深入文档」指针表里出现一次,不在概览段再叙事一次
全局配置极度克制:~/.claude/CLAUDE.md / ~/.codex/AGENTS.md 只有用户在对话中明确表达了跨项目的核心原则才动。日常项目细节绝不进全局。
docs/ 编辑要点——新增一个能力的文档变更通常要四处都补:
- integration-guide 或对应"外部视角"文档:加怎么用(curl / SDK 示例 / 错误码表)
- architecture:加怎么工作(数据流、状态机、设计取舍)
- runbook:加怎么运维(冒烟命令、故障排查、环境变量)
- handoff 或 CHANGELOG:加已完成
API 速查表、环境变量表、术语表是高频查询的结构化信息,必须保持"所见即最新"。
第四步:自检清单(必须逐项过一遍)
这一步同时防止"漏改 docs" + "误把叙事塞进 CLAUDE.md"。改完后逐条检查:
尺寸 / 反膨胀(先查这组,不达标的话回头先精简):
- CLAUDE.md / AGENTS.md 净涨幅 ≤ 30 行(超了就是塞了历史叙事,回去删 / 迁 docs)
- 没新增 "X 起 Y 上线,详见 docs/Z.md" 这种 blockquote 历史叙事条目
- 没在 CLAUDE.md 里抄 docs/ 已有的详细机制说明
- 单条 memory 文件没超 ~100 行(超了拆 / 删 / 改成 reference)
- 记忆索引
MEMORY.md≤ 25KB 且 ≤ 200 行(wc -c实测;超出部分会话开始时静默不加载 = 等于没记) - 体量没倒挂:
du memory不应大于du docs/;倒挂了说明有该毕业进 docs 的知识赖在 memory,回去毕业
完整性 / 反漏改(再查这组):
- 第一步列出的每个文件,都判断了"不用改"或"已改"
- 记忆索引(若有)里的每个链接指向存在的文件
- 每个记忆文件的 description 和内容对得上
- 记忆之间没有互相矛盾
- CLAUDE.md / AGENTS.md 里提到的路径 / 命令 / 工具 / 环境变量在代码中真实存在
- README 的安装 / 运行步骤跟代码一致
- 新增 API 路由:在 integration-guide 和 architecture 都出现了
- 新增环境变量:在 runbook 和项目根 markdown 都出现了
- 新增数据库表:在 architecture 的 Data Model 和项目根 markdown 都出现了
- 跨项目影响:下游项目的 docs 也跟着改了
- 没有相对时间遗留(
grep -E "今天|昨天|刚刚|最近|上周|today|yesterday|recently"清零)
哪条打不了勾,回去补。不要因为"差不多了"就跳过这一步——这是这个 skill 的灵魂。
第五步:变更摘要
在所有文件修改完之后(不是之前),给用户简洁摘要:
## 同步完成
### 记忆变更
- 更新:xxx(原因)
- 新增:xxx
- 删除:xxx(原因)
### 文档变更(按项目分组,每个项目列全改动的文件)
- <项目 A>/CLAUDE.md — xxx
- <项目 A>/docs/integration-guide.md — xxx
- <项目 A>/docs/architecture.md — xxx
- <项目 B>/docs/<integration>.md — xxx
### 未处理
- xxx(为什么没处理,比如需要用户确认)
只列有实际变更的条目。没改的不写。
特殊情况
项目还没有 README 或 CLAUDE.md/AGENTS.md:判断项目是不是到了"有可运行代码"的阶段。是 → 创建。还在 vibe 阶段 → 跳过,但在摘要里提一句。
对话没有产生新事实:审查现有记忆和文档有没有过期 / 冲突 / 相对时间——审查本身就有价值。
记忆之间出现无法自动判断的矛盾:列在「未处理」让用户决定。这是唯一需要用户介入的情况,其他都自己拍板。
跨项目改动:本次对话改了多个项目,每个项目都要跑一次完整的第一步(ls + 读 docs)。不要假设一个项目的 docs 改了,另一个就不用。尤其是上游-下游对接文档(集成指南 / SDK 说明 / API 协议),两边都要对齐。
发现之前的同步漏了东西:修掉。不要说"那不是这次对话的事"——你就是这个项目的持续编辑,过去的漏洞也归你管。
参考资料
- references/sync-matrix.md — 完整的"变更类型 → 要改哪些文件"映射表
- references/agent-paths.md — Claude Code / Codex / OpenCode 各自的记忆与配置路径速查
Related skills
More from kkkkhazix/khazix-skills and the wider catalog.

storage-analyzer
>

aihot
Real-time Chinese AI news and industry updates from aihot.virxact.com via public API.

hv-analysis
Systematic horizontal-vertical analysis for deep research on products, companies, concepts, and people.

khazix-writer
Write WeChat public account long-form articles in Khazix's distinctive voice—curious, authentic, and deeply human.

kling-cli
>-

mcp2cli
Turn any MCP server, OpenAPI spec, or GraphQL endpoint into a CLI. Use this skill when the user wants to interact with an MCP server, OpenAPI/REST API, or GraphQL API via command line, discover available tools/endpoints, call API operations, or generate a new skill from an API. Triggers include "mcp2cli", "call this MCP server", "use this API", "list tools from", "create a skill for this API", "graphql", or any task involving MCP tool invocation, OpenAPI endpoint calls, or GraphQL queries without writing code.