Files
Claude-Code-Workflow/.claude/workflows/file-modification.md
catlog22 c16da759b2 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>
2025-12-17 18:09:23 +08:00

49 lines
1.4 KiB
Markdown

## File Modification
### Use edit_file (MCP)
- Built-in Edit tool failed 1+ times
- Need dry-run preview before applying changes
- Need line-based operations (insert_after, insert_before)
- Need to replace all occurrences at once
- Built-in Edit returns "old_string not found"
- Whitespace/formatting issues in built-in Edit
**Mode Selection**:
- `mode=update`: Replace text
- `mode=line`: Line-based operations
### Use write_file (MCP)
- Creating brand new files
- MCP edit_file still fails (last resort)
- Need to completely replace file content
- Need backup before overwriting
- User explicitly asks to "recreate file"
## Priority Logic
**File Reading**:
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 → smart_search (indexed)
**File Editing**:
1. Always try built-in Edit first
2. Fails 1+ times → edit_file (MCP)
3. Still fails → write_file (MCP)
**Search**:
1. External knowledge → Exa
2. Exact pattern in small codebase → Built-in Grep
3. Semantic/unknown location → smart_search
4. Large codebase + repeated searches → smart_search (indexed)
## Decision Triggers
**Start with simplest tool** (Read, Edit, Grep)
**Escalate to MCP tools** when built-ins fail or inappropriate
**Use semantic search** for exploratory tasks
**Use indexed search** for large, stable codebases
**Use Exa** for external/public knowledge