CLI Usage: When unsure about a CLI's interface or flags, run it with --help first. Do NOT attempt to discover functionality by reading plugin source code — doing so leads to incorrect execution from assumptions made without context of the holistic flow.
Knowledge Management
Manage the CLEAR knowledge base: search, view, capture, index, link, deprecate, and supersede entries.
Plugin Root Resolution
CLI commands in this skill reference $CLEAR_PLUGIN_ROOT — a .claude/settings.json env var the shell expands. The SessionStart hook persists it, but settings env vars load at session launch, so on a brand-new consumer's first session (before its next restart) the variable is empty and node "$CLEAR_PLUGIN_ROOT/build/..." fails with MODULE_NOT_FOUND.
First-session bootstrap — if $CLEAR_PLUGIN_ROOT is empty, set it inline in the same Bash call as the CLI (each Bash call is a fresh shell, so a separate export would not carry over):
export CLEAR_PLUGIN_ROOT="${CLEAR_PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}"
Prepend it to the CLI in one shell line: export CLEAR_PLUGIN_ROOT="${CLEAR_PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}"; <node "$CLEAR_PLUGIN_ROOT/build/..." command>. ${CLAUDE_PLUGIN_ROOT} resolves in this SKILL.md body to the actually-loaded plugin path; once the consumer restarts, $CLEAR_PLUGIN_ROOT is populated and the assignment is a harmless no-op. Reference files are left unchanged.
When to Use This Skill
| Trigger |
Examples |
| View overview |
"Show me the knowledge base status", "What's in the KB?" |
| Search or find entries |
"Search knowledge for caching pattern", "Find decisions about auth" |
| View entry details |
"Show me TD-015", "What does LES-003 say?" |
| Load into context |
"Load knowledge for this workpackage" |
| Rebuild index |
"Rebuild the knowledge index", "Reindex knowledge" |
| Capture knowledge |
"Capture this decision", "Save this as a lesson learned" |
| Deprecate an entry |
"Deprecate PAT-003", "This pattern is outdated" |
| Link or unlink |
"Link TD-012 to WP-04", "Unlink LES-001" |
| Supersede an entry |
"TD-005 replaces TD-002", "Supersede PAT-001 with PAT-007" |
Not for: Project status (/cf-status), workpackage ops (/cf-workpackage), debug (/cf-debug).
Command Reference
All CLIs at $CLEAR_PLUGIN_ROOT/build/infrastructure/knowledge/cli/. Run with --clear-dir=./.clear.
| Action |
CLI Command |
| Create new entry |
capture-cli --create --type=<type> --title="..." --description="..." |
| Update entry fields (tags, description) |
capture-cli --update --id=<id> --tags="..." --description="..." |
| Change entry type (regenerates ID) |
capture-cli --update --id=<id> --type=<new-type> |
| Add file link to entry |
capture-cli --update --id=<id> --add-related-file=<path> |
| Search knowledge base |
search-cli --query="..." |
| Show entry details |
show-cli --id=<id> |
| Knowledge base overview |
status-cli |
| Link entry to workpackage |
link-cli link <id> --to=<wp-id> |
| Unlink from workpackage |
link-cli unlink <id> |
| Deprecate entry |
deprecate-cli <id> --reason="..." |
| Supersede entry |
supersede-cli <old-id> <new-id> |
| Delete entry |
delete-cli <id> --reason="..." --force |
| Rebuild search index |
index-cli --mode=full --force |
| Incremental index update |
index-cli --mode=incremental |
| File-to-entry lookup |
file-index-cli --lookup=<path> |
| Rebuild file index |
file-index-cli --rebuild |
Key distinction: link-cli manages workpackage associations only.
To add file links (related_files) to a knowledge entry, use the
capture-cli update path with the add-related-file option.
Pre-Flight Check
if [ ! -d ".clear" ]; then
echo "ERROR: CLEAR not initialized. Run /cf-init first." >&2
exit 1
fi
Subcommand Table
| Subcommand |
Type |
Reference File |
Intent Signals |
search |
[R] |
references/search.md |
"search", "find", "look for" |
show |
[R] |
references/show.md |
"show", "details", "what does X say" |
load |
[R] |
references/load.md |
"load", "load knowledge", "bring in context" |
index |
[R] |
references/index.md |
"index", "reindex", "rebuild index" |
help |
[R] |
references/help.md |
"help", "how do I", "usage" |
capture |
[W] |
references/capture.md |
"capture", "save", "record this decision", "lesson learned" |
deprecate |
[W] |
references/deprecate.md |
"deprecate", "outdated", "no longer valid" |
dismiss |
[W] |
references/dismiss.md |
"dismiss deprecation", "acknowledge deprecation", "skip-replacement" |
ack |
[W] |
references/ack.md |
"ack", "acknowledge", "mark reviewed", "clear pending-review", "I've seen it" |
link |
[W] |
references/link.md |
"link", "associate", "connect to WP" |
unlink |
[W] |
references/unlink.md |
"unlink", "disconnect", "remove link" |
supersede |
[W] |
references/supersede.md |
"supersede", "replace", "X replaces Y" |
Routing
Follow these steps in order. Track which step you reached — this determines whether confirmation is needed.
Step 1 — Check $ARGUMENTS for an explicit subcommand.
Check whether $ARGUMENTS literally starts with one of the subcommand keywords from the table above (e.g., capture, search, deprecate). This is a string match, not intent inference.
- If YES: load
references/{subcommand}.md, pass remaining arguments. Done — skip steps 2-4.
- If NO (empty, missing, or does not start with a table keyword): continue to step 2.
Step 2 — Infer intent from the user's natural language message.
$ARGUMENTS did not contain an explicit subcommand. Determine which subcommand best matches the user's intent from their message. Use the subcommand table's intent signals, the "When to Use" examples, and the conversation context.
- If you can identify a specific subcommand with reasonable confidence: continue to step 3.
- If the user's message is purely a status or overview inquiry with no action intent (e.g., "show me the knowledge base status"): load
references/default.md. Done. Only use this exit if the message contains no entity identifiers (entry ID, WP ID) and expresses no specific action intent.
- If you cannot determine intent with reasonable confidence: go to step 4.
Step 3 — Confirm before write actions (NL-inferred only).
You reached this step via intent inference (step 2), not explicit arguments (step 1).
- If the inferred subcommand is a read action ([R] in the table): load the reference file immediately.
- If the inferred subcommand is a write action ([W] in the table): you MUST confirm before proceeding. Ask: "I'll run {subcommand}{details}. Proceed?" where
{details} includes the target identifier (e.g., " on TD-015", " superseding TD-002 with PAT-007"). For destructive actions (deprecate, supersede, delete), always include the target ID. Wait for the user's response. Only load the reference file after the user confirms.
Step 4 — Ambiguity fallback.
Ask the user: "I matched /cf-knowledge but I'm not sure which action you want. Did you mean: {top 2-3 candidates}?" Do NOT silently fall through to default.
Error Codes
| Exit Code |
Meaning |
| 0 |
Success |
| 1 |
Invalid usage or missing arguments |
| 2 |
Knowledge entry not found |
| 3 |
Invalid operation (e.g., deprecate already deprecated) |
| 4 |
Chain depth exceeded |
| 5 |
Validation failed |
Completion Checklist
1---2name: cf-knowledge3description: Manage the CLEAR knowledge base — search, view, capture, index, link, deprecate, and supersede entries. Use when the user asks about knowledge base entries, wants to capture a decision or lesson, search for patterns, or manage entry lifecycle.4---56> **CLI Usage:** When unsure about a CLI's interface or flags, run it with `--help` first. Do NOT attempt to discover functionality by reading plugin source code — doing so leads to incorrect execution from assumptions made without context of the holistic flow.78# Knowledge Management910Manage the CLEAR knowledge base: search, view, capture, index, link, deprecate, and supersede entries.1112## Plugin Root Resolution1314CLI commands in this skill reference `$CLEAR_PLUGIN_ROOT` — a `.claude/settings.json` env var the shell expands. The SessionStart hook persists it, but settings env vars load at session **launch**, so on a brand-new consumer's **first session** (before its next restart) the variable is empty and `node "$CLEAR_PLUGIN_ROOT/build/..."` fails with `MODULE_NOT_FOUND`.1516**First-session bootstrap** — if `$CLEAR_PLUGIN_ROOT` is empty, set it inline in the *same* Bash call as the CLI (each Bash call is a fresh shell, so a separate `export` would not carry over):1718```bash19export CLEAR_PLUGIN_ROOT="${CLEAR_PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}"20```2122Prepend it to the CLI in one shell line: `export CLEAR_PLUGIN_ROOT="${CLEAR_PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}"; <node "$CLEAR_PLUGIN_ROOT/build/..." command>`. `${CLAUDE_PLUGIN_ROOT}` resolves in this SKILL.md body to the actually-loaded plugin path; once the consumer restarts, `$CLEAR_PLUGIN_ROOT` is populated and the assignment is a harmless no-op. Reference files are left unchanged.2324## When to Use This Skill2526| Trigger | Examples |27|---------|---------|28| View overview | "Show me the knowledge base status", "What's in the KB?" |29| Search or find entries | "Search knowledge for caching pattern", "Find decisions about auth" |30| View entry details | "Show me TD-015", "What does LES-003 say?" |31| Load into context | "Load knowledge for this workpackage" |32| Rebuild index | "Rebuild the knowledge index", "Reindex knowledge" |33| Capture knowledge | "Capture this decision", "Save this as a lesson learned" |34| Deprecate an entry | "Deprecate PAT-003", "This pattern is outdated" |35| Link or unlink | "Link TD-012 to WP-04", "Unlink LES-001" |36| Supersede an entry | "TD-005 replaces TD-002", "Supersede PAT-001 with PAT-007" |3738**Not for:** Project status (`/cf-status`), workpackage ops (`/cf-workpackage`), debug (`/cf-debug`).3940---4142## Command Reference4344All CLIs at `$CLEAR_PLUGIN_ROOT/build/infrastructure/knowledge/cli/`. Run with `--clear-dir=./.clear`.4546| Action | CLI Command |47|--------|-------------|48| Create new entry | `capture-cli --create --type=<type> --title="..." --description="..."` |49| Update entry fields (tags, description) | `capture-cli --update --id=<id> --tags="..." --description="..."` |50| Change entry type (regenerates ID) | `capture-cli --update --id=<id> --type=<new-type>` |51| Add file link to entry | `capture-cli --update --id=<id> --add-related-file=<path>` |52| Search knowledge base | `search-cli --query="..."` |53| Show entry details | `show-cli --id=<id>` |54| Knowledge base overview | `status-cli` |55| Link entry to workpackage | `link-cli link <id> --to=<wp-id>` |56| Unlink from workpackage | `link-cli unlink <id>` |57| Deprecate entry | `deprecate-cli <id> --reason="..."` |58| Supersede entry | `supersede-cli <old-id> <new-id>` |59| Delete entry | `delete-cli <id> --reason="..." --force` |60| Rebuild search index | `index-cli --mode=full --force` |61| Incremental index update | `index-cli --mode=incremental` |62| File-to-entry lookup | `file-index-cli --lookup=<path>` |63| Rebuild file index | `file-index-cli --rebuild` |6465> **Key distinction:** `link-cli` manages **workpackage associations** only.66> To add **file links** (`related_files`) to a knowledge entry, use the67> `capture-cli` update path with the `add-related-file` option.6869---7071## Pre-Flight Check7273```bash74if [ ! -d ".clear" ]; then75 echo "ERROR: CLEAR not initialized. Run /cf-init first." >&276 exit 177fi78```7980---8182## Subcommand Table8384| Subcommand | Type | Reference File | Intent Signals |85|------------|------|----------------|----------------|86| `search` | [R] | `references/search.md` | "search", "find", "look for" |87| `show` | [R] | `references/show.md` | "show", "details", "what does X say" |88| `load` | [R] | `references/load.md` | "load", "load knowledge", "bring in context" |89| `index` | [R] | `references/index.md` | "index", "reindex", "rebuild index" |90| `help` | [R] | `references/help.md` | "help", "how do I", "usage" |91| `capture` | [W] | `references/capture.md` | "capture", "save", "record this decision", "lesson learned" |92| `deprecate` | [W] | `references/deprecate.md` | "deprecate", "outdated", "no longer valid" |93| `dismiss` | [W] | `references/dismiss.md` | "dismiss deprecation", "acknowledge deprecation", "skip-replacement" |94| `ack` | [W] | `references/ack.md` | "ack", "acknowledge", "mark reviewed", "clear pending-review", "I've seen it" |95| `link` | [W] | `references/link.md` | "link", "associate", "connect to WP" |96| `unlink` | [W] | `references/unlink.md` | "unlink", "disconnect", "remove link" |97| `supersede` | [W] | `references/supersede.md` | "supersede", "replace", "X replaces Y" |9899---100101## Routing102103Follow these steps **in order**. Track which step you reached — this determines whether confirmation is needed.104105**Step 1 — Check `$ARGUMENTS` for an explicit subcommand.**106Check whether `$ARGUMENTS` literally starts with one of the subcommand keywords from the table above (e.g., `capture`, `search`, `deprecate`). This is a string match, not intent inference.107- If YES: load `references/{subcommand}.md`, pass remaining arguments. **Done — skip steps 2-4.**108- If NO (empty, missing, or does not start with a table keyword): continue to step 2.109110**Step 2 — Infer intent from the user's natural language message.**111`$ARGUMENTS` did not contain an explicit subcommand. Determine which subcommand best matches the user's intent from their message. Use the subcommand table's intent signals, the "When to Use" examples, and the conversation context.112- If you can identify a specific subcommand with reasonable confidence: continue to step 3.113- If the user's message is purely a status or overview inquiry with no action intent (e.g., "show me the knowledge base status"): load `references/default.md`. **Done.** Only use this exit if the message contains no entity identifiers (entry ID, WP ID) and expresses no specific action intent.114- If you cannot determine intent with reasonable confidence: go to step 4.115116**Step 3 — Confirm before write actions (NL-inferred only).**117You reached this step via intent inference (step 2), not explicit arguments (step 1).118- If the inferred subcommand is a **read** action ([R] in the table): load the reference file immediately.119- If the inferred subcommand is a **write** action ([W] in the table): **you MUST confirm before proceeding.** Ask: "I'll run **{subcommand}**{details}. Proceed?" where `{details}` includes the target identifier (e.g., " on TD-015", " superseding TD-002 with PAT-007"). For destructive actions (deprecate, supersede, delete), always include the target ID. Wait for the user's response. Only load the reference file after the user confirms.120121**Step 4 — Ambiguity fallback.**122Ask the user: "I matched `/cf-knowledge` but I'm not sure which action you want. Did you mean: {top 2-3 candidates}?" Do NOT silently fall through to `default`.123124---125126## Error Codes127128| Exit Code | Meaning |129|-----------|---------|130| 0 | Success |131| 1 | Invalid usage or missing arguments |132| 2 | Knowledge entry not found |133| 3 | Invalid operation (e.g., deprecate already deprecated) |134| 4 | Chain depth exceeded |135| 5 | Validation failed |136137---138139## Completion Checklist140141- [ ] Pre-flight passed142- [ ] Correct reference loaded and executed143- [ ] Exit code 0, output displayed