Add comprehensive workflows for CLI tools usage, coding philosophy, context requirements, file modification, and CodexLens auto hybrid mode

- Introduced a detailed guide for intelligent tools selection strategy, including quick reference, tool specifications, prompt templates, and best practices for CLI execution.
- Established a coding philosophy document outlining core beliefs, simplicity principles, and guidelines for effective coding practices.
- Created context requirements documentation emphasizing the importance of understanding existing patterns and dependencies before implementation.
- Developed a file modification workflow detailing the use of edit_file and write_file MCP tools, along with priority logic for file reading and editing.
- Implemented CodexLens auto hybrid mode, enhancing the CLI with automatic vector embedding generation and default hybrid search mode based on embedding availability.
This commit is contained in:
catlog22
2025-12-17 09:53:30 +08:00
parent 154a9283b5
commit d06a3ca12e
18 changed files with 619 additions and 313 deletions

View File

@@ -1,6 +1,6 @@
# Claude Instructions
- **CLI Tools Usage**: @~/.claude/rules/cli-tools-usage.md
- **Coding Philosophy**: @~/.claude/rules/coding-philosophy.md
- **Context Requirements**: @~/.claude/rules/context-requirements.md
- **File Modification**: @~/.claude/rules/file-modification.md
- **CLI Tools Usage**: @~/.claude/workflows/cli-tools-usage.md
- **Coding Philosophy**: @~/.claude/workflows/coding-philosophy.md
- **Context Requirements**: @~/.claude/workflows/context-requirements.md
- **File Modification**: @~/.claude/workflows/file-modification.md

View File

@@ -542,8 +542,8 @@ The `implementation_approach` supports **two execution modes** based on the pres
- **Use for**: Large-scale features, complex refactoring, or when user explicitly requests CLI tool usage
- **Required fields**: Same as default mode **PLUS** `command`, `resume_from` (optional)
- **Command patterns** (with resume support):
- `ccw cli exec '[prompt]' --tool codex --mode auto --cd [path]`
- `ccw cli exec '[prompt]' --resume ${previousCliId} --tool codex --mode auto` (resume from previous)
- `ccw cli exec '[prompt]' --tool codex --mode write --cd [path]`
- `ccw cli exec '[prompt]' --resume ${previousCliId} --tool codex --mode write` (resume from previous)
- `ccw cli exec '[prompt]' --tool gemini --mode write --cd [path]` (write mode)
- **Resume mechanism**: When step depends on previous CLI execution, include `--resume` with previous execution ID
@@ -621,7 +621,7 @@ Agent determines CLI tool usage per-step based on user semantics and task nature
"step": 3,
"title": "Execute implementation using CLI tool",
"description": "Use Codex/Gemini for complex autonomous execution",
"command": "ccw cli exec '[prompt]' --tool codex --mode auto --cd [path]",
"command": "ccw cli exec '[prompt]' --tool codex --mode write --cd [path]",
"modification_points": ["[Same as default mode]"],
"logic_flow": ["[Same as default mode]"],
"depends_on": [1, 2],
@@ -634,7 +634,7 @@ Agent determines CLI tool usage per-step based on user semantics and task nature
"step": 4,
"title": "Continue implementation with context",
"description": "Resume from previous step with accumulated context",
"command": "ccw cli exec '[continuation prompt]' --resume ${step3_cli_id} --tool codex --mode auto",
"command": "ccw cli exec '[continuation prompt]' --resume ${step3_cli_id} --tool codex --mode write",
"resume_from": "step3_cli_id", // Reference previous step's CLI ID
"modification_points": ["[Continue from step 3]"],
"logic_flow": ["[Build on previous output]"],

View File

