Command Guide
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
Version: 0.5.2 | Updated: 2026-04-22
Claude Code only: The
/kmgraph:prefix requires Claude Code with this plugin installed. Other IDEs access equivalent functionality through MCP tools โ see INSTALL.md for platform-specific setup.
About Commands on Other Platformsโ
These commands are designed as reference documentation for any LLM:
- Claude Code: Invoke as slash commands (e.g.,
/kmgraph:capture-lesson) - Other platforms: Copy the command prompt into your LLM. Substitute
${CLAUDE_PLUGIN_ROOT}with your actual project path - No-tool LLMs: Commands serve as workflow documentation โ follow steps manually
Commands work across platforms, but full automation is Claude Code-specific.
Quick Navigationโ
- I Want To... โ Task-based command finder
- Essential Commands โ Start here
- Intermediate Commands โ Daily use
- Advanced Commands โ Power features
- Command Comparison โ When to use which
- Troubleshooting โ Common problems and fixes
- Related Documentation โ Links to other guides
I Want To...โ
Getting Startedโ
- Set up a new knowledge graph โ
/kmgraph:init - See what's in my knowledge graph โ
/kmgraph:status - Document what I just learned โ
/kmgraph:capture-lesson - Find something I documented before โ
/kmgraph:recall "search query"
Daily Useโ
- Sync lessons to the knowledge graph โ
/kmgraph:update-graph - Summarize this conversation โ
/kmgraph:session-summary - Add a new category (e.g., security, ml-ops) โ
/kmgraph:add-category - See my chat history โ
/kmgraph:extract-chat - Update plugin documentation โ
/kmgraph:update-doc --user-facing
Team Collaborationโ
- Share knowledge safely โ
/kmgraph:config-sanitization - Check for sensitive data before sharing โ
/kmgraph:check-sensitive - Link lessons to GitHub issues โ
/kmgraph:link-issue
Project Transitions & Onboardingโ
- Create comprehensive handoff documentation โ
/kmgraph:handoff - Set up for new developer โ
/kmgraph:setup-platform
Note: The term "issues" in this guide refers to GitHub Issues โ a platform feature for tracking bugs, feature requests, and enhancements. This is distinct from "knowledge graph issues" (meta-issues) or "lessons learned issues" (problems documented in the KG).
Working with Multiple Knowledge Graphsโ
- View all configured knowledge graphs โ
/kmgraph:list - Switch to a different knowledge graph โ
/kmgraph:switch
Complex Problem Trackingโ
- Track a multi-attempt bug โ
/kmgraph:meta-issue - Start structured issue tracking with documentation and Git branch โ
/kmgraph:start-issue-tracking - Sync progress to plans and GitHub โ
/kmgraph:update-issue-plan
Memory Managementโ
- Run the full sync pipeline in one command โ
/kmgraph:sync-all
Browse Commands by Categoryโ
Get the knowledge graph running and configure how it works.
-
๐ข
/kmgraph:initโ Initialize a new knowledge graph -
๐ก
/kmgraph:init-personal-kgโ Create personal KG for cross-project lessons -
๐ก
/kmgraph:listโ View all configured knowledge graphs -
๐ก
/kmgraph:switchโ Switch to a different knowledge graph -
๐ก
/kmgraph:add-categoryโ Add custom categories -
๐ก
/kmgraph:config-sanitizationโ Set up safety features for team sharing
Document lessons, capture history, and summarize sessions.
-
๐ข
/kmgraph:capture-lessonโ Capture problems solved and patterns discovered -
๐ก
/kmgraph:extract-chatโ Export chat history to markdown -
๐ก
/kmgraph:session-summaryโ Summarize important work sessions
Find knowledge and keep the graph synchronized.
-
๐ข
/kmgraph:statusโ Check current knowledge graph status -
๐ข
/kmgraph:recallโ Search across all knowledge entries -
๐ก
/kmgraph:update-graphโ Extract lessons into knowledge graph -
๐ก
/kmgraph:update-docโ Update documentation with changes -
๐ด
/kmgraph:sync-allโ Run complete synchronization pipeline
Share knowledge safely with team members.
-
๐ก
/kmgraph:check-sensitiveโ Scan for sensitive data before sharing -
๐ด
/kmgraph:link-issueโ Connect lessons to GitHub issues
Track complex, multi-attempt problems systematically.
-
๐ด
/kmgraph:meta-issueโ Track multi-attempt bugs and features -
๐ด
/kmgraph:start-issue-trackingโ Systematic issue tracking with Git branches -
๐ด
/kmgraph:update-issue-planโ Sync progress with GitHub and plans
Essential Commandsโ
๐ข /kmgraph:initโ
Purpose: Set up a structured knowledge management system for the active project. Lessons, decisions, and patterns land in a searchable, git-tracked knowledge graph so nothing valuable gets lost between sessions.
When to use:
- First time setup on any project
- Starting a new project that needs its own knowledge graph
- Creating a separate KG for different work (e.g., personal vs. team)
- After a plugin update โ verify/upgrade existing KG to current version
What it does:
- Asks for KG name and storage location (project-local, personal, or custom path)
- Prompts for category selection (architecture, process, patterns, debugging, or custom)
- Asks for optional custom prefixes per category
- Creates directory structure (
knowledge/,lessons-learned/,decisions/,sessions/,chat-history/) - Copies templates from the plugin
- Offers to create a personal KG at
~/.kmgraph/for cross-project lessons (see/kmgraph:init-personal-kg) - Optionally backfills from existing project context (README, CHANGELOG, lessons, decisions, chat history)
- Optionally installs a git post-commit hook for lesson capture suggestions
- Updates
.gitignorebased on chosen git strategy - Registers the KG in
~/.claude/kg-config.jsonand sets it as active
Time: 2-3 minutes
Example:
/kmgraph:init
# Claude asks:
# - What should this knowledge graph be called?
# - Where should it be stored? (project-local / personal / custom)
# - Which categories do you want to include?
# - Would you like to backfill from existing project context? (y/N)
# (If yes: scans README, CHANGELOG, lessons-learned/, decisions/, chat-history/)
# - Install post-commit hook? (y/n)
# - Git strategy for each category? (commit/ignore)
Backfill Feature: When you enable backfill, the system extracts existing knowledge from your project:
- README.md โ Project overview and key concepts
- CHANGELOG.md โ Released features and changes
- lessons-learned/ โ Existing lessons (if any)
- decisions/ โ Architecture Decision Records
- chat-history/ โ Extracted chat logs
The system presents candidates for your review before creating entries.
After backfill: If backfill was used, the knowledge graph now contains a full set of imported content. This is a good time to build the search index so all that content is immediately searchable by relevance. Run /kmgraph:sync-all and accept the index prompt, or call kg_fts5_rebuild directly from the MCP tool panel.
Next steps: Run /kmgraph:status to verify setup
Model tier configuration: As of v0.5.x, init also walks through the model tier system. Tier labels (fast-tier, standard-tier, powerful-tier) replace hardcoded model names (Haiku, Sonnet, Opus and their Gemini equivalents) so rules, commands, and agents stay stable across model version changes and platforms. During init, a platforms[] block is written to knowledge/me.md with a tier_map entry for each detected platform, binding each tier label to a concrete model name. Locally running Ollama (localhost:11434) and LM Studio (localhost:1234) instances are discovered automatically and offered as additional platforms, with host, port, and per-tier model selection captured in the walkthrough. An alias map translates legacy model names (Haiku, Sonnet, Opus, Flash, Pro) to tier labels for backwards compatibility, and unrecognized model names trigger a one-time prompt to assign the name to a tier before dispatch continues.
๐ก /kmgraph:init-personal-kgโ
Purpose: Create a personal knowledge graph at ~/.kmgraph/ for lessons that apply across every project, not just the current one. capture-lesson gains a KG picker and recall searches both automatically.
When to use:
- After running
/kmgraph:initand skipping the personal KG offer - When you want a dedicated place for workflow lessons, cross-project gotchas, and personal ADRs that apply across all projects, not just the current one
What it does:
- Creates
~/.kmgraph/with standard directory structure - Registers it as
type: "personal"with name"personal"in~/.claude/kg-config.json - Copies knowledge templates (patterns, gotchas, concepts)
- Builds FTS5 search index for the new KG
- Does not change the active KG โ project KG remains active
After setup:
/kmgraph:capture-lessonshows a KG picker when โฅ2 KGs are registered/kmgraph:recallsearches both project and personal KGs automatically
Example:
/kmgraph:init-personal-kg
# Claude creates ~/.kmgraph/
# Registers "personal" KG (type: personal) in config
# Active KG unchanged
Related: See Personal vs Project Knowledge for when to use each.
Cross-Reference Formatting (Wiki Links)โ
When you run /kmgraph:init (Step 1f.2) or /kmgraph:init-personal-kg (Step 8.1), the system automatically converts cross-references in your knowledge graph to Obsidian wiki link format for seamless navigation in compatible editors.
Supported Formatsโ
The wiki pass applies these auto-linkification patterns:
- Enhancements:
[[ENH-NNN]](e.g.,[[ENH-010]]) - Architecture Decisions:
[[ADR-NNN-full-title]](e.g.,[[ADR-028-postgres-over-mongodb]]) - Lessons Learned:
[[Lessons_Learned_X]](e.g.,[[Lessons_Learned_5]]) - GitHub Issues:
[#NNN](url)format (automatically applied when linking via/kmgraph:link-issue)
When Links Are Appliedโ
- During initial
/kmgraph:initsetup (Step 1f.2: "Apply Obsidian wiki link formatting to cross-references") - During
/kmgraph:init-personal-kg(Step 8.1: "Applying wiki pass to personal KG") - Only once โ controlled by the
wiki_pass_completeconfig flag to avoid re-running on subsequent setups
Preview Changes with --dry-runโ
To preview what links will be created without applying them:
/kmgraph:init --dry-run
The --dry-run mode shows which files will be modified and what cross-references will be converted, without writing any changes.
Scope & Limitationsโ
- 5 legacy lesson files without the
Lessons_Learned_prefix are excluded from auto-linking (e.g.,lesson-1.md,debug-tip.md). Manual cross-references to these files still work โ they are fully searchable and accessible. - Lesson files created after v0.3.3 automatically follow the
Lessons_Learned_Xnaming convention and are auto-linked.
Related: For naming conventions and documentation structure, see Style Guide.
๐ข /kmgraph:capture-lessonโ
Purpose: Identifies lessons while context is still fresh and captures both the problem and how it was solved. By automatically linking lessons to relevant metadata, the record is searchable and reusable across future sessions and projects.
Command refactored in v0.2.1-beta: 710 โ 108 lines. Execution logic delegated to
agents/for platform portability. See CONCEPTS.md ยง Four-Layer Architecture.
When to use:
- Just solved a problem
- Discovered a reusable pattern
- Fixed a tricky bug worth remembering
- Learned something that future you will need
What it does:
- {OPTIONAL} Prompts to take a session snapshot before starting to preserve the context at the moment of discovery
- Checks for duplicate or similar existing lessons in the existing knowledge graph before proceeding
- Asks verification questions to confirm topic, audience, and scope
- Auto-detects the category from keywords in the lesson content
- Captures git context for the record โ branch, commit, PR, and issue number automatically
- Wizard captures the following:
- problem
- root cause
- solution
- prevention
- Creates the lesson file from the standard template with all fields populated
- Updates category and chronological indexes
- {OPTIONAL} Runs
/kmgraph:update-graphto extract KG entries from the new lesson - {OPTIONAL} Links to a GitHub Issue via
/kmgraph:link-issue
Time: 5-10 minutes (faster with practice)
Example:
/kmgraph:capture-lesson # โ active KG
/kmgraph:capture-lesson "user level" # โ personal KG (~/.kmgraph/)
/kmgraph:capture-lesson --project # โ current project's KG
/kmgraph:capture-lesson --named=career-ops # โ career-ops KG
# Agent guides you through:
# 1. What problem did you encounter?
# 2. What was the root cause?
# 3. How did you solve it?
# 4. How can this be prevented?
Tips:
- Capture while the problem is fresh (don't wait)
- Include error messages verbatim
- Note what DIDN'T work (helps future you)
- Level routing: use "user level" for cross-project patterns; "for this project" for codebase-specific lessons. See Personal vs Project KGs for details.
- If the active KG differs from the project's own KG, the command stops before writing and asks which graph to use
๐ข /kmgraph:statusโ
Purpose: Show the health and contents of the active knowledge graph at a glance. File counts, sync timestamps, staleness warnings, and a quick command reference, all without leaving the conversation.
When to use:
- Verify setup after running
/kmgraph:init - See recent lessons at a glance
- Check profile file staleness (
~/.kmgraph/rules.md,~/.kmgraph/me.md) - Quick health check on the knowledge graph
What it shows:
- Active KG name and file path
- Categories and git strategy
- Last sync timestamp
- File counts (lessons, KG entries, ADRs, sessions)
- Warnings (stale profile files, missing paths)
- Quick command reference for common next steps
Time: Instant
Example output:
Knowledge Graph Status
โโโโโโโโโโโโโโโโโโโโโ
Active KG: my-project
Location: /Users/name/projects/my-app/docs/
Categories: architecture, process, patterns, debugging
Git: selective (architecture/patterns committed, process/debugging gitignored)
Last sync: 2026-02-12 15:45
Stats:
Lessons: 12 (3 new since last sync)
KG Entries: 28 patterns, 6 concepts, 4 gotchas
ADRs: 5
Sessions: 8
Quick Commands:
/kmgraph:capture-lesson โ Document a lesson
/kmgraph:recall "query" โ Search across all KG
/kmgraph:sync-all โ Run full sync pipeline
Tips: Use the flags --minimal for a one-line summary and --json for machine-readable output.
๐ข /kmgraph:recallโ
Purpose: Search across lessons, decisions, patterns, and sessions in one command. When a personal KG is registered, both knowledge graphs are searched automatically, with source labels on every result.
Command refactored in v0.2.1-beta: 437 โ 79 lines. Execution logic delegated to
agents/for platform portability. See CONCEPTS.md ยง Four-Layer Architecture.
When to use:
- "I solved this before..."
- Looking for a specific pattern or solution
- Need to find a past architectural decision
- Searching for context on a topic
What it searches:
Dispatches to the recall agent, which searches:
- Lessons learned (full text)
- Architecture decisions (ADRs)
- Knowledge entries (patterns, gotchas, concepts)
- Session summaries
- Profile files (
~/.kmgraph/rules.md,~/.kmgraph/me.md,knowledge/rules.md,knowledge/me.md) - Personal KG (if registered) โ automatically included when a personal KG exists
Multi-KG behavior: When a personal KG is registered, recall searches both project and personal KGs by default. Results include a source label ([project] or [personal]) so origin is always clear.
Time: 1-2 seconds (single KG); 2-4 seconds (multi-KG with FTS5)
Example:
/kmgraph:recall "database timeout"
/kmgraph:recall "auth patterns" --scope=all
/kmgraph:recall "workflow patterns" --scope=personal-only
# Multi-KG result format:
# Lessons Learned (3 matches)
# 1. Debugging PostgreSQL Connection Timeouts โ [project: my-project]
# 2. Connection Pool Best Practices โ [project: my-project]
# 3. Database Timeout Patterns โ [personal: personal]
--scope parameter:
| Value | Behavior |
|---|---|
active | Active KG only (original behavior) |
all | Active KG + all registered KGs (auto-default when personal KG exists) |
personal-only | Only KGs with type: personal |
Level routing: Scope search to a specific KG without changing the active KG:
| Flag / Natural Language | Searches |
|---|---|
--user / "user level" | Only ~/.kmgraph/ |
--project / "for this project" | Only current project's KG |
--named=<kg> / KG name | Only the named KG |
/kmgraph:recall "auth patterns" --user # personal KG only
/kmgraph:recall "database timeout" --project # current project only
/kmgraph:recall "deployment" --named=devops-kg # named KG only
Search tips:
- Use specific terms ("PostgreSQL timeout" > "database")
- Try synonyms if nothing found
- Search by date:
/kmgraph:recall "2024-01" - Search by category:
/kmgraph:recall "architecture" - Output formats: default (summary),
--format=paths(file list),--format=detailed(full context) - Scope override:
--scope=activeto restrict to project KG only
Intermediate Commandsโ
๐ก /kmgraph:update-graphโ
Purpose: Takes individual lessons learned and adds them directly into the knowledge graph's searchable index. Lessons hold the full narrative; update-graph makes patterns findable in seconds, not minutes.
When to use:
- After creating or updating lesson-learned documents
- When discovering new patterns or best practices
- Before completing complex work sessions
- Daily or weekly consolidation of captured knowledge
What it does:
- Identifies new or modified lessons (since last sync or last 24 hours)
- Reads each lesson and extracts: title, problem, solution, when-to-use triggers
- Checks if a matching KG entry already exists in
knowledge/patterns.md(or similar) - Creates new entries or updates existing ones with bidirectional links
- Runs data integrity audit on each new entry
- Commits KG changes
Time: 1-5 minutes depending on number of lessons
Example:
/kmgraph:update-graph
/kmgraph:update-graph --lesson=Pattern_Discovery.md # Process specific lesson
/kmgraph:update-graph --auto # Skip prompts, silent mode
/kmgraph:update-graph --interactive # Review each entry before saving
Tips:
--autoflag is useful when called from other commands (e.g., after/kmgraph:capture-lesson)--interactiveflag lets you review and edit each extracted entry before saving
Cleaner conversations: When the context-mode plugin is installed and there are 10 or more lessons to process, update-graph reads the lesson files in a background process instead of inline. This keeps the conversation cleaner without changing any results. Falls back automatically if context-mode is not installed.
๐ก /kmgraph:add-categoryโ
Purpose: Add a new category to the active knowledge graph. Creates the directory structure, index file, and git strategy in one step, so the new category is ready to capture lessons immediately.
When to use:
- Need to track a new domain (e.g., security, ml-ops, devops)
- Team-specific categorization needed beyond defaults
- Organizing lessons into more granular groups
What it does:
- Prompts for category name (or accepts from command argument)
- Asks for optional prefix (e.g., "sec-" for security lessons)
- Asks for git strategy (commit or ignore)
- Creates
lessons-learned/[category]/directory - Creates
knowledge/[category].mdKG entry file from template - Updates
kg-config.jsonwith the new category - Updates
.gitignoreif git strategy is "ignore"
Time: Under 1 minute
Example:
/kmgraph:add-category
/kmgraph:add-category security
/kmgraph:add-category ml-ops --prefix ml- --git ignore
Next steps: Capture lessons in the new category with /kmgraph:capture-lesson
๐ก /kmgraph:session-summaryโ
Purpose: Capture session context on demand and store it in a dated markdown file before it is lost. The dated file is a reliable record of what happened, so any future session can reference it.
When to use:
- Before context limits are reached (~180K tokens)
- At major milestones during long sessions
- Before handing work to another developer
- End of a productive work session to preserve context
What it does:
- Auto-detects session scope from conversation context since last summary
- Classifies session type (feature development, debugging, planning, research)
- Generates two zones: an Operational Snapshot (Current State, Open Issues, Session History, Session Findings) overwritten on each run, and an Accumulated Narrative appended chronologically
- One file per day per branch โ subsequent runs update the same file; Operational Snapshot sections are overwritten, narrative blocks are timestamped and preserved
- Saves to
{active_kg_path}/sessions/YYYY-MM-DD-{branch-slug}.md - Optionally triggers lesson capture and KG update
Snapshot mode (--snapshot): Lightweight mid-session capture. Runs before any capture command when the user opts in. Appends to today's session file (or creates one) without a user review gate. Optional git history (--snapshot --git). Used by capture-lesson, create-adr, and start-issue-tracking to preserve the "why" at the moment of discovery.
Time: Under 10 seconds (full mode); under 5 seconds (snapshot mode without git)
Example:
/kmgraph:session-summary # โ active KG
/kmgraph:session-summary --auto # Skip confirmation, save immediately
/kmgraph:session-summary --snapshot # Mid-session save without review gate
/kmgraph:session-summary "user level" # โ personal KG (~/.kmgraph/sessions/)
/kmgraph:session-summary --project # โ current project's KG sessions/
/kmgraph:session-summary --named=career-ops # โ career-ops KG sessions/
Tips:
- Captures git commits automatically โ no need to list them manually
- Auto-suggests summary when context approaches ~180K tokens
- Run before creating a handoff โ START-HERE.md auto-detects today's summary and links it via
continues_from
๐ก /kmgraph:create-adrโ
Purpose: Create strategic Architectural Decision Records (ADRs) that capture why decisions were made. Records are auto-populated with git metadata, sequential numbering, and the implementation commit, so the history is traceable without manual bookkeeping.
When to use:
- Making a significant architecture, process, or technology decision
- Choosing between competing approaches and want to document the rationale
- After a decision has already been made and needs to be formally recorded
- When a lesson learned reveals a decision that should be captured as an ADR
What it does:
- {OPTIONAL} Before capturing ADR, prompt will ask whether or not to take a snapshot of the current session before starting to preserve an archive of the context behind the decision
- Reviews the current ADR items in the active knowledge graph
- Assigns the next ADR number automatically
- Captures git context for the record โ author, branch, and PR/issue number automatically
- Wizard starts to capture the following:
- title
- status
- category
- context
- decision
- rationale
- consequences
- related lessons
- [NEW in v0.5.2] Asks if the decision has already been implemented โ if yes, captures the current commit and subject line automatically; design-first ADRs get a back-fill reminder
- Shows a full summary for review before writing anything
- Creates the ADR file from the standard template with all fields populated
- Updates the decisions index (count, chronological list, by-category)
- Commits both files with a structured commit message
Time: 5-15 minutes (depends on how much detail you provide)
Example:
/kmgraph:create-adr # โ active KG
/kmgraph:create-adr "Use PostgreSQL for primary database" # Pre-fills title
/kmgraph:create-adr "Prefer TypeScript strict mode" --user # โ personal KG decisions/
/kmgraph:create-adr "Use Redis caching" --project # โ current project decisions/
Tips:
- Pass a title as an argument to skip the first wizard prompt
- Use Proposed status for decisions still under review; Accepted for decisions already implemented
- Link to related lessons in Step 3.8 โ creates bidirectional traceability
- If a snapshot was taken earlier in the session, the ADR's Context section can draw from it
- If the active KG differs from the project's own KG, the wizard stops before writing and asks which graph to use
๐ก /kmgraph:listโ
Purpose: Display all knowledge graph projects registered locally. Useful when working across multiple projects and the exact KG name needs to be identified before switching.
When to use:
- View all available knowledge graphs
- Check which KG is currently active
- Review KG configurations before switching
- Verify a new KG was created successfully
What it shows:
- All configured knowledge graphs with numbered list
- Active KG highlighted
- Location paths, categories, git strategy, last used timestamp
- Total count
Time: Instant
Example output:
Knowledge Graphs:
1. my-project (active) โ /Users/name/projects/my-app/docs/
Categories: architecture, process, patterns
Git: selective (architecture/patterns committed, process gitignored)
Last used: 2026-02-13 15:45
2. ai-research โ ~/.claude/knowledge-graphs/ai-research/
Categories: architecture, process, ml-patterns (custom)
Git: all committed
Last used: 2026-02-10 12:00
Total: 2 knowledge graph(s) configured
Tip: Use --names-only for scripting or --json for machine-readable output.
๐ก /kmgraph:switchโ
Purpose: Switch the active knowledge graph so all subsequent commands read from and write to the intended one.
When to use:
- Switch between different project knowledge graphs
- Change to a topic-based KG for cross-project patterns
- Return to a previously used KG
What it does:
- Validates the target KG exists in config
- Verifies KG path exists on disk (warns if missing, allows override)
- Updates the
activefield in~/.claude/kg-config.json - Updates
lastUsedtimestamp - Reports previous and new active KG
Time: Instant
Example:
/kmgraph:switch my-project
/kmgraph:switch ai-research
/kmgraph:switch cowork-devops --force # Skip missing path warning
Tips:
- All subsequent knowledge commands operate on the newly active KG
- Use
/kmgraph:listfirst to see available options
๐ก /kmgraph:check-sensitiveโ
Purpose: Scan the active knowledge graph for emails, API keys, and internal URLs before pushing to a shared repository. Flags findings with file name and line number for manual review.
When to use:
- Before pushing knowledge graph files to a public or shared repository
- As a manual check alongside
/kmgraph:config-sanitizationhooks - Periodic audit of KG content
What it does:
- Loads scan patterns from
.claude/sanitization-config.json(or uses defaults) - Scans all markdown files in the active KG for: email addresses, API keys/tokens, URLs
- Reports findings with file name, line number, and matched content
- Optionally shows fix suggestions with
--fix-suggestionsflag
Time: Under 5 seconds
Example:
/kmgraph:check-sensitive
# Output:
# โ ๏ธ Potential sensitive data found:
#
# - patterns.md:42 โ email: user@example.com
# - debugging-auth.md:15 โ URL: https://api.internal.company.com
# - lesson-template.md:8 โ api-key: API_KEY=abc123def456
#
# Review these entries before pushing to public repository.
๐ก /kmgraph:config-sanitizationโ
Purpose: Run a one-time wizard to automatically flag sensitive data before every commit is saved. Configures scan patterns, custom regexes, and enforcement level in 2-3 minutes.
When to use:
- One-time setup per repository for automated security scanning
- When team members need consistent sanitization enforcement
What it does:
- Prompts for scan patterns (emails, API keys, personal names, internal URLs)
- Collects custom regex patterns specific to your project
- Asks for action on match (warn or block commit)
- Installs a pre-commit hook script to
.git/hooks/pre-commit - Creates
.claude/sanitization-config.jsonwith selected configuration
Time: 2-3 minutes
Example:
/kmgraph:config-sanitization
# Wizard asks:
# 1. What should be scanned for? (checkboxes for email, API keys, names, URLs)
# 2. Any custom patterns? (e.g., "ACME Corp", "internal\.company\.com")
# 3. What should happen when found? (1. Warn 2. Block)
# โ Installs hook and creates config
Output:
โ
Pre-commit sanitization hook installed!
Scan patterns: emails, API keys, custom patterns (2)
Action: Block commits with sensitive data
Test the hook:
git add docs/knowledge/patterns.md
git commit -m "test"
๐ก /kmgraph:extract-chatโ
Purpose: Extracts existing local chat history files and stores them within the project as markdown files. Results vary by model and platform; anything beyond Claude may require unsupported configuration.
When to use:
- Preserve chat history for reference or knowledge extraction
- End of day archival of important conversations
- When logs might be cleared by app updates
What it does:
- (Step 0) Checks active KG alignment โ Compares the active KG's project root against the current working directory. On mismatch, stops and asks: switch active KG / proceed to active KG anyway / cancel. Skipped when
--output-diror--projectis present. - Determines output directory (active KG's
chat-history/by default, or custom path) - Scans Claude logs (
~/.claude/projects/for.jsonlfiles), Gemini logs (~/.gemini/tmp/,~/.gemini/antigravity/conversations/for.json/.pbfiles), and/or Codex CLI sessions (~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl) - Merges sessions by date into
YYYY-MM-DD-claude.md,YYYY-MM-DD-gemini.md, and/orYYYY-MM-DD-codex.md - If a daily file exceeds 900 KB or 30,000 lines, automatically splits into numbered parts (
-part1.md,-part2.md, โฆ) inside aYYYY-MM-DD/subfolder to prevent Obsidian rendering failures - Supports incremental append โ re-running adds new sessions without overwriting; appends target the last part file if the day was previously split
Time: Under 30 seconds
Source flags:
-claudeโ Extract only Claude sessions-geminiโ Extract only Gemini sessions--source codexโ Extract only Codex CLI sessions from~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl; outputsYYYY-MM-DD-codex.md--source allโ Extract Claude and Gemini sessions; does not include Codex yet, use--source codexexplicitly
Date filtering options:
--todayโ Extract only today's sessions--date=YYYY-MM-DDโ Extract only sessions from a specific date--after=YYYY-MM-DDโ Extract sessions from this date onwards (inclusive)--before=YYYY-MM-DDโ Extract sessions up to and including this date--project=<fragment>โ Filter to sessions from a specific project (path fragment match)
Example:
/kmgraph:extract-chat # Extract all (Claude + Gemini)
/kmgraph:extract-chat -claude # Extract only Claude
/kmgraph:extract-chat -gemini # Extract only Gemini
/kmgraph:extract-chat --source codex # Extract only Codex CLI sessions
/kmgraph:extract-chat --output-dir=/custom/path # Custom output location
/kmgraph:extract-chat --today # Today only
/kmgraph:extract-chat -claude 2026-02-20 through 2026-02-21 # Date range
/kmgraph:extract-chat --project=knowledge-graph # Specific project only
/kmgraph:extract-chat --source codex --after 2026-01-01 # Codex sessions from a date onwards
Tips:
- Extracted files are automatically searchable via
/kmgraph:recall - Optional
blackboxprotobufPython library enables Gemini protobuf file support - Date ranges use natural language:
YYYY-MM-DD through YYYY-MM-DDorYYYY-MM-DD to YYYY-MM-DD - Gemini date filtering: passthrough implemented; underlying Gemini extraction may have known limitations
- Large days auto-split into a
YYYY-MM-DD/subfolder with numbered part files; each part is a valid standalone markdown file readable in Obsidian
๐ก /kmgraph:update-docโ
Purpose: Maintains this project's user-facing documentation through a guided wizard. Intended primarily for contributors; adapting it to other projects is possible but not yet documented.
When to use:
- A plugin feature changed and COMMAND-GUIDE, CHEAT-SHEET, or README needs updating
- Adding a new command entry to user-facing docs
- Ensuring documentation follows v0.0.7 language standards (third-person, Section 508)
What it does:
Without --user-facing: shows a disambiguation dialog to distinguish plugin documentation from KG content.
With --user-facing:
- Reads target file and displays current sections and version
- Asks what type of update (add command entry, update existing entry, add section, update metadata, validate only)
- Runs v0.0.7 standards validation (third-person voice, heading hierarchy, table headers, link text)
- Shows diff preview before writing
- Applies changes and commits with standards-compliant message
Time: 2-5 minutes
Example:
/kmgraph:update-doc COMMAND-GUIDE.md --user-facing # Update plugin documentation wizard
/kmgraph:update-doc README.md --user-facing # Update README with new feature info
/kmgraph:update-doc some-lesson.md # Disambiguation dialog for KG content
Tips:
- Always use
--user-facingfor plugin/project docs (README, COMMAND-GUIDE, CHEAT-SHEET, etc.) - Without
--user-facing, a dialog clarifies whether the target is plugin docs or KG content - Standards validation runs automatically โ violations are flagged before writing
Advanced Commandsโ
๐ด /kmgraph:meta-issueโ
Purpose: Create a structured workspace for problems that resist initial solutions. Tracks each attempt with its hypothesis and outcome so understanding evolves across attempts rather than starting blind each time.
When to use (2 or more criteria should be met):
- 3+ solution attempts already tried or expected
- Root cause understanding has shifted 2+ times
- Problem spans multiple project versions
- High complexity requiring coordination across systems
- Significant learning value for future similar problems
What it does:
- Initialize (
/kmgraph:meta-issue "Problem Title"):- Prompts for domain, scope, severity, expected attempts
- Creates structured directory under
{active_kg_path}/issues/[meta-issue-name]/ - Populates core files: README, description, implementation-log, test-cases
- Creates analysis files: root-cause-evolution, timeline, lessons-learned
- Links to knowledge graph
- Add attempt (
--add-attempt 003 "Try connection pooling"):- Creates numbered attempt folder with solution approach and results templates
- Updates implementation log
- Update understanding (
--update-understanding "Root cause is network latency"):- Records belief shifts with timestamp and evidence
- Updates description with current best understanding
- View status (
--status):- Shows all active meta-issues with attempt counts and current understanding
- Log attempt with hypothesis (
--log-attempt NNN "hypothesis"):- Enforces a distinct hypothesis before each attempt begins
- Pre-populates the attempt template's hypothesis field
- Reminds the user to invoke
stuck-work-escalationat attempt 3+ - At 5 attempts, exit-path analysis becomes mandatory (see
stuck-work-escalationskill)
Time: 3-5 minutes for initialization
Example:
/kmgraph:meta-issue "Authentication Redesign"
/kmgraph:meta-issue --add-attempt 002 "OAuth2 with JWT"
/kmgraph:meta-issue --log-attempt 003 "JWT expiry logic is the root cause"
/kmgraph:meta-issue --update-understanding "Token expiry logic flawed"
/kmgraph:meta-issue --status
Note: Do NOT use meta-issue for simple bugs, standard features, or one-off debugging. Use
/kmgraph:capture-lessoninstead.
See also: Meta-Issue Guide โ full guide covering directory structure, attempt templates, escalation thresholds, and worked examples. Track a Multi-Attempt Issue โ step-by-step walkthrough.
๐ด /kmgraph:start-issue-trackingโ
Purpose: Document a bug or enhancement from identification through resolution, with git integration when a repository is present. Captures the context of an issue in structured templates for review and implementation.
When to use:
- Identified a bug that needs structured tracking
- Planning a new feature or enhancement
- Documenting a problem before solving it
- Creating a developer handoff with full context
Note: The term "issue" here refers to a GitHub Issue โ a platform feature for tracking bugs and feature requests/enhancements.
What it does:
- Snapshot gate โ optionally takes a session snapshot before the issue dialog
- Branch guard โ Step 1.0 now surfaces a โ ๏ธ warning when current branch โ main, priming the user before versioning decisions; Step 6.2 lesson capture prompt becomes strongly recommended when working on a non-main branch
- Steps 1.1โ1.4 ask one question at a time โ type (bug vs. enhancement), version impact, branch name, and plan filename are each asked independently, waiting for a response before the next question. No multi-question prompts.
- Scans chat history for recent proposals ("Would you like me to...")
- Runs git authority check and auto-detects version increment path
- Auto-detects issue type from keywords (bug vs. enhancement)
- Creates directory structure with documentation templates (description, solution approach, test cases, implementation log)
- Generates an implementation plan with safety headers and atomic approval protocol
- Step 5.0: Creates a GitHub Issue via
gh issue create --body-filefrom the issue description; writes the returned issue number back to spec frontmatter (github-issuefield auto-populated) - Creates a Git feature branch (
issue/{N}-{slug}) - Optionally creates a draft PR on GitHub with
--body-filepopulated from solution approach andCloses #Nreferencing the issue created in Step 5.0 - Step 6.2 (lesson capture) is a mandatory gate โ must receive a response before continuing. When working on a non-main branch, this step is strongly recommended.
- Step 6.4 (ROADMAP + CHANGELOG update) is a mandatory gate โ must receive a response confirming ROADMAP and CHANGELOG entries have been considered before the command completes.
- Links to knowledge graph and prompts for lesson capture
- Engages implementation freeze โ stops before any code changes
Time: 5-10 minutes
Example:
/kmgraph:start-issue-tracking
/kmgraph:start-issue-tracking CLI flag parsing fails on quoted args
/kmgraph:start-issue-tracking Add token usage display
Tips:
- Uses the Dual-ID Policy: local IDs (
issue-NorENH-NNN) are independent from GitHub issue numbers (#N) - GitHub Issue creation is automatic at Step 5.0 โ
gh issue create --body-fileruns before branch creation;github-issuefrontmatter is written back immediately
See also: Track Issues โ full lifecycle walkthrough including git integration and the implementation freeze gate.
๐ด /kmgraph:update-issue-planโ
Purpose: Keeps the knowledge graph, active plans, and GitHub issues in sync after new entries are extracted. The right command when formal issue plans are part of the workflow.
When to use:
- After extracting new KG entries with
/kmgraph:update-graph - When implementation plan needs to reflect new insights
- Before committing governance-related changes
- When progress needs to be posted to a GitHub Issue
Note: References to "issues" here mean GitHub Issues โ platform-level bug reports or feature requests.
What it does:
- Knowledge extraction: Runs
/kmgraph:update-graphto extract patterns - Plan sync: Updates the active implementation plan with a "Lessons Learned Integration" section
- Local issue update: Appends progress and new verification requirements to local issue docs
- GitHub sync: Maps local issue ID to GitHub Issue number, posts a knowledge sync comment, and updates PR description with related lessons
- Governance audit: Outputs a summary table showing sync status across all components
Time: 2-5 minutes
Example:
/kmgraph:update-issue-plan
/kmgraph:update-issue-plan --auto # Skip prompts
/kmgraph:update-issue-plan --pr=42 # Sync to specific PR
Tips:
- Works fully offline โ GitHub steps gracefully degrade if
ghCLI is not installed - Decision gates will prompt before creating new issues for out-of-scope discoveries
๐ด /kmgraph:link-issueโ
Purpose: Link a lesson or ADR to a GitHub Issue after the fact. Writes the issue number into the file's frontmatter and posts a comment to the issue, so the KG and GitHub stay in sync.
When to use:
- A lesson was captured but not linked to its relevant GitHub Issue
- An ADR should reference the GitHub Issue that prompted the decision
- Building traceability between knowledge and tracked work
Note: "Issue" here refers to a GitHub Issue โ which could be a bug report or a feature request/enhancement.
What it does:
- Validates the file exists and issue number is provided
- Updates YAML frontmatter in the lesson/ADR with issue and PR metadata
- Posts a comment to the GitHub Issue with a link to the lesson (if
ghCLI available) - Updates the related KG entry with the issue reference
- Reports bidirectional link status
Time: Under 1 minute
Example:
/kmgraph:link-issue docs/lessons-learned/process/my-lesson.md --issue 42
/kmgraph:link-issue docs/decisions/ADR-005.md --issue 38 --pr 40
๐ด /kmgraph:sync-allโ
Purpose: The catch-up command when lessons have been captured but the pipeline has not run. Replaces four manual steps in a single pass: update-graph, plan sync, issue update, and GitHub posting.
When to use:
- After significant work sessions to consolidate everything
- Weekly deep sync to ensure KG, plans, and GitHub are aligned
- Before major milestones or project phase changes
- As a catch-up sync if you've been capturing lessons without syncing
What it does:
- Scans for new or modified lessons in
{active_kg_path}/lessons-learned/ - Extracts KG entries from lessons (delegates to
/kmgraph:update-graph) - Links to active implementation plan if relevant
- Updates local issue with KG references and progress notes
- Enriches today's session summary with KG insights
- Generates GitHub Issue comment draft and asks for single confirmation before posting
Time: 1-5 minutes depending on volume
Example:
/kmgraph:sync-all
/kmgraph:sync-all --auto # Skip GitHub posting confirmation
/kmgraph:sync-all --dry-run # Preview without changes
Output:
Knowledge Sync Complete
-----------------------
Lessons scanned: 3 (2 new, 1 modified)
KG entries: 2 created, 1 updated
Plan linked: v2.0 (Step 2 โ Prefix Naming lesson)
Local issue: issue-42 (updated)
GitHub: #45 (comment posted)
Session: 2026-02-11 (enriched)
Tips:
- Idempotent โ safe to run multiple times (existing entries updated, not duplicated)
- GitHub integration is optional โ works fully offline if
ghCLI is not installed
Cleaner conversations: When the context-mode plugin is installed, sync-all runs file scans in a background process so the results do not fill the conversation. Falls back automatically if context-mode is not installed. No configuration required.
Search index: Each run of sync-all automatically refreshes the search index if one has been built. On the first run after upgrading, sync-all will ask once whether to build the index. The preference is remembered.
๐ด /kmgraph:handoffโ
Purpose: Create a complete snapshot of project state for continuation across sessions, models, or machines. Five documents capture everything the next session needs to orient without losing working context.
When to use:
- Before transitioning project to another developer
- Preparing for context window limits (>180K tokens)
- Completing a major release cycle
- Creating documentation for AI assistant handoffs
- Before taking a long break
What it creates:
- START-HERE.md โ Thin pointer: branch, commit, auto-detected link to today's session summary
- DOCUMENTATION-MAP.md โ File inventory with purpose annotations
- ARCHITECTURE-SNAPSHOT.md โ Current codebase structure and key decisions
Operational state (current branch, open issues, in-progress work) lives in the linked session summary โ not in the handoff package. Run /kmgraph:session-summary first if you want that context captured.
Time: 1-2 minutes
Example:
/kmgraph:handoff
/kmgraph:handoff --output-dir=./backup/
Output:
โ
Handoff package created!
Location: ./handoff-packages/2026-06-09
Files:
- START-HERE.md โ 8 lines
- DOCUMENTATION-MAP.md โ 156 lines
- ARCHITECTURE-SNAPSHOT.md โ 189 lines
Total: ~353 lines of documentation
Reading time: ~20 minutes for complete orientation
Tips:
- Creates dated directory:
handoff-packages/YYYY-MM-DD/by default - START-HERE.md auto-detects today's session summary and sets
continues_fromโ run/kmgraph:session-summaryfirst for best results - Files can be shared via zip or archived for future reference
Command Comparisonโ
Capture vs Update vs Syncโ
Three ways to save learnings:
-
/kmgraph:capture-lesson- Creates a NEW lesson file
- Guided interview process
- Use: When documenting new learnings
-
/kmgraph:update-graph- Extracts patterns from existing lessons
- Updates knowledge entries
- Use: Daily or weekly to consolidate
-
/kmgraph:sync-all- Full 4-step pipeline (capture โ update โ sync โ link)
- Comprehensive sync across KG, plans, issues, and GitHub
- Use: Weekly deep sync or before sharing
When to use which:
- Just solved a problem โ
capture-lesson - End of day/week โ
update-graph - Major milestone โ
sync-all
Status vs Recall vs Listโ
Three ways to view knowledge:
-
/kmgraph:status- High-level overview of active KG
- File counts, warnings, recent activity
- Use: Daily check-in, health check
-
/kmgraph:recall- Deep full-text search across all memory systems
- Find specific content by keyword
- Use: Looking for something specific
-
/kmgraph:list- Shows all configured KGs (if multiple)
- Metadata only (names, paths, categories)
- Use: Switching between projects
Issue Tracking: meta-issue vs start-issue-trackingโ
Two levels of issue tracking:
-
/kmgraph:start-issue-tracking- For individual bugs or enhancements
- Creates a single issue directory, implementation plan, and Git branch
- Standard workflow for most tracked work
-
/kmgraph:meta-issue- For complex problems requiring 3+ solution attempts
- Creates a richer directory structure with attempt folders and root-cause evolution
- Tracks how understanding changes over time
When to use which:
- Standard bug or feature โ
start-issue-tracking - Multi-attempt investigation โ
meta-issue
Troubleshootingโ
"Command not found"โ
Problem: Claude doesn't recognize /kmgraph:... command
Solutions:
- Verify plugin installed: Check Claude Code > Extensions
- Restart Claude Code
- Update plugin: Check for updates in marketplace
- Check active KG: Run
/kmgraph:status
"No active knowledge graph"โ
Problem: Commands fail with "no active KG"
Solutions:
- Run
/kmgraph:initto create your first KG - Run
/kmgraph:listto see available KGs - Run
/kmgraph:switchto activate an existing KG
"No chat history found"โ
Problem: /kmgraph:extract-chat finds no logs
Solutions:
- Verify log directories exist:
ls ~/.claude/projects/ls ~/.gemini/tmp/
- Check if you've used Claude Code or Gemini recently
- Logs may be cleared on app updates
"Protobuf extraction fails"โ
Problem: Gemini .pb files can't be read
Solutions:
# Install optional dependency
pip install blackboxprotobuf
# Or skip protobuf files (JSON extraction still works)
/kmgraph:extract-chat -gemini # Will warn about .pb files
"Git branch creation fails"โ
Problem: /kmgraph:start-issue-tracking can't create a branch
Solutions:
# Check current branch
git branch
# Make sure you're on main/develop
git checkout main
# Try again
git checkout -b issue/N-description
Technical Detailsโ
This section covers implementation specifics for users who want to understand how features work internally.
Context-Mode Integrationโ
When the context-mode plugin is installed alongside kmgraph:
sync-allusesctx_batch_executeto combine lesson scanning and KG extraction in a single sandboxed background processupdate-graphusesctx_execute_filefor sandboxed file reads when processing 10 or more lessons; falls back to the knowledge-extractor subagent for large batches without context-mode, or reads directly for small batches- Detection: kmgraph checks for
mcp__plugin_context-mode_context-mode__ctx_batch_executeat runtime; no configuration required; zero breaking change if context-mode is absent
Search Index Implementationโ
The diagram below shows how kg_search decides which search method to use.
kg_search checks for a search index first. If the index exists, it queries the index and returns BM25-ranked results with an index label. If the index does not exist or encounters an error, kg_search falls back to reading files sequentially. The caller receives the same result format either way.
- Index format: SQLite database using FTS5 (Full-Text Search version 5) extension
- Ranking: BM25 โ the same relevance algorithm used by most search engines
- Stemming: porter stemmer โ "searching" matches "search", "decisions" matches "decision"
- Rebuild strategy: incremental โ only re-indexes files whose modification time changed
- Storage:
{kg-root}/.fts5.dbโ gitignored, local only, rebuilt on demand - Package:
node-sqlite3-wasm(WASM-based SQLite, no native compilation required) - Fallback: if the index is corrupt or missing,
kg_searchsilently uses file-scan
Related Documentationโ
Quick helpโ
One-page quick reference
-
Term definitions
Writing better entriesโ
Quality standards
Relatedโ
-
Installation, first lesson, and setup verification.
-
One-page cheat sheet with all commands at a glance.
-
Plain-English explanations of all key terms and patterns.
Related Documentationโ
Getting startedโ
-
Installation, first lesson, setup verification (5 min)
-
Universal installer for all platforms (paste-friendly)
-
Post-install setup: sanitization, team workflows, MCP server
Learning resourcesโ
-
One-page cheat sheet for common tasks
-
Plain-English definitions of every term and pattern
-
Real-world completed examples of lessons, ADRs, and KG entries
Advancedโ
-
Step-by-step guides for all 9 workflow types (non-Claude platforms)
-
Integration details for Cursor, Windsurf, Continue, VS Code, Aider
-
Documentation authoring standards and conventions
Version: 0.5.2 Updated: 2026-04-22