agentleFS
wo-owo-o/claude-code-toolkit/skills/knowledge-graph-builder/SKILL.md

knowledge-graph-builder

Skill1 starsChanged 7 months agoMITView on GitHub

Match yesterday's Slack threads against yesterday's Notion page edits, score similarity, and bidirectionally link strong matches — Slack thread gets a bot reply citing the related Notion page; Notion page gets a "Related discussions" section with the Slack permalink. Designed for daily 18:00 launchd cron with a strict precision threshold to avoid noise.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Default mode does not need a canonical resource — it writes cross-references back into the matched Slack threads and Notion pages directly.

    line 35
  2. Very specific:

    Keep only matches with score ≥ --threshold.

    line 91
  3. Distinctive:

    If the section does not exist, create it as a heading_2 + bulleted_list_item

    line 106
  4. Distinctive:

    Never claim "this is the official decision page" — the skill links related material, it does not adjudicate authority

    line 148

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

knowledge-graph-builder

Same topic, two homes — and the homes do not know each other. The Notion page "API auth design" sits next to a separate Slack thread debating the same decision; new hires see only one side. Hand-linking is a willpower problem nobody wins. This skill closes the loop automatically: every evening it scans the day's Slack threads and Notion edits, finds high-confidence matches, and inserts cross-references on both sides. False positives are the entire risk model — so the skill defaults to high-precision matching and never auto-links low-confidence pairs.

Zero-config: in default mode the skill writes cross-references back into the Slack threads and Notion pages it matched, so no canonical resource is needed. In --review-mode, it auto-resolves the parent page "Knowledge Graph Review" and creates a daily child page underneath it — see docs/auto-resolve.md. Slack channels are auto-derived from the day's thread activity when not specified.

Input

  • --since YYYY-MM-DD (optional, defaults to yesterday 00:00 KST) — earliest message/edit to consider
  • --slack-channels <comma-separated> (override only — defaults to auto-derived from observed thread activity. Env override: CLAUDE_CODE_TOOLKIT_KG_CHANNELS)
  • --notion-workspace <id> (override only — defaults to whole-account search scope. Env override: CLAUDE_CODE_TOOLKIT_KG_WORKSPACE)
  • --threshold N (optional, default 0.75) — minimum similarity score (0.0~1.0) to auto-link
  • --review-mode (optional flag) — output match candidates to a Notion review page instead of writing cross-references directly. Recommended for the first 1-2 weeks

Output

2026-04-27 (since 2026-04-26): scanned T threads · P pages → M strong matches (≥0.75) → L bidirectional links written
- Auto-linked: <count>
- Below threshold (skipped): <count>
- Review-mode page: <Notion URL> (when --review-mode is set)

Procedure

1. Parse input

  • --since missing → yesterday 00:00 KST
  • Slack channels: when missing, default to auto-derived from observed thread activity (mentions / cross-references). On large workspaces, pass --slack-channels to limit scope explicitly. Env override: CLAUDE_CODE_TOOLKIT_KG_CHANNELS.
  • Default mode does not need a canonical resource — it writes cross-references back into the matched Slack threads and Notion pages directly.
  • --review-mode only: auto-resolve the parent page "Knowledge Graph Review" via the algorithm in docs/auto-resolve.md (cache-first, fall through to notion-search with type=page). The skill creates a daily child page named Knowledge Graph Review — YYYY-MM-DD under it. Override: edit ~/.claude-code-toolkit/auto-resolve.json directly.
  • --threshold clamped to [0.6, 1.0]; below 0.6 the false-positive rate becomes unacceptable

2. Collect Slack threads

Invoke slack-scout once per channel with the --since window. Then, for each thread surfaced (≥3 messages, ≥2 distinct authors), call mcp__claude_ai_Slack__slack_read_channel with the thread ts to fetch full replies.

Skip threads with <3 messages or single-author monologues — those rarely produce decision content worth cross-linking.

3. Collect Notion page edits

Invoke notion-scout with a custom prompt:

description: "Recent Notion edits scout"
subagent_type: "notion-scout"
prompt: |
  Search Notion for pages whose last_edited_time is within the window 2026-04-26 ~ 2026-04-27.
  Limit to the top 30 most-recently-edited.
  For each page, fetch title + the first 500 characters of the body.
  Output the standard format.

4. Build matching features

For each Slack thread:

  • Extract noun phrases, project codenames, ALL_CAPS abbreviations, URLs
  • Compute a bag-of-features signature