@@ -134,7 +134,7 @@ RULES: $(cat {selected_template}) | {constraints}
```
analyze|plan → gemini (qwen fallback) + mode=analysis
execute (simple|medium) → gemini (qwen fallback) + mode=write
execute (complex) → codex + mode=auto
execute (complex) → codex + mode=write
discuss → multi (gemini + codex parallel)
```
@@ -165,9 +165,9 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt)
ccw cli exec "..." --tool gemini --mode write --cd {dir}
```
**Codex (Auto)**:
**Codex (Write)**:
```bash
ccw cli exec "..." --tool codex --mode auto --cd {dir}
ccw cli exec "..." --tool codex --mode write --cd {dir}
```
**Cross-Directory** (Gemini/Qwen):

View File

@@ -123,7 +123,7 @@ When task JSON contains `flow_control.implementation_approach` array:
**CLI Command Execution (CLI Execute Mode)**:
When step contains `command` field with Codex CLI, execute via CCW CLI. For Codex resume:
- First task (`depends_on: []`): `ccw cli exec "..." --tool codex --mode auto --cd [path]`
- First task (`depends_on: []`): `ccw cli exec "..." --tool codex --mode write --cd [path]`
- Subsequent tasks (has `depends_on`): Use CCW CLI with resume context to maintain session
**Test-Driven Development**:

View File

@@ -241,7 +241,7 @@ api_id=$((group_count + 3))
**Command Patterns**:
- Gemini/Qwen: `ccw cli exec "..." --tool gemini --cd dir`
- CLI Mode: `ccw cli exec "..." --tool gemini --mode write --cd dir`
- Codex: `ccw cli exec "..." --tool codex --mode auto --cd dir`
- Codex: `ccw cli exec "..." --tool codex --mode write --cd dir`
**Generation Process**:
1. Read configuration values (tool, cli_execute, mode) from workflow-session.json

View File

@@ -473,7 +473,7 @@ Detailed plan: ${executionContext.session.artifacts.plan}`)
return prompt
}
ccw cli exec "${buildCLIPrompt(batch)}" --tool codex --mode auto
ccw cli exec "${buildCLIPrompt(batch)}" --tool codex --mode write
```
**Execution with fixed IDs** (predictable ID pattern):
@@ -496,8 +496,8 @@ const previousCliId = batch.resumeFromCliId || null
// Build command with fixed ID (and optional resume for continuation)
const cli_command = previousCliId
? `ccw cli exec "${buildCLIPrompt(batch)}" --tool codex --mode auto --id ${fixedExecutionId} --resume ${previousCliId}`
: `ccw cli exec "${buildCLIPrompt(batch)}" --tool codex --mode auto --id ${fixedExecutionId}`
? `ccw cli exec "${buildCLIPrompt(batch)}" --tool codex --mode write --id ${fixedExecutionId} --resume ${previousCliId}`
: `ccw cli exec "${buildCLIPrompt(batch)}" --tool codex --mode write --id ${fixedExecutionId}`
bash_result = Bash(
command=cli_command,
@@ -519,7 +519,7 @@ if (bash_result.status === 'failed' || bash_result.status === 'timeout') {
⚠️ Execution incomplete. Resume available:
Fixed ID: ${fixedExecutionId}
Lookup: ccw cli detail ${fixedExecutionId}
Resume: ccw cli exec "Continue tasks" --resume ${fixedExecutionId} --tool codex --mode auto --id ${fixedExecutionId}-retry
Resume: ccw cli exec "Continue tasks" --resume ${fixedExecutionId} --tool codex --mode write --id ${fixedExecutionId}-retry
`)
// Store for potential retry in same session
@@ -582,7 +582,7 @@ ccw cli exec "[Shared Prompt Template with artifacts]" --tool qwen --mode analys
# Same prompt as Gemini, different execution engine
# Method 4: Codex Review (autonomous)
ccw cli exec "[Verify plan acceptance criteria at ${plan.json}]" --tool codex --mode auto
ccw cli exec "[Verify plan acceptance criteria at ${plan.json}]" --tool codex --mode write
```
**Multi-Round Review with Fixed IDs**:
@@ -744,5 +744,5 @@ Appended to `previousExecutionResults` array for context continuity in multi-exe
ccw cli detail ${fixedCliId}
# Resume with new fixed ID for retry
ccw cli exec "Continue from where we left off" --resume ${fixedCliId} --tool codex --mode auto --id ${fixedCliId}-retry
ccw cli exec "Continue from where we left off" --resume ${fixedCliId} --tool codex --mode write --id ${fixedCliId}-retry
```

View File

@@ -255,7 +255,7 @@ Based on userConfig.executionMethod:
CLI Resume Support (MANDATORY for all CLI commands):
- Use --resume parameter to continue from previous task execution
- Read previous task's cliExecutionId from session state
- Format: ccw cli exec "[prompt]" --resume ${previousCliId} --tool ${tool} --mode auto
- Format: ccw cli exec "[prompt]" --resume ${previousCliId} --tool ${tool} --mode write
## EXPLORATION CONTEXT (from context-package.exploration_results)
- Load exploration_results from context-package.json

View File

