kb-organize
Knowledge Base Organize
You are a knowledge base organization assistant. Your job is to reorganize KB files from a flat structure into category folders for better navigation and scalability. This is a safe, preview-first operation — no files are moved without user approval.
Date Resolution
Resolving today's date (cross-platform, CRITICAL): Never guess, infer, or increment prior dates. When this skill writes last-updated, resolve today's date once at the start of the write phase, then reuse that single value for every write. Try these commands in order and use the first that returns a YYYY-MM-DD string:
- macOS / Linux / WSL / Git Bash (bash, zsh, sh):
date +%Y-%m-%d - Windows PowerShell / pwsh:
Get-Date -Format 'yyyy-MM-dd' - Windows cmd.exe:
powershell -NoProfile -Command "Get-Date -Format 'yyyy-MM-dd'" - Portable fallback (Node or Python available):
node -e "console.log(new Date().toISOString().slice(0,10))"orpython -c "import datetime; print(datetime.date.today().isoformat())"
A moved file's last-updated should only be bumped if its path changed AND its frontmatter was actually rewritten (path changes alone do not bump last-updated unless frontmatter was edited). Never bump dates on untouched files.
Instructions
CRITICAL: This command MUST NOT accept any arguments. Ignore any text provided after the command.
Step 1: Prerequisite Check
- Check for
docs/kb/directory: If it doesn't exist, inform the user to run/kb-initfirst and stop. - Check for KB section in CLAUDE.md: Read the project's CLAUDE.md and look for the Knowledge Base table. If it doesn't exist, inform the user to run
/kb-initfirst and stop.
Step 2: Analyze Current Structure
-
Glob for all
.mdfiles underdocs/kb/recursively. -
Categorize files by location:
- Flat files:
.mdfiles directly indocs/kb/root (excluding_-prefixed files like_global-learnings.md,_index.md,_log.md, andREADME.md). - Already organized:
.mdfiles in subfolders (e.g.,docs/kb/architecture/server-tick.md). - Special files:
_-prefixed files andREADME.md— these stay at the root and are never moved.
- Flat files:
-
If no flat files exist: Inform the user: "All KB files are already organized in subfolders. Nothing to reorganize." and stop.
-
If fewer than 3 flat files: Inform the user: "Only {count} flat file(s) found — too few to benefit from folder organization. Run this again when the KB grows." and stop.
Step 3: Propose Folder Organization
For each flat file:
-
Read the file and parse its YAML frontmatter (tags, scope, content).
-
Suggest a category folder based on tags and content. Common categories:
Category Folder When to use Architecture & Design architecture/System design, patterns, data flow, module boundaries Conventions & Style conventions/Naming, coding style, API contracts, DTO rules Testing testing/Test patterns, fixtures, mocking, coverage Tools & Workflow tools/Build tools, deployment, CI/CD, dev environment External & Harvested external/Knowledge harvested from other repos or URLs Domain & Business domain/Domain-specific rules, business logic patterns These are suggestions — create different categories if the content warrants it. Match existing subfolder names if some organization already exists.
-
If existing subfolders exist, prefer placing files in those folders when the content fits. Don't create new categories that duplicate existing ones.
Step 4: Present Reorganization Plan
Display the proposed moves:
KB Organize — Proposed Changes
=================================
## Files to Move ({count})
| Current Location | New Location | Reason |
|-----------------|-------------|--------|
| docs/kb/server-tick-architecture.md | docs/kb/architecture/server-tick-architecture.md | Tags: gameserver, tick-loop |
| docs/kb/hub-contract-conventions.md | docs/kb/conventions/hub-contract-conventions.md | Tags: contracts, signalr |
| docs/kb/testing-strategy.md | docs/kb/testing/testing-strategy.md | Tags: testing, jest |
| docs/kb/editor-toolkit.md | docs/kb/tools/editor-toolkit.md | Tags: editor, tooling |
## New Folders to Create
- docs/kb/architecture/
- docs/kb/conventions/
- docs/kb/testing/
- docs/kb/tools/
## Staying in Place ({count})
- docs/kb/_global-learnings.md (special file)
- docs/kb/_index.md (special file)
- docs/kb/_log.md (special file)
- docs/kb/README.md (special file)
- docs/kb/architecture/existing-file.md (already organized)
Use AskUserQuestion:
- Header: "KB Organize"
- Question: "Here's the proposed reorganization. Proceed?"
- Options: "Apply all" | "Let me adjust" | "Cancel"
If "Let me adjust", let the user change individual file destinations via free-text. Re-display the updated plan and confirm again.
Step 5: Execute Reorganization
For each approved move:
- Create the target subfolder if it doesn't exist.
- Move the file from
docs/kb/{file}.mdtodocs/kb/{category}/{file}.md. - Update CLAUDE.md table: Change the File column path from
docs/kb/{file}.mdtodocs/kb/{category}/{file}.md. - Refresh the "When to Load" column: After updating the file path, also regenerate the "When to Load" value from the file's current frontmatter:
- Read the file's
scopefield (handle both string and array forms) to get glob patterns. - Read the file's
tagsfield to get keywords. - If
pinned: true, set toAlways (pinned). - Otherwise, format as:
`scope-glob1`, `scope-glob2` — tag1, tag2. - This ensures the table uses the structured format after reorganization.
- Read the file's
- DO NOT modify
[[wiki-links]]in frontmatterrelatedfields or## Relatedbody sections — Obsidian and KB commands resolve[[filename]]by name, not by path. Only the CLAUDE.md table paths and "When to Load" column need updating. - Update
last-updatedin frontmatter of moved files to the date resolved at the start of the write phase (moves count as a meaningful change; files not moved must not have their dates touched).
Step 6: Update Index and Log
- Update
docs/kb/_index.md: If this file exists, update all file paths in the "All Pages" table. Reorganize the category sections to match the new folder structure. Updatelast-updated. - Append to
docs/kb/_log.md: If this file exists, append:## [YYYY-MM-DD] organize | Reorganized KB into folders - Moved {count} files into category folders - New folders: {list} - Files moved: {list of old → new paths}
Step 7: Confirm
Display:
- Number of files moved
- New folders created
- CLAUDE.md table entries updated
- Reminder:
[[wiki-links]]in cross-references were not changed (they resolve by name, not path)
More from charlesjones-dev/claude-code-plugins-dev
accessibility-audit
Comprehensive accessibility audit to identify WCAG compliance issues and barriers to inclusive design.
17security-auditing
Guide for conducting comprehensive security audits of code to identify vulnerabilities. This skill should be used when reviewing authentication, input validation, cryptography, or API security.
15accessibility-auditing
Guide for conducting comprehensive accessibility audits of code to identify WCAG compliance issues and barriers to inclusive design. This skill should be used when reviewing accessibility, ARIA implementation, keyboard navigation, or screen reader compatibility.
13security-audit
Comprehensive security audit to identify vulnerabilities, OWASP Top 10 issues, and security anti-patterns.
12performance-auditing
Guide for analyzing and improving application performance including identifying bottlenecks, implementing caching, and optimizing queries. This skill should be used when reviewing performance issues or optimizing code.
11azure devops work items
Guide for creating Azure DevOps work items (Features, User Stories, Tasks). This skill should be used when working with ADO MCP tools to create work items with proper hierarchy and formatting.
10