For each Notion page:

  • Extract the same features from title + body excerpt
  • Compute the same signature

5. Score matches (LLM-assisted)

For each (thread, page) candidate pair where the bag-of-features overlap is ≥30%, call the LLM with a focused prompt:

Compare this Slack thread to this Notion page. Output a similarity score 0.0~1.0 plus 1-line rationale.

Score 1.0 = same topic, same scope, same decision being recorded
Score 0.7~0.9 = same topic, partial overlap (e.g. thread is a debate, page is the decision)
Score 0.4~0.6 = related but different scope (thread mentions the topic in passing)
Score below 0.4 = coincidence

Be conservative — when in doubt, score lower.

Slack thread: <thread summary>
Notion page: <title> + <body excerpt>

This LLM step is the core of precision — do not skip it. Pure embedding distance over-merges.

6. Filter by threshold

Keep only matches with score ≥ --threshold. Discard the rest.

7. Write cross-references (or review-mode output)

Default mode — for each surviving match, write both directions:

  • Slack: post a thread reply via mcp__claude_ai_Slack__slack_send_message (in-thread, as a bot) with text:
    📚 Related Notion: <page title> — <URL>
    Reply with :x: to remove this suggestion.
  • Notion: update the page via mcp__claude_ai_Notion__notion-update-page, appending to a "Related discussions" section a bullet:
    - <YYYY-MM-DD> #<channel> thread — <permalink>
    If the section does not exist, create it as a heading_2 + bulleted_list_item

--review-mode — instead of writing, append match candidates to a Notion review page (Knowledge Graph Review — YYYY-MM-DD) with score + rationale + both URLs. The operator manually applies (or rejects) the links. Use this for the first 1-2 weeks to calibrate the threshold.

Hook behavior: the plugin's PreToolUse(mcp__claude_ai_Notion__notion-update-page) and PreToolUse(mcp__claude_ai_Slack__slack_send_message) hooks fire — Slack post is never bypassed even in cron mode (a wrong public bot reply is not silently recoverable). Notion updates can be bypassed with CLAUDE_CODE_TOOLKIT_CRON_MODE=1 after the first successful run signs off the threshold; audit log lives at ~/.claude-code-toolkit/audit/knowledge-graph-YYYY-MM-DD.jsonl.

8. Output

Print the one-line console summary + (if review-mode) the review page URL. Done.

Automated operation (cron)

Recommended launchd cron at daily 18:00 KST:

# ~/Library/LaunchAgents/<reverse-domain>.claude-code-toolkit.knowledge-graph.plist
# Program: /usr/local/bin/claude
# ProgramArguments: -p "/claude-code-toolkit:knowledge-graph-builder"
# StartCalendarInterval: { Hour=18, Minute=0 }
# EnvironmentVariables:
#   CLAUDE_CODE_TOOLKIT_CRON_MODE=1
#   # Optional — only set if you want to override auto-resolve
#   CLAUDE_CODE_TOOLKIT_KG_CHANNELS=#eng,#product,#design,#research
#   CLAUDE_CODE_TOOLKIT_KG_WORKSPACE=<id>

For the first 1-2 weeks, run with --review-mode (interactive only) to validate match quality. Switch to direct write only after the precision is verified.

Pitfalls

  • False positives are catastrophic: a wrong "Related Notion" reply on a public Slack thread is visible to everyone. Never lower the threshold below 0.6, and prefer --review-mode for the first runs
  • LLM scoring drift: the same pair scored at different times can vary by ±0.1. When near the threshold, prefer not-linking
  • Notion edits storm: API rate limits trigger on >20 update_page calls in a minute. Cap at 15 links per run; queue the rest for the next day
  • Slack bot post permission: chat:write scope must be approved by the workspace admin. Without it, only the Notion side can be written — print this asymmetry in the output
  • Thread author dislikes the bot reply: respect a :x: reaction by the thread author or the OP — track via a dedupe ledger to avoid re-posting the same suggestion the next day
  • Page → page linking is out of scope: Notion-to-Notion knowledge graph is a separate skill (see roadmap). This skill only crosses Slack ↔ Notion

Tone

  • The Slack reply is a single line + footer. No rationale, no scoring exposed to readers
  • The Notion bullet is a permalink with a date — no editorial summary
  • "Speculative" wording is welcome in the review-mode page (when score is borderline)
  • Never claim "this is the official decision page" — the skill links related material, it does not adjudicate authority

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.