From 9167e4e39e4961f10d917fbb05e2dbed4399a187 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Thu, 18 Sep 2025 10:16:03 +0800 Subject: [PATCH] feat: Add context search strategy guidelines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Create context-search-strategy.md with comprehensive search command reference - Include rg, find, and grep usage patterns for efficient codebase exploration - Add workflow-specific search examples for task analysis and session management - Reference new strategy in CLAUDE.md CLI tool protocols section 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .claude/workflows/context-search-strategy.md | 60 ++++++++++++++++++++ CLAUDE.md | 1 + 2 files changed, 61 insertions(+) create mode 100644 .claude/workflows/context-search-strategy.md diff --git a/.claude/workflows/context-search-strategy.md b/.claude/workflows/context-search-strategy.md new file mode 100644 index 00000000..ce15ed64 --- /dev/null +++ b/.claude/workflows/context-search-strategy.md @@ -0,0 +1,60 @@ +--- +name: context-search-strategy +description: Strategic guidelines for context search commands +type: search-guideline +--- + +# Context Search Strategy + +## ⚡ Core Search Tools + +**rg (ripgrep)**: Fast content search with regex support +**find**: File/directory location by name patterns +**grep**: Built-in pattern matching in files + +### Decision Principles +- **Use rg for content** - Fastest for searching within files +- **Use find for files** - Locate files/directories by name +- **Use grep sparingly** - Only when rg unavailable + +### Quick Command Reference +```bash +# Content Search (rg preferred) +rg "pattern" --type js # Search in JS files +rg -i "case-insensitive" # Ignore case +rg -n "show-line-numbers" # Show line numbers +rg -A 3 -B 3 "context-lines" # Show 3 lines before/after + +# File Search (find) +find . -name "*.ts" -type f # Find TypeScript files +find . -path "*/node_modules" -prune -o -name "*.js" -print + +# Built-in alternatives +grep -r "pattern" . # Recursive search (slower) +grep -n -i "pattern" file.txt # Line numbers, case-insensitive +``` + +### Workflow Integration Examples +```bash +# Search for task definitions +rg "IMPL-\d+" .workflow/ --type json # Find task IDs +find .workflow/ -name "*.json" -path "*/.task/*" # Locate task files + +# Analyze workflow structure +rg "status.*pending" .workflow/.task/ # Find pending tasks +rg "depends_on" .workflow/.task/ -A 2 # Show dependencies + +# Find workflow sessions +find .workflow/ -name ".active-*" # Active sessions +rg "WFS-" .workflow/ --type json # Session references + +# Content analysis for planning +rg "flow_control" .workflow/ -B 2 -A 5 # Flow control patterns +find . -name "IMPL_PLAN.md" -exec grep -l "requirements" {} \; +``` + +### Performance Tips +- **rg > grep** for content search +- **Use --type filters** to limit file types +- **Exclude common dirs**: `--glob '!node_modules'` +- **Use -F for literal** strings (no regex) \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index d21d3a7a..7c6b86b3 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,6 +6,7 @@ This document defines project-specific coding standards and development principl ### CLI Tool Context Protocols For all CLI tool usage, command syntax, and integration guidelines: - **Intelligent Context Strategy**: @~/.claude/workflows/intelligent-tools-strategy.md +- **Context Search Commands**: @~/.claude/workflows/context-search-strategy.md **Context Requirements**: - Identify 3+ existing similar patterns before implementation