@@ -1,47 +0,0 @@
# Context Requirements
Before implementation, always:
- Identify 3+ existing similar patterns before implementation
- Map dependencies and integration points
- Understand testing framework and coding conventions
## Context Gathering
### Use Exa
- Researching external APIs, libraries, frameworks
- Need recent documentation beyond knowledge cutoff
- Looking for implementation examples in public repos
- User mentions specific library/framework names
- Questions about "best practices" or "how does X work"
### Use read_file (MCP)
- Reading multiple related files at once
- Directory traversal with pattern matching
- Searching file content with regex
- Need to limit depth/file count for large directories
- Batch operations on multiple files
- Pattern-based filtering (glob + content regex)
### Use codex_lens
- Large codebase (>500 files) requiring repeated searches
- Need semantic understanding of code relationships
- Working across multiple sessions
- Symbol-level navigation needed
- Finding all implementations of interface/class
- Tracking function calls across codebase
### Use smart_search
- Unknown file locations
- Concept/semantic search ("authentication logic", "payment processing")
- Medium-sized codebase (100-500 files)
- One-time or infrequent searches
- Natural language queries about code structure
**Mode Selection**:
- `auto`: Let tool decide (default)
- `exact`: Known exact pattern
- `fuzzy`: Typo-tolerant search
- `semantic`: Concept-based search
- `graph`: Dependency analysis

View File

