{"id":"search-hierarchy","name":"search-hierarchy","summary":"検索ツールの階層","body":"# Search Tool Hierarchy\n\nUse the most token-efficient search tool for each query type.\n\n## Decision Tree\n\n```\nQuery Type?\n├── STRUCTURAL (code patterns)\n│   → AST-grep (~50 tokens output)\n│   Examples: \"def foo\", \"class Bar\", \"import X\", \"@decorator\"\n│\n├── SEMANTIC (conceptual questions)\n│   → LEANN (~100 tokens if path-only)\n│   Examples: \"how does auth work\", \"find error handling patterns\"\n│\n├── LITERAL (exact identifiers)\n│   → Grep (variable output)\n│   Examples: \"TemporalMemory\", \"check_evocation\", regex patterns\n│\n└── FULL CONTEXT (need complete understanding)\n    → Read (1500+ tokens)\n    Last resort after finding the right file\n```\n\n## Token Efficiency Comparison\n\n| Tool | Output Size | Best For |\n|------|-------------|----------|\n| AST-grep | ~50 tokens | Function/class definitions, imports, decorators |\n| LEANN | ~100 tokens | Conceptual questions, architecture, patterns |\n| Grep | ~200-2000 | Exact identifiers, regex, file paths |\n| Read | ~1500+ | Full understanding after finding the file |\n\n## Hook Enforcement\n\nThe `grep-to-leann.sh` hook automatically:\n1. Detects query type (structural/semantic/literal)\n2. Blocks and suggests AST-grep for structural queries\n3. Blocks and suggests LEANN for semantic queries\n4. Allows literal patterns through to Grep\n\n## DO\n\n- Start with AST-grep for code structure questions\n- Use LEANN for \"how does X work\" questions\n- Use Grep only for exact identifier matches\n- Read files only after finding them via search\n\n## DON'T\n\n- Use Grep for conceptual questions (returns nothing)\n- Read files before knowing which ones are relevant\n- Use Read when AST-grep would give file:line\n- Ignore hook suggestions\n\n## Examples\n\n```bash\n# STRUCTURAL → AST-grep\nast-grep --pattern \"async def $FUNC($$$):\" --lang python\n\n# SEMANTIC → LEANN\nleann search opc-dev \"how does authentication work\" --top-k 3\n\n# LITERAL → Grep\nGrep pattern=\"check_evocation\" path=opc/scripts\n\n# FULL CONTEXT → Read (after finding file)\nRead file_path=opc/scripts/z3_erotetic.py\n```\n\n## Optimal Flow\n\n```\n1. AST-grep: \"Find async functions\" → 3 file:line matches\n2. Read: Top match only → Full understanding\n3. Skip: 4 irrelevant files → 6000 tokens saved\n```","author":"@parcadei","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/parcadei/Continuous-Claude-v3/tree/main/.claude/skills/archive/search-hierarchy","license":"MIT","category":"coding","lang":"en","tokens":568,"stars":0,"calls30d":2,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":[]}}