Search across all notes for a phrase or pattern with context
Searches all notes for phrases or patterns with context and analysis.
/plugin marketplace add witt3rd/claude-plugins/plugin install azkg@witt3rd-claude-pluginsYou are tasked with searching across all notes in the Zettelkasten for a specific phrase or pattern, showing context for each match.
Check for AZKG_REPO_PATH environment variable:
if [ -z "$AZKG_REPO_PATH" ]; then REPO_PATH=$(pwd); else REPO_PATH="$AZKG_REPO_PATH"; fiAll file operations must use REPO_PATH:
Read(REPO_PATH/filename.md) or Read("$REPO_PATH/filename.md")Write(REPO_PATH/filename.md) or Write("$REPO_PATH/filename.md")Edit(REPO_PATH/filename.md) or Edit("$REPO_PATH/filename.md")Grep(pattern, path=REPO_PATH) or with explicit pathGlob(pattern, path=REPO_PATH) or with explicit pathExample usage:
# Check environment variable
if [ -z "$AZKG_REPO_PATH" ]; then
REPO_PATH=$(pwd)
else
REPO_PATH="$AZKG_REPO_PATH"
fi
# Then use REPO_PATH for all operations
Read("$REPO_PATH/agents.md")
Concrete examples:
Input format: User provides either:
/search-notes "semantic routing"/search-notes "async.*await"/search-notes "MCP security authentication"Extract:
Use Grep tool to search all markdown files:
pattern: <user's search term>
glob: "*.md"
output_mode: "content"
-n: true (show line numbers)
-C: 2 (show 2 lines of context before and after)
-i: true (case insensitive by default)
Search strategy:
.md files in repository rootGroup results by file and present clearly:
Found <N> matches across <M> notes:
## note_name.md (X matches)
Match 1 (line 45):
43: context before
44: more context
45: **matching line with PATTERN highlighted**
46: context after
47: more context
Match 2 (line 120):
118: context before
119: more context
120: **matching line with PATTERN highlighted**
121: context after
122: more context
---
## another_note.md (Y matches)
Match 1 (line 78):
...
Formatting guidelines:
## headers for each file---Provide insights:
Thematic clustering:
Related concepts:
Coverage assessment:
Based on search results, suggest:
If many matches (>10):
/generate-moc for this theme"If few matches (1-3):
/create-note for deeper treatment"/expand-graph on existing notes to add related content"If related concepts found:
/link-notes"If search term in multiple contexts:
Support optional flags:
Case-sensitive search:
/search-notes --case-sensitive "Python"-i: false in GrepWhole word only:
/search-notes --whole-word "test"\btest\bRegex mode:
/search-notes --regex "mcp.*server"More context:
/search-notes --context 5 "pattern"-C: 5 for 5 lines of contextFiles only (no content):
/search-notes --files-only "pattern"output_mode: "files_with_matches"Provide concise summary:
Search Summary for "<search-pattern>"
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Statistics:
- Total matches: <N>
- Files with matches: <M>
- Most matches: <filename> (<X> matches)
📁 Distribution by batch:
- MCP Protocol: 5 notes
- Python Stack: 3 notes
- Core AI/Agents: 2 notes
🏷️ Common tags in results:
#mcp, #python, #security, #api
💡 Suggestions:
- [Specific actionable next step based on results]
- [Another suggestion]
🔗 Potentially missing links:
- [[note_a]] ↔ [[note_b]] - both discuss same concept
Recognize common search needs:
Tag search:
/search-notes "#mcp"Broken wikilinks:
/search-notes --broken-links[[wikilinks]] that don't point to existing filesTODOs and incomplete sections:
/search-notes --todosTODO, FIXME, [placeholder], etc.Missing related concepts:
/search-notes --no-relationships/expand-graph on themSimple search:
/search-notes "semantic routing"
Regex search:
/search-notes --regex "async.*(await|runtime)"
Case-sensitive search:
/search-notes --case-sensitive "Python"
Find all notes about a technology:
/search-notes --context 3 "FastMCP"
Tag search:
/search-notes "#agents"
Find broken links:
/search-notes --broken-links
Find incomplete notes:
/search-notes --todos
Performance:
Formatting:
note.md:45Accuracy:
Execute the search for the pattern provided by the user.