修复内容:
- 将位置参数格式改为JSON格式: ccw tool exec tool '{"param":"value"}'
- 修复双引号字符串内的JSON引号转义问题
- 更新deprecated脚本的使用示例
受影响文件:
- commands/memory/update-full.md, docs-full-cli.md, docs-related-cli.md, update-related.md
- commands/workflow/ui-design/generate.md, import-from-code.md
- scripts/*.sh (9个deprecated脚本)
- skills/command-guide/reference/* (通过analyze_commands.py自动同步)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
12 KiB
name, description, argument-hint, allowed-tools
| name | description | argument-hint | allowed-tools |
|---|---|---|---|
| cli-init | Generate .gemini/ and .qwen/ config directories with settings.json and ignore files based on workspace technology detection | [--tool gemini|qwen|all] [--output path] [--preview] | Bash(*), Read(*), Write(*), Glob(*) |
CLI Initialization Command (/cli:cli-init)
Overview
Initializes CLI tool configurations for the workspace by:
- Analyzing current workspace using
get_modules_by_depth.shto identify technology stacks - Generating ignore files (
.geminiignoreand.qwenignore) with filtering rules optimized for detected technologies - Creating configuration directories (
.gemini/and.qwen/) with settings.json files
Supported Tools: gemini, qwen, all (default: all)
Core Functionality
Configuration Generation
- Workspace Analysis: Runs
get_modules_by_depth.shto analyze project structure - Technology Stack Detection: Identifies tech stacks based on file extensions, directories, and configuration files
- Config Creation: Generates tool-specific configuration directories and settings files
- Ignore Rules Generation: Creates ignore files with filtering patterns for detected technologies
Generated Files
Configuration Directories
Creates tool-specific configuration directories:
For Gemini (.gemini/):
.gemini/settings.json:
{
"contextfilename": ["CLAUDE.md","GEMINI.md"]
}
For Qwen (.qwen/):
.qwen/settings.json:
{
"contextfilename": ["CLAUDE.md","QWEN.md"]
}
Ignore Files
Uses gitignore syntax to filter files from CLI tool analysis:
.geminiignore- For Gemini CLI.qwenignore- For Qwen CLI
Both files have identical content based on detected technologies.
Supported Technology Stacks
Frontend Technologies
- React/Next.js: Ignores build artifacts, .next/, node_modules
- Vue/Nuxt: Ignores .nuxt/, dist/, .cache/
- Angular: Ignores dist/, .angular/, node_modules
- Webpack/Vite: Ignores build outputs, cache directories
Backend Technologies
- Node.js: Ignores node_modules, package-lock.json, npm-debug.log
- Python: Ignores pycache, .venv, *.pyc, .pytest_cache
- Java: Ignores target/, .gradle/, *.class, .mvn/
- Go: Ignores vendor/, *.exe, go.sum (when appropriate)
- C#/.NET: Ignores bin/, obj/, *.dll, *.pdb
Database & Infrastructure
- Docker: Ignores .dockerignore, docker-compose.override.yml
- Kubernetes: Ignores *.secret.yaml, helm charts temp files
- Database: Ignores *.db, *.sqlite, database dumps
Generated Rules Structure
Base Rules (Always Included)
# Version Control
.git/
.svn/
.hg/
# OS Files
.DS_Store
Thumbs.db
*.tmp
*.swp
# IDE Files
.vscode/
.idea/
.vs/
# Logs
*.log
logs/
Technology-Specific Rules
Rules are added based on detected technologies:
Node.js Projects (package.json detected):
# Node.js
node_modules/
npm-debug.log*
.npm/
.yarn/
package-lock.json
yarn.lock
.pnpm-store/
Python Projects (requirements.txt, setup.py, pyproject.toml detected):
# Python
__pycache__/
*.py[cod]
.venv/
venv/
.pytest_cache/
.coverage
htmlcov/
Java Projects (pom.xml, build.gradle detected):
# Java
target/
.gradle/
*.class
*.jar
*.war
.mvn/
Command Options
Tool Selection
Initialize All Tools (default):
/cli:cli-init
- Creates
.gemini/,.qwen/directories with settings.json - Creates
.geminiignoreand.qwenignorefiles - Sets contextfilename to "CLAUDE.md" for both
Initialize Gemini Only:
/cli:cli-init --tool gemini
- Creates only
.gemini/directory and.geminiignorefile
Initialize Qwen Only:
/cli:cli-init --tool qwen
- Creates only
.qwen/directory and.qwenignorefile
Preview Mode
/cli:cli-init --preview
- Shows what would be generated without creating files
- Displays detected technologies, configuration, and ignore rules
Custom Output Path
/cli:cli-init --output=.config/
- Generates files in specified directory
- Creates directories if they don't exist
Combined Options
/cli:cli-init --tool qwen --preview
/cli:cli-init --tool all --output=.config/
EXECUTION INSTRUCTIONS - START HERE
When this command is triggered, follow these exact steps:
Step 1: Parse Tool Selection
# Extract --tool flag (default: all)
# Options: gemini, qwen, all
Step 2: Workspace Analysis (MANDATORY FIRST)
# Analyze workspace structure
bash(ccw tool exec get_modules_by_depth '{"format":"json"}')
Step 3: Technology Detection
# Check for common tech stack indicators
bash(find . -name "package.json" -not -path "*/node_modules/*" | head -1)
bash(find . -name "requirements.txt" -o -name "setup.py" -o -name "pyproject.toml" | head -1)
bash(find . -name "pom.xml" -o -name "build.gradle" | head -1)
bash(find . -name "Dockerfile" | head -1)
Step 4: Generate Configuration Files
For Gemini (if --tool is gemini or all):
# Create .gemini/ directory and settings.json
mkdir -p .gemini
Write({file_path: '.gemini/settings.json', content: '{"contextfilename": "CLAUDE.md"}'})
# Create .geminiignore file with detected technology rules
# Backup existing files if present
For Qwen (if --tool is qwen or all):
# Create .qwen/ directory and settings.json
mkdir -p .qwen
Write({file_path: '.qwen/settings.json', content: '{"contextfilename": "CLAUDE.md"}'})
# Create .qwenignore file with detected technology rules
# Backup existing files if present
Step 5: Validation
# Verify generated files are valid
bash(ls -la .gemini* .qwen* 2>/dev/null || echo "Configuration files created")
Implementation Process (Technical Details)
Phase 1: Tool Selection
- Parse
--toolflag from command arguments - Determine which configurations to generate:
gemini: Generate .gemini/ and .geminiignore onlyqwen: Generate .qwen/ and .qwenignore onlyall(default): Generate both sets of files
Phase 2: Workspace Analysis
- Execute
get_modules_by_depth.sh jsonto get structured project data - Parse JSON output to identify directories and files
- Scan for technology indicators:
- Configuration files (package.json, requirements.txt, etc.)
- Directory patterns (src/, tests/, etc.)
- File extensions (.js, .py, .java, etc.)
- Detect project name from directory name or package.json
Phase 3: Technology Detection
# Technology detection logic
detect_nodejs() {
[ -f "package.json" ] || find . -name "package.json" -not -path "*/node_modules/*" | head -1
}
detect_python() {
[ -f "requirements.txt" ] || [ -f "setup.py" ] || [ -f "pyproject.toml" ] || \
find . -name "*.py" -not -path "*/__pycache__/*" | head -1
}
detect_java() {
[ -f "pom.xml" ] || [ -f "build.gradle" ] || \
find . -name "*.java" | head -1
}
Phase 4: Configuration Generation
For each selected tool, create:
-
Config Directory:
- Create
.gemini/or.qwen/directory if it doesn't exist - Generate
settings.jsonwith contextfilename setting - Set contextfilename to "CLAUDE.md" by default
- Create
-
Settings.json Format (identical for both tools):
{
"contextfilename": "CLAUDE.md"
}
Phase 5: Ignore Rules Generation
- Start with base rules (always included)
- Add technology-specific rules based on detection
- Add workspace-specific patterns if found
- Sort and deduplicate rules
- Generate identical content for both
.geminiignoreand.qwenignore
Phase 6: File Creation
- Generate config directories: Create
.gemini/and/or.qwen/directories with settings.json - Generate ignore files: Create organized ignore files with sections
- Create backups: Backup existing files if present
- Validate: Check generated files are valid
Generated File Format
Configuration Files
// .gemini/settings.json or .qwen/settings.json
{
"contextfilename": "CLAUDE.md"
}
Ignore Files
# .geminiignore / .qwenignore
# Generated by Claude Code /cli:cli-init command
# Creation date: 2024-01-15 10:30:00
# Detected technologies: Node.js, Python, Docker
#
# This file uses gitignore syntax to filter files for CLI tool analysis
# Edit this file to customize filtering rules for your project
# ============================================================================
# Base Rules (Always Applied)
# ============================================================================
# Version Control
.git/
.svn/
.hg/
# ============================================================================
# Node.js (Detected: package.json found)
# ============================================================================
node_modules/
npm-debug.log*
.npm/
yarn-error.log
package-lock.json
# ============================================================================
# Python (Detected: requirements.txt, *.py files found)
# ============================================================================
__pycache__/
*.py[cod]
.venv/
.pytest_cache/
.coverage
# ============================================================================
# Docker (Detected: Dockerfile found)
# ============================================================================
.dockerignore
docker-compose.override.yml
# ============================================================================
# Custom Rules (Add your project-specific rules below)
# ============================================================================
Error Handling
Missing Dependencies
- If
get_modules_by_depth.shnot found, show error with path to script - Gracefully handle cases where script fails
Write Permissions
- Check write permissions before attempting file creation
- Show clear error message if cannot write to target location
Backup Existing Files
- If
.gemini/directory exists, create backup as.gemini.backup/ - If
.qwen/directory exists, create backup as.qwen.backup/ - If
.geminiignoreexists, create backup as.geminiignore.backup - If
.qwenignoreexists, create backup as.qwenignore.backup - Include timestamp in backup filename
Integration Points
Workflow Commands
- After
/cli:plan: Suggest running cli-init for better analysis - Before analysis: Recommend updating ignore patterns for cleaner results
CLI Tool Integration
- Automatically update when new technologies detected
- Integrate with
intelligent-tools-strategy.mdrecommendations
Usage Examples
Basic Project Setup
# Initialize all CLI tools (Gemini + Qwen)
/cli:cli-init
# Initialize only Gemini
/cli:cli-init --tool gemini
# Initialize only Qwen
/cli:cli-init --tool qwen
# Preview what would be generated
/cli:cli-init --preview
# Generate in subdirectory
/cli:cli-init --output=.config/
Technology Migration
# After adding new tech stack (e.g., Docker)
/cli:cli-init # Regenerates all config and ignore files with new rules
# Check what changed
/cli:cli-init --preview # Compare with existing configuration
# Update only Qwen configuration
/cli:cli-init --tool qwen
Tool-Specific Initialization
# Setup for Gemini-only workflow
/cli:cli-init --tool gemini
# Setup for Qwen-only workflow
/cli:cli-init --tool qwen
# Setup both with preview
/cli:cli-init --tool all --preview
Tool Selection Guide
| Scenario | Command | Result |
|---|---|---|
| New project, using both tools | /cli:cli-init |
Creates .gemini/, .qwen/, .geminiignore, .qwenignore |
| Gemini-only workflow | /cli:cli-init --tool gemini |
Creates .gemini/ and .geminiignore only |
| Qwen-only workflow | /cli:cli-init --tool qwen |
Creates .qwen/ and .qwenignore only |
| Preview before commit | /cli:cli-init --preview |
Shows what would be generated |
| Update configurations | /cli:cli-init |
Regenerates all files with backups |