feat: 增加文件模式参考和复杂模式发现的示例,增强 CLI 命令的文档

This commit is contained in:
catlog22
2025-10-05 10:26:08 +08:00
parent 7d9adf5a55
commit a9d6de228e
7 changed files with 291 additions and 34 deletions

View File

@@ -46,6 +46,39 @@ The code-analysis template provides:
- **Logical Reasoning**: Explain "why" behind code behavior
- **Debugging Insights**: Identify potential bugs or inefficiencies
## File Pattern Reference
### Common Patterns
- All files: `@{**/*}`
- Source files: `@{src/**/*}`
- TypeScript: `@{*.ts,*.tsx}`
- JavaScript: `@{*.js,*.jsx}`
- Python: `@{*.py}`
- With docs: `@{CLAUDE.md,**/*CLAUDE.md}`
- Tests: `@{**/*.test.*,**/*.spec.*}`
### Complex Pattern Discovery
For deep code analysis, use semantic discovery to trace execution paths:
```bash
# Step 1: Find entry points and related files
rg "function.*authenticate|class.*AuthService" --files-with-matches
mcp__code-index__search_code_advanced(pattern="authenticate|login", file_pattern="*.ts")
# Step 2: Trace execution flow through discovered files
# Build call graph: entry → middleware → service → repository
# Step 3: Execute analysis with focused context
cd src && ~/.claude/scripts/gemini-wrapper --all-files -p "
PURPOSE: Trace authentication execution flow
TASK: Analyze complete auth flow from request to response
MODE: analysis
CONTEXT: @{CLAUDE.md,api/auth.ts,middleware/auth.ts,services/auth.ts}
EXPECTED: Step-by-step execution trace with call diagram
RULES: $(cat ~/.claude/prompt-templates/code-analysis.md) | Focus on control flow
"
```
## Command Templates
### Gemini (Default)