@@ -17,11 +17,11 @@
```
┌─ Task Analysis/Documentation?
│ └─→ Use Gemini (Fallback: Codex,Qwen)
│ └─→ MODE: analysis (default, read-only)
│ └─→ MODE: analysis (read-only)
└─ Task Implementation/Bug Fix?
└─→ Use Codex (Fallback: Gemini,Qwen)
└─→ MODE: auto (full operations) or write (file operations)
└─→ Use Codex (Fallback: Gemini,Qwen)
└─→ MODE: write (file operations)
```
@@ -30,10 +30,10 @@
```
PURPOSE: [what] + [why] + [success criteria] + [constraints/scope]
TASK: • [step 1: specific action] • [step 2: specific action] • [step 3: specific action]
MODE: [analysis|write|auto]
MODE: [analysis|write]
CONTEXT: @[file patterns] | Memory: [session/tech/module context]
EXPECTED: [deliverable format] + [quality criteria] + [structure requirements]
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt) | [domain constraints] | MODE=[permission]
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/[mode]-protocol.md) $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt) | [domain constraints]
```
### Intent Capture Checklist (Before CLI Execution)
@@ -54,20 +54,15 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt
- MODE: `analysis`
- When to Use: Code review, architecture analysis, pattern discovery, exploration
- **Write/Create**
- Tool: Gemini/Qwen
- **Write/Implement**
- Tool: Codex (Fallback: Gemini/Qwen)
- MODE: `write`
- When to Use: Documentation generation, file creation (non-code)
- **Implement/Fix**
- Tool: Codex
- MODE: `auto`
- When to Use: Feature implementation, bug fixes, test creation, refactoring
- When to Use: Feature implementation, bug fixes, test creation, refactoring, documentation generation, file creation
## Essential Command Structure
```bash
ccw cli exec "<PROMPT>" --tool <gemini|qwen|codex> --mode <analysis|write|auto>
ccw cli exec "<PROMPT>" --tool <gemini|qwen|codex> --mode <analysis|write>
```
**⚠️ CRITICAL**: `--mode` parameter is **MANDATORY** for all CLI executions. No defaults are assumed.
@@ -76,9 +71,9 @@ ccw cli exec "<PROMPT>" --tool <gemini|qwen|codex> --mode <analysis|write|auto>
- **Use tools early and often** - Tools are faster and more thorough
- **Unified CLI** - Always use `ccw cli exec` for consistent parameter handling
- **Mode is MANDATORY** - ALWAYS explicitly specify `--mode analysis|write|auto` (no implicit defaults)
- **Mode is MANDATORY** - ALWAYS explicitly specify `--mode analysis|write` (no implicit defaults)
- **One template required** - ALWAYS reference exactly ONE template in RULES (use universal fallback if no specific match)
- **Write protection** - Require EXPLICIT `--mode write` or `--mode auto`
- **Write protection** - Require EXPLICIT `--mode write` for file operations
- **No escape characters** - NEVER use `\$`, `\"`, `\'` in CLI commands
---
@@ -88,41 +83,52 @@ ccw cli exec "<PROMPT>" --tool <gemini|qwen|codex> --mode <analysis|write|auto>
### MODE Options
- **`analysis`**
- Permission: Read-only (default)
- Use For: Code review, architecture analysis, pattern discovery
- Specification: Auto for Gemini/Qwen
- Permission: Read-only
- Use For: Code review, architecture analysis, pattern discovery, exploration
- Specification: Safe for all tools (Gemini/Qwen/Codex)
- **`write`**
- Permission: Create/Modify/Delete
- Use For: Documentation, code creation, file modifications
- Specification: Requires `--mode write`
- **`auto`**
- Permission: Full operations
- Use For: Feature implementation, bug fixes, autonomous development
- Specification: Codex only, requires `--mode auto`
- Use For: Feature implementation, bug fixes, documentation, code creation, file modifications
- Specification: Requires explicit `--mode write`
### Mode Protocol References (MANDATORY)
**⚠️ REQUIRED**: Every CLI execution MUST include the corresponding mode protocol in RULES:
- **`analysis`**
- Protocol (REQUIRED): `$(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md)`
#### Mode Rule= Templates
- **`write/auto`**
- Protocol (REQUIRED): `$(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md)`
**Purpose**: Mode protocols define permission boundaries and operational constraints for each execution mode.
**Protocol Mapping**:
- **`analysis`** mode
- Protocol: `$(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md)`
- Permission: Read-only operations
- Enforces: No file creation/modification/deletion
- **`write`** mode
- Protocol: `$(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md)`
- Permission: Create/Modify/Delete files
- Enforces: Explicit write authorization and full workflow execution capability
**RULES Format** (protocol MUST be included):
```bash
# Analysis mode - MUST include analysis-protocol.md
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md) $(cat ~/.claude/workflows/cli-templates/prompts/analysis/...) | constraints
# Write/Auto mode - MUST include write-protocol.md
# Write mode - MUST include write-protocol.md
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(cat ~/.claude/workflows/cli-templates/prompts/development/...) | constraints
```
**Validation**: CLI execution without mode protocol reference is INVALID
**Why Mode Rules Are Required**:
- Ensures consistent permission enforcement across all tools (Gemini/Qwen/Codex)
- Prevents accidental file modifications during analysis tasks
- Provides explicit authorization trail for write operations
- Enables safe automation with clear boundaries
### Gemini & Qwen
**Via CCW**: `ccw cli exec "<prompt>" --tool gemini --mode analysis` or `--tool qwen --mode analysis`
@@ -141,12 +147,12 @@ RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(ca
### Codex
**Via CCW**: `ccw cli exec "<prompt>" --tool codex --mode auto`
**Via CCW**: `ccw cli exec "<prompt>" --tool codex --mode write`
**Characteristics**:
- Autonomous development, mathematical reasoning
- Best for: Implementation, testing, automation
- No default MODE - must explicitly specify `--mode write` or `--mode auto`
- Best for: Implementation, testing, automation, bug fixes
- No default MODE - must explicitly specify `--mode analysis` or `--mode write`
**Models**: `gpt-5.2`
@@ -156,7 +162,7 @@ RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(ca
```bash
ccw cli exec "Continue analyzing" --tool gemini --mode analysis --resume # Resume last session
ccw cli exec "Fix issues found" --tool codex --mode auto --resume <id> # Resume specific session
ccw cli exec "Fix issues found" --tool codex --mode write --resume <id> # Resume specific session
```
- **`--resume` (empty)**: Resume most recent session
@@ -212,10 +218,10 @@ Every command MUST include these fields:
- Good Example: "Markdown report with: severity levels (Critical/High/Medium/Low), file:line references, remediation code snippets, priority ranking"
- **RULES**
- Purpose: Template + constraints
- Components: $(cat template) + domain rules
- Purpose: Protocol + template + constraints
- Components: $(cat protocol) + $(cat template) + domain rules
- Bad Example: (missing)
- Good Example: "$(cat ~/.claude/.../security.txt) \| Focus on authentication \| Ignore test files \| analysis=READ-ONLY"
- Good Example: "$(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md) $(cat ~/.claude/workflows/cli-templates/prompts/analysis/03-assess-security-risks.txt) \| Focus on authentication \| Ignore test files"
### CONTEXT Configuration
@@ -334,7 +340,7 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/universal/00-universal-ri
- Default: gemini
- **`--mode <mode>`**
- Description: **REQUIRED**: analysis, write, auto
- Description: **REQUIRED**: analysis, write
- Default: **NONE** (must specify)
- **`--model <model>`**
@@ -400,14 +406,14 @@ CCW automatically maps to tool-specific syntax:
- Gemini/Qwen: `--include-directories`
- Codex: `--add-dir` (per dir)
- **`--mode analysis`**
- Gemini/Qwen: (default read-only)
- Codex: (default read-only)
- **`--mode write`**
- Gemini/Qwen: `--approval-mode yolo`
- Codex: `-s danger-full-access`
- **`--mode auto`**
- Gemini/Qwen: N/A
- Codex: `-s danger-full-access`
### Command Examples
#### Task-Type Specific Templates
@@ -420,7 +426,7 @@ TASK: • Scan for injection flaws (SQL, command, LDAP) • Check authentication
MODE: analysis
CONTEXT: @src/auth/**/* @src/middleware/auth.ts | Memory: Using bcrypt for passwords, JWT for sessions
EXPECTED: Security report with: severity matrix, file:line references, CVE mappings where applicable, remediation code snippets prioritized by risk
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/03-assess-security-risks.txt) | Focus on authentication | Ignore test files | analysis=READ-ONLY
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md) $(cat ~/.claude/workflows/cli-templates/prompts/analysis/03-assess-security-risks.txt) | Focus on authentication | Ignore test files
" --tool gemini --cd src/auth --timeout 600000
```
@@ -429,11 +435,11 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/03-assess-securi
ccw cli exec "
PURPOSE: Implement rate limiting for API endpoints to prevent abuse; must be configurable per-endpoint; backward compatible with existing clients
TASK: • Create rate limiter middleware with sliding window • Implement per-route configuration • Add Redis backend for distributed state • Include bypass for internal services
MODE: auto
MODE: write
CONTEXT: @src/middleware/**/* @src/config/**/* | Memory: Using Express.js, Redis already configured, existing middleware pattern in auth.ts
EXPECTED: Production-ready code with: TypeScript types, unit tests, integration test, configuration example, migration guide
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/development/02-implement-feature.txt) | Follow existing middleware patterns | No breaking changes | auto=FULL
" --tool codex --mode auto --timeout 1800000
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(cat ~/.claude/workflows/cli-templates/prompts/development/02-implement-feature.txt) | Follow existing middleware patterns | No breaking changes
" --tool codex --mode write --timeout 1800000
```
**Bug Fix Task**:
@@ -444,7 +450,7 @@ TASK: • Trace connection lifecycle from open to close • Identify event liste
MODE: analysis
CONTEXT: @src/websocket/**/* @src/services/connection-manager.ts | Memory: Using ws library, ~5000 concurrent connections in production
EXPECTED: Root cause analysis with: memory profile, leak source (file:line), fix recommendation with code, verification steps
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt) | Focus on resource cleanup | analysis=READ-ONLY
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md) $(cat ~/.claude/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt) | Focus on resource cleanup
" --tool gemini --cd src --timeout 900000
```
@@ -456,7 +462,7 @@ TASK: • Extract gateway interface from current implementation • Create strat
MODE: write
CONTEXT: @src/payments/**/* @src/types/payment.ts | Memory: Currently only Stripe, adding PayPal next sprint, must support future gateways
EXPECTED: Refactored code with: strategy interface, concrete implementations, factory class, updated tests, migration checklist
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/development/02-refactor-codebase.txt) | Preserve all existing behavior | Tests must pass | write=CREATE/MODIFY/DELETE
RULES: $(cat ~/.claude/workflows/cli-templates/protocols/write-protocol.md) $(cat ~/.claude/workflows/cli-templates/prompts/development/02-refactor-codebase.txt) | Preserve all existing behavior | Tests must pass
" --tool gemini --mode write --timeout 1200000
```
---
@@ -483,7 +489,7 @@ RULES: $(cat ~/.claude/workflows/cli-templates/prompts/development/02-refactor-c
```bash
ccw cli exec "<prompt>" --tool gemini --mode analysis --timeout 600000 # 10 min
ccw cli exec "<prompt>" --tool codex --mode auto --timeout 1800000 # 30 min
ccw cli exec "<prompt>" --tool codex --mode write --timeout 1800000 # 30 min
```
### Permission Framework
@@ -492,8 +498,7 @@ ccw cli exec "<prompt>" --tool codex --mode auto --timeout 1800000 # 30 min
**Mode Hierarchy**:
- `analysis`: Read-only, safe for auto-execution
- `write`: Create/Modify/Delete files - requires explicit `--mode write`
- `auto`: Full operations - requires explicit `--mode auto`
- `write`: Create/Modify/Delete files, full operations - requires explicit `--mode write`
- **Exception**: User provides clear instructions like "modify", "create", "implement"
---
@@ -512,15 +517,15 @@ ccw cli exec "<prompt>" --tool codex --mode auto --timeout 1800000 # 30 min
### Workflow Integration
- **Understanding**: `ccw cli exec "<prompt>" --tool gemini`
- **Architecture**: `ccw cli exec "<prompt>" --tool gemini`
- **Implementation**: `ccw cli exec "<prompt>" --tool codex --mode auto`
- **Understanding**: `ccw cli exec "<prompt>" --tool gemini --mode analysis`
- **Architecture**: `ccw cli exec "<prompt>" --tool gemini --mode analysis`
- **Implementation**: `ccw cli exec "<prompt>" --tool codex --mode write`
- **Quality**: `ccw cli exec "<prompt>" --tool codex --mode write`
### Planning Checklist
- [ ] **Purpose defined** - Clear goal and intent
- [ ] **Mode selected** - `--mode analysis|write|auto`
- [ ] **Mode selected** - `--mode analysis|write`
- [ ] **Context gathered** - File references + memory (default `@**/*`)
- [ ] **Directory navigation** - `--cd` and/or `--includeDirs`
- [ ] **Tool selected** - `--tool gemini|qwen|codex`

View File

@@ -0,0 +1,44 @@
# Context Requirements
Before implementation, always:
- Identify 3+ existing similar patterns
- Map dependencies and integration points
- Understand testing framework and coding conventions
## Context Gathering
**MANDATORY**: Use `codex_lens` (MCP tool) for all code search and analysis.
### codex_lens (REQUIRED)
**MCP Actions**: `init`, `search`, `search_files` (Advanced ops via CLI: `codexlens --help`)
**Initialize**:
```
codex_lens(action="init", path=".")
```
- Auto-generates embeddings if `fastembed` installed
- Skip with `--no-embeddings` flag
**Search** (Auto hybrid mode):
```
codex_lens(action="search", query="authentication")
```
**Search Files**:
```
codex_lens(action="search_files", query="payment")
```
### read_file (MCP)
- Read files found by codex_lens
- Directory traversal with patterns
- Batch operations
### smart_search
- Fallback when codex_lens unavailable
- Small projects (<100 files)
### Exa
- External APIs, libraries, frameworks
- Recent documentation beyond knowledge cutoff
- Public implementation examples

View File

@@ -1,56 +0,0 @@
# Context Search Strategy
## ⚡ Execution Environment
**CRITICAL**: All commands execute in **Bash environment** (Git Bash on Windows)
**❌ Forbidden**: Windows commands (`findstr`, `dir`, `where`) - Use Bash (`grep`, `find`, `cat`)
## ⚡ Core Search Tools
**Skill()**: FASTEST way to get context - use FIRST if SKILL exists. Three types: (1) `workflow-progress` for WFS sessions (2) tech SKILLs for stack docs (3) `{project-name}` for project docs
**codebase-retrieval**: Semantic file discovery via Gemini CLI with all files analysis
**rg (ripgrep)**: Fast content search with regex support
**find**: File/directory location by name patterns
**grep**: Built-in pattern matching (fallback when rg unavailable)
**get_modules_by_depth**: Program architecture analysis (MANDATORY before planning)
## 🔧 Quick Command Reference
```bash
# Semantic File Discovery (codebase-retrieval via CCW)
ccw cli exec "
PURPOSE: Discover files relevant to task/feature
TASK: • List all files related to [task/feature description]
MODE: analysis
CONTEXT: @**/*
EXPECTED: Relevant file paths with relevance explanation
RULES: Focus on direct relevance to task requirements | analysis=READ-ONLY
" --tool gemini --cd [directory]
# Program Architecture (MANDATORY before planning)
ccw tool exec get_modules_by_depth '{}'
# Content Search (rg preferred)
rg "pattern" --type js -n # Search JS files with line numbers
rg -i "case-insensitive" # Ignore case
rg -C 3 "context" # Show 3 lines before/after
# File Search
find . -name "*.ts" -type f # Find TypeScript files
find . -path "*/node_modules" -prune -o -name "*.js" -print
# Workflow Examples
rg "IMPL-\d+" .workflow/ --type json # Find task IDs
find .workflow/ -name "*.json" -path "*/.task/*" # Locate task files
rg "status.*pending" .workflow/.task/ # Find pending tasks
```
## ⚡ Performance Tips
- **rg > grep** for content search
- **Use --type filters** to limit file types
- **Exclude dirs**: `--glob '!node_modules'`
- **Use -F** for literal strings (no regex)