mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-14 02:42:04 +08:00
feat: Add -C parameter support for directory context in CLI tools
- Add -C parameter to gemini-wrapper for directory change before analysis - Update intelligent-tools-strategy.md to use -C (uppercase) consistently - Replace cd [directory] functionality with -C parameter throughout docs - Add directory context examples for both Gemini and Codex tools - Enhance context optimization strategy with -C parameter usage - Test confirms -C parameter works correctly with token analysis in target directory 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,8 @@
|
|||||||
# Location: ~/.claude/scripts/gemini-wrapper
|
# Location: ~/.claude/scripts/gemini-wrapper
|
||||||
#
|
#
|
||||||
# This wrapper automatically manages --all-files flag based on project token count
|
# This wrapper automatically manages --all-files flag based on project token count
|
||||||
# Usage: gemini-wrapper [all gemini options]
|
# Usage: gemini-wrapper [-C <directory>] [all gemini options]
|
||||||
|
# -C <directory> Change to specified directory before analysis (relative or absolute path)
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -38,19 +39,57 @@ count_tokens() {
|
|||||||
# Parse arguments to check for flags
|
# Parse arguments to check for flags
|
||||||
has_all_files=false
|
has_all_files=false
|
||||||
has_approval_mode=false
|
has_approval_mode=false
|
||||||
|
change_dir=""
|
||||||
args=()
|
args=()
|
||||||
|
|
||||||
# Check for existing flags
|
# Check for existing flags and -c parameter
|
||||||
for arg in "$@"; do
|
i=0
|
||||||
if [[ "$arg" == "--all-files" ]]; then
|
while [[ $i -lt $# ]]; do
|
||||||
|
arg="${!i}"
|
||||||
|
case "$arg" in
|
||||||
|
"--all-files")
|
||||||
has_all_files=true
|
has_all_files=true
|
||||||
elif [[ "$arg" == --approval-mode* ]]; then
|
|
||||||
has_approval_mode=true
|
|
||||||
fi
|
|
||||||
args+=("$arg")
|
args+=("$arg")
|
||||||
|
;;
|
||||||
|
--approval-mode*)
|
||||||
|
has_approval_mode=true
|
||||||
|
args+=("$arg")
|
||||||
|
;;
|
||||||
|
"-C")
|
||||||
|
# Next argument is the directory
|
||||||
|
i=$((i + 1))
|
||||||
|
if [[ $i -lt $# ]]; then
|
||||||
|
change_dir="${!i}"
|
||||||
|
echo -e "${YELLOW}📁 Directory change requested: $change_dir${NC}" >&2
|
||||||
|
else
|
||||||
|
echo -e "${RED}❌ Error: -C requires a directory path${NC}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
args+=("$arg")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
i=$((i + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
# Count tokens
|
# Change directory if requested
|
||||||
|
original_dir=""
|
||||||
|
if [[ -n "$change_dir" ]]; then
|
||||||
|
original_dir=$(pwd)
|
||||||
|
if [[ -d "$change_dir" ]]; then
|
||||||
|
echo -e "${GREEN}📁 Changing to directory: $change_dir${NC}" >&2
|
||||||
|
cd "$change_dir" || {
|
||||||
|
echo -e "${RED}❌ Error: Cannot change to directory: $change_dir${NC}" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
echo -e "${RED}❌ Error: Directory does not exist: $change_dir${NC}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Count tokens (in the target directory if -c was used)
|
||||||
echo -e "${YELLOW}🔍 Analyzing project size...${NC}" >&2
|
echo -e "${YELLOW}🔍 Analyzing project size...${NC}" >&2
|
||||||
read -r token_count file_count <<< "$(count_tokens)"
|
read -r token_count file_count <<< "$(count_tokens)"
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type: strategic-guideline
|
|||||||
- **When in doubt, use both** - Parallel usage provides comprehensive coverage
|
- **When in doubt, use both** - Parallel usage provides comprehensive coverage
|
||||||
- **Default to tools** - Use specialized tools for most coding tasks, no matter how small
|
- **Default to tools** - Use specialized tools for most coding tasks, no matter how small
|
||||||
- **Lower barriers** - Engage tools immediately when encountering any complexity
|
- **Lower barriers** - Engage tools immediately when encountering any complexity
|
||||||
- **Context optimization** - Based on user intent, determine whether to use `cd [directory]` for focused analysis to reduce irrelevant context import
|
- **Context optimization** - Based on user intent, determine whether to use `-C [directory]` parameter for focused analysis to reduce irrelevant context import
|
||||||
|
|
||||||
### Quick Decision Rules
|
### Quick Decision Rules
|
||||||
1. **Exploring/Understanding?** → Start with Gemini
|
1. **Exploring/Understanding?** → Start with Gemini
|
||||||
@@ -35,7 +35,7 @@ type: strategic-guideline
|
|||||||
### Standard Format (REQUIRED)
|
### Standard Format (REQUIRED)
|
||||||
```bash
|
```bash
|
||||||
# Gemini Analysis
|
# Gemini Analysis
|
||||||
~/.claude/scripts/gemini-wrapper -p "
|
~/.claude/scripts/gemini-wrapper [-C directory] -p "
|
||||||
PURPOSE: [clear analysis goal]
|
PURPOSE: [clear analysis goal]
|
||||||
TASK: [specific analysis task]
|
TASK: [specific analysis task]
|
||||||
CONTEXT: [file references and memory context]
|
CONTEXT: [file references and memory context]
|
||||||
@@ -44,7 +44,7 @@ RULES: [template reference and constraints]
|
|||||||
"
|
"
|
||||||
|
|
||||||
# Codex Development
|
# Codex Development
|
||||||
codex --full-auto exec "
|
codex [-C directory] --full-auto exec "
|
||||||
PURPOSE: [clear development goal]
|
PURPOSE: [clear development goal]
|
||||||
TASK: [specific development task]
|
TASK: [specific development task]
|
||||||
CONTEXT: [file references and memory context]
|
CONTEXT: [file references and memory context]
|
||||||
@@ -60,6 +60,13 @@ RULES: [template reference and constraints]
|
|||||||
- [ ] **EXPECTED** - Clear expected results
|
- [ ] **EXPECTED** - Clear expected results
|
||||||
- [ ] **RULES** - Template reference and constraints
|
- [ ] **RULES** - Template reference and constraints
|
||||||
|
|
||||||
|
### Directory Context (-C parameter)
|
||||||
|
Both tools support changing working directory before execution:
|
||||||
|
- **Gemini**: `~/.claude/scripts/gemini-wrapper -C path/to/project -p "prompt"`
|
||||||
|
- **Codex**: `codex -C path/to/project --full-auto exec "task"`
|
||||||
|
- **Path types**: Supports both relative (`../project`) and absolute (`/full/path`) paths
|
||||||
|
- **Token analysis**: For gemini-wrapper, token counting happens in target directory
|
||||||
|
|
||||||
### Rules Field Format
|
### Rules Field Format
|
||||||
```bash
|
```bash
|
||||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt) | [constraints]
|
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/[category]/[template].txt) | [constraints]
|
||||||
@@ -123,7 +130,7 @@ When planning any coding task, **ALWAYS** integrate CLI tools:
|
|||||||
|
|
||||||
### Common Scenarios
|
### Common Scenarios
|
||||||
```bash
|
```bash
|
||||||
# Project Analysis
|
# Project Analysis (in current directory)
|
||||||
~/.claude/scripts/gemini-wrapper -p "
|
~/.claude/scripts/gemini-wrapper -p "
|
||||||
PURPOSE: Understand codebase architecture
|
PURPOSE: Understand codebase architecture
|
||||||
TASK: Analyze project structure and identify patterns
|
TASK: Analyze project structure and identify patterns
|
||||||
@@ -132,8 +139,17 @@ EXPECTED: Architecture overview and integration points
|
|||||||
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Focus on integration points
|
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/architecture.txt) | Focus on integration points
|
||||||
"
|
"
|
||||||
|
|
||||||
# Feature Development
|
# Project Analysis (in different directory)
|
||||||
codex --full-auto exec "
|
~/.claude/scripts/gemini-wrapper -C ../other-project -p "
|
||||||
|
PURPOSE: Compare authentication patterns
|
||||||
|
TASK: Analyze auth implementation in related project
|
||||||
|
CONTEXT: @{src/auth/**/*} Current project context from session memory
|
||||||
|
EXPECTED: Pattern comparison and recommendations
|
||||||
|
RULES: $(cat ~/.claude/workflows/cli-templates/prompts/analysis/pattern.txt) | Focus on architectural differences
|
||||||
|
"
|
||||||
|
|
||||||
|
# Feature Development (in target directory)
|
||||||
|
codex -C path/to/project --full-auto exec "
|
||||||
PURPOSE: Implement user authentication
|
PURPOSE: Implement user authentication
|
||||||
TASK: Create JWT-based authentication system
|
TASK: Create JWT-based authentication system
|
||||||
CONTEXT: @{src/auth/**/*} Database schema from session memory
|
CONTEXT: @{src/auth/**/*} Database schema from session memory
|
||||||
@@ -191,18 +207,21 @@ For every development task:
|
|||||||
- **Document context** - Always reference CLAUDE.md for context
|
- **Document context** - Always reference CLAUDE.md for context
|
||||||
|
|
||||||
### Context Optimization Strategy
|
### Context Optimization Strategy
|
||||||
**Directory Navigation**: Use `cd [directory]` when analyzing specific areas to reduce irrelevant context
|
**Directory Navigation**: Use `-C [directory]` parameter when analyzing specific areas to reduce irrelevant context
|
||||||
|
|
||||||
**When to use `cd`**:
|
**When to use `-C`**:
|
||||||
- Specific directory mentioned → Navigate first
|
- Specific directory mentioned → Use `-C directory` parameter
|
||||||
- Focused analysis needed → Change to target directory
|
- Focused analysis needed → Target specific directory with `-C`
|
||||||
- Multi-directory scope → Stay in root, use explicit paths
|
- Multi-directory scope → Stay in root, use explicit paths or multiple commands
|
||||||
|
|
||||||
**Example**:
|
**Example**:
|
||||||
```bash
|
```bash
|
||||||
# Focused (preferred)
|
# Focused (preferred)
|
||||||
cd src/auth && ~/.claude/scripts/gemini-wrapper -p "analyze auth patterns"
|
~/.claude/scripts/gemini-wrapper -C src/auth -p "analyze auth patterns"
|
||||||
|
|
||||||
# Multi-scope
|
# Alternative for codex
|
||||||
|
codex -C src/auth --full-auto exec "analyze auth implementation"
|
||||||
|
|
||||||
|
# Multi-scope (stay in root)
|
||||||
~/.claude/scripts/gemini-wrapper -p "CONTEXT: @{src/auth/**/*,src/api/**/*}"
|
~/.claude/scripts/gemini-wrapper -p "CONTEXT: @{src/auth/**/*,src/api/**/*}"
|
||||||
```
|
```
|
||||||
@@ -114,7 +114,7 @@ All task files use this unified 5-field schema:
|
|||||||
|
|
||||||
"meta": {
|
"meta": {
|
||||||
"type": "feature|bugfix|refactor|test|docs",
|
"type": "feature|bugfix|refactor|test|docs",
|
||||||
"agent": "@code-developer|@planning-agent|@code-review-test-agent"
|
"agent": "code-developer|planning-agent|code-review-test-agent"
|
||||||
},
|
},
|
||||||
|
|
||||||
"context": {
|
"context": {
|
||||||
|
|||||||
Reference in New Issue
Block a user