mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
Fix session management location inference and ccw command usage
This commit addresses multiple issues in session management and command documentation: Session Management Fixes: - Add auto-inference of location from type parameter in session.ts - When --type lite-plan/lite-fix is specified, automatically set location accordingly - Preserve explicit --location parameter when provided - Update session-manager.ts to support type-based location inference - Fix metadata filename selection (session-metadata.json vs workflow-session.json) Command Documentation Fixes: - Add missing --mode analysis parameter (3 locations): * commands/memory/docs.md * commands/workflow/lite-execute.md (2 instances) - Add missing --mode write parameter (4 locations): * commands/workflow/tools/task-generate-agent.md - Remove non-existent subcommands (3 locations): * commands/workflow/session/complete.md (manifest, project) - Update session command syntax to use simplified format: * Changed from 'ccw session manifest read' to 'test -f' checks * Changed from 'ccw session project read' to 'test -f' checks Documentation Updates: - Update lite-plan.md and lite-fix.md to use --type parameter - Update session/start.md to document lite-plan and lite-fix types - Sync all fixes to skills/command-guide/reference directory (84 files) All ccw command usage across the codebase is now consistent and correct. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -74,7 +74,7 @@ ccw cli exec "<PROMPT>" --tool <gemini|qwen|codex> --mode <analysis|write>
|
||||
- **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` for file operations
|
||||
- **No escape characters** - NEVER use `\$`, `\"`, `\'` in CLI commands
|
||||
- **Use double quotes for shell expansion** - Always wrap prompts in double quotes `"..."` to enable `$(cat ...)` command substitution; NEVER use single quotes or escape characters (`\$`, `\"`, `\'`)
|
||||
|
||||
---
|
||||
|
||||
@@ -276,9 +276,22 @@ ccw cli exec "..." --tool gemini --mode analysis --cd src
|
||||
- `universal/00-universal-creative-style.txt` - For exploratory tasks
|
||||
|
||||
**Command Substitution Rules**:
|
||||
- Use `$(cat ...)` directly - do NOT read template content first
|
||||
- NEVER use escape characters: `\$`, `\"`, `\'`
|
||||
- Tilde expands correctly in prompt context
|
||||
- Use `$(cat ...)` directly in **double quotes** - command substitution executes in your local shell BEFORE passing to ccw
|
||||
- Shell expands `$(cat ...)` into file content automatically - do NOT read template content first
|
||||
- NEVER use escape characters (`\$`, `\"`, `\'`) or single quotes - these prevent shell expansion
|
||||
- Tilde (`~`) expands correctly in prompt context
|
||||
|
||||
**Critical**: Use double quotes `"..."` around the entire prompt to enable `$(cat ...)` expansion:
|
||||
```bash
|
||||
# ✓ CORRECT - double quotes allow shell expansion
|
||||
ccw cli exec "RULES: $(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md) ..." --tool gemini
|
||||
|
||||
# ✗ WRONG - single quotes prevent expansion
|
||||
ccw cli exec 'RULES: $(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md) ...' --tool gemini
|
||||
|
||||
# ✗ WRONG - escaped $ prevents expansion
|
||||
ccw cli exec "RULES: \$(cat ~/.claude/workflows/cli-templates/protocols/analysis-protocol.md) ..." --tool gemini
|
||||
```
|
||||
|
||||
**Examples**:
|
||||
```bash
|
||||
|
||||
@@ -5,40 +5,67 @@ Before implementation, always:
|
||||
- Map dependencies and integration points
|
||||
- Understand testing framework and coding conventions
|
||||
|
||||
## Context Gathering
|
||||
## MCP Tools Usage
|
||||
|
||||
**MANDATORY**: Use `codex_lens` (MCP tool) for all code search and analysis.
|
||||
### smart_search - Code Search (REQUIRED)
|
||||
|
||||
### codex_lens (REQUIRED)
|
||||
**When**: Find code, understand codebase structure, locate implementations
|
||||
|
||||
**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")
|
||||
**How**:
|
||||
```javascript
|
||||
smart_search(query="authentication logic") // Auto mode (recommended)
|
||||
smart_search(action="init", path=".") // First-time setup
|
||||
smart_search(query="LoginUser", mode="exact") // Precise matching
|
||||
smart_search(query="import", mode="ripgrep") // Fast, no index
|
||||
```
|
||||
|
||||
### read_file (MCP)
|
||||
- Read files found by codex_lens
|
||||
- Directory traversal with patterns
|
||||
- Batch operations
|
||||
**Modes**: `auto` (intelligent routing), `hybrid` (best quality), `exact` (FTS), `ripgrep` (fast)
|
||||
|
||||
### smart_search
|
||||
- Fallback when codex_lens unavailable
|
||||
- Small projects (<100 files)
|
||||
---
|
||||
|
||||
### Exa
|
||||
- External APIs, libraries, frameworks
|
||||
- Recent documentation beyond knowledge cutoff
|
||||
- Public implementation examples
|
||||
### read_file - Read File Contents
|
||||
|
||||
**When**: Read files found by smart_search
|
||||
|
||||
**How**:
|
||||
```javascript
|
||||
read_file(path="/path/to/file.ts") // Single file
|
||||
read_file(path="/src/**/*.config.ts") // Pattern matching
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### edit_file - Modify Files
|
||||
|
||||
**When**: Built-in Edit tool fails or need advanced features
|
||||
|
||||
**How**:
|
||||
```javascript
|
||||
edit_file(path="/file.ts", old_string="...", new_string="...", mode="update")
|
||||
edit_file(path="/file.ts", line=10, content="...", mode="insert_after")
|
||||
```
|
||||
|
||||
**Modes**: `update` (replace text), `insert_after`, `insert_before`, `delete_line`
|
||||
|
||||
---
|
||||
|
||||
### write_file - Create/Overwrite Files
|
||||
|
||||
**When**: Create new files or completely replace content
|
||||
|
||||
**How**:
|
||||
```javascript
|
||||
write_file(path="/new-file.ts", content="...")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Exa - External Search
|
||||
|
||||
**When**: Find documentation/examples outside codebase
|
||||
|
||||
**How**:
|
||||
```javascript
|
||||
exa(query="React hooks 2025 documentation")
|
||||
exa(query="FastAPI auth example github")
|
||||
```
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
1. Known single file → Built-in Read
|
||||
2. Multiple files OR pattern matching → read_file (MCP)
|
||||
3. Unknown location → smart_search then Read
|
||||
4. Large codebase + repeated access → codex_lens
|
||||
4. Large codebase + repeated access → smart_search (indexed)
|
||||
|
||||
**File Editing**:
|
||||
1. Always try built-in Edit first
|
||||
@@ -36,7 +36,7 @@
|
||||
1. External knowledge → Exa
|
||||
2. Exact pattern in small codebase → Built-in Grep
|
||||
3. Semantic/unknown location → smart_search
|
||||
4. Large codebase + repeated searches → codex_lens
|
||||
4. Large codebase + repeated searches → smart_search (indexed)
|
||||
|
||||
## Decision Triggers
|
||||
|
||||
@@ -46,48 +46,3 @@
|
||||
**Use indexed search** for large, stable codebases
|
||||
**Use Exa** for external/public knowledge
|
||||
|
||||
## ⚡ Core Search Tools
|
||||
|
||||
**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)
|
||||
|
||||
Reference in New Issue
Block a user