agentleFS
chengkj99chengkj99/kj-skills/skills/wiki-intelligence/SKILL.md

wiki-intelligence

Skill14 starsChanged 5 months agoMITView on GitHub

Claude Code hook 系统:在发送提示词前自动评估质量(好提示词存入 wiki,差提示词给出建议), 回答结束后分析对话价值并引导知识沉淀。适用于任何基于 Markdown 的个人知识库。

  • Installs packages

The file

Files
SKILL.md

Wiki Intelligence

一套轻量 Claude Code hook,让每次对话都能为知识库增值。

功能

时机行为
发送提示词前(UserPromptSubmit)识别高价值意图 → 调用 AI 评分 → 低分给出改进建议;高分静默收藏到 wiki
回答结束后(Stop)分析对话价值 → 高分输出要点摘要 → 引导「确认沉淀」
会话开始(SessionStart)清理 24h 过期的会话状态文件

安装

# 1. 克隆 kj-skills(或已有则跳过)
git clone https://github.com/your-org/kj-skills.git

# 2. 一键安装
bash kj-skills/skills/wiki-intelligence/install.sh

# 3. 设置 wiki 路径
vim ~/.claude/wiki-intelligence.config.json
# 修改 "wiki_path" 为你的 wiki 绝对路径

# 4. 重启 Claude Code 生效

配置

唯一配置文件:~/.claude/wiki-intelligence.config.json

字段默认值说明
wiki_path(必填)wiki 仓库根目录(支持 ~)
quality_threshold7提示词分数 ≥ 此值则收藏
knowledge_threshold6对话分数 ≥ 此值则提示沉淀
high_value_intents见示例触发质量检查的关键词列表
analysis_modelclaude-haiku-4-5-20251001用于分析的模型(影响成本)
enabledtrue全局开关
prompt_check_enabledtrue提示词质量检查开关
knowledge_capture_enabledtrue知识沉淀捕获开关
prompt_collection_enabledtrue好提示词自动收藏开关
prompt_collection_pathwiki/playbooks/promptswiki 内的提示词存储路径(相对)
min_prompt_length20短于此字符数的提示词跳过检查

Wiki 目录约定

好提示词写入 {wiki_path}/{prompt_collection_path}/ 下按意图分类:

wiki/playbooks/prompts/
├── design.md      # 设计/架构类
├── analysis.md    # 分析/研究类
├── planning.md    # 规划/方案类
└── general.md     # 其他

知识沉淀(「确认沉淀」触发)由 Claude 侧规则处理写入,hooks 只负责分析与提示。

运行测试

# 跳过需要 claude -p 的集成测试(在 Claude Code 内部运行时使用)
WI_SKIP_CLAUDE_TESTS=1 bash tests/test-wiki-intelligence.sh

# 完整测试(在 Claude Code 外部运行)
bash tests/test-wiki-intelligence.sh

文件结构

hooks/
├── prompt-quality.sh         # UserPromptSubmit hook
├── knowledge-capture.sh      # Stop hook
├── session-start-cleanup.sh  # SessionStart hook
└── lib/
    ├── wiki-intelligence.sh  # 分析引擎(共享库)
    └── wiki-writer.sh        # Wiki 写入工具
tests/
└── test-wiki-intelligence.sh
wiki-intelligence.config.example.json
install.sh

依赖

  • jq — JSON 解析(brew install jq)
  • python3 — 解析对话记录(macOS 自带)
  • claude CLI — AI 分析子进程(Claude Code 自带)

交付前自检

  • 运行 WI_SKIP_CLAUDE_TESTS=1 bash tests/test-wiki-intelligence.sh 并确认退出码为 0;在 Claude Code 外部改动时再跑一次不带跳过变量的完整测试。
  • 对照「文件结构」一节核验:hooks/ 下 prompt-quality.sh、knowledge-capture.sh、session-start-cleanup.sh 与 hooks/lib/ 下两个共享库均存在且可执行。
  • 运行 jq . ~/.claude/wiki-intelligence.config.json 确认配置是合法 JSON 且退出码为 0,wiki_path 指向真实存在的目录。
  • 确认好提示词只写入 {wiki_path}/{prompt_collection_path}/ 下的分类文件(design.md / analysis.md / planning.md / general.md),未写到 wiki 目录之外。
  • 若改动了 hook 行为或新增配置字段,确认本文件「配置」表与「文件结构」段已同步更新。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.