mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-12 02:37:45 +08:00
refactor: consolidate workflow documentation into unified architecture
- Create unified workflow-architecture.md combining: - data-model.md (JSON-only architecture, task schemas) - file-structure-standards.md (progressive structures, templates) - session-management-principles.md (marker files, session ops) - complexity-rules.md (classification thresholds, behaviors) - Update 11 files with references to new consolidated document - Remove redundant documentation while preserving all functionality - Streamline maintenance with single source of truth 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,239 +1,201 @@
|
||||
```markdown
|
||||
---
|
||||
name: gemini-unified
|
||||
description: Consolidated Gemini CLI guidelines - core rules, syntax, patterns, templates, and best practices
|
||||
type: technical-guideline
|
||||
---
|
||||
|
||||
# Unified Gemini CLI Guidelines
|
||||
### 🚀 Command Overview: `gemini`
|
||||
|
||||
## 🚀 Core Rules
|
||||
- **Purpose**: A CLI tool for comprehensive codebase analysis, context gathering, and pattern detection across multiple files.
|
||||
- **Primary Triggers**:
|
||||
- When user intent is to "analyze", "get context", or "understand the codebase".
|
||||
- When a task requires understanding relationships between multiple files.
|
||||
- When the problem scope exceeds a single file.
|
||||
- **Core Use Cases**:
|
||||
- Project-wide context acquisition.
|
||||
- Architectural analysis and pattern detection.
|
||||
- Identification of coding standards and conventions.
|
||||
|
||||
### When to Trigger
|
||||
- **Semantic Intent**: User asks to "analyze with Gemini", "get context", or "understand codebase"
|
||||
- **Context Need**: Task requires understanding multiple files or relationships
|
||||
- **Complex Analysis**: Problem exceeds single-file scope
|
||||
### ⚙️ Command Syntax & Arguments
|
||||
|
||||
### Primary Use Cases
|
||||
- Project context acquisition and codebase understanding
|
||||
- Pattern detection and architectural analysis
|
||||
- Standards extraction and convention identification
|
||||
- **Basic Structure**:
|
||||
```bash
|
||||
gemini [flags] -p "@{patterns} {template} prompt"
|
||||
```
|
||||
- **Key Arguments**:
|
||||
- `--all-files`: Includes all files in the current working directory.
|
||||
- `-p`: The prompt string, which must contain file reference patterns and the analysis query.
|
||||
- `{template}`: Template injection using `$(cat ~/.claude/workflows/gemini-templates/prompts/[category]/[template].txt)` for standardized analysis
|
||||
- `@{pattern}`: A special syntax for referencing files and directories.
|
||||
|
||||
### Standard Template Structure
|
||||
- **Template Usage**:
|
||||
```bash
|
||||
# Without template (manual prompt)
|
||||
gemini -p "@{src/**/*} @{CLAUDE.md} Analyze code patterns and conventions"
|
||||
|
||||
# With template (recommended)
|
||||
gemini -p "@{src/**/*} @{CLAUDE.md} $(cat ~/.claude/workflows/gemini-templates/prompts/analysis/pattern.txt)"
|
||||
|
||||
# Multi-template composition
|
||||
gemini -p "@{src/**/*} @{CLAUDE.md} $(cat <<'EOF'
|
||||
$(cat ~/.claude/workflows/gemini-templates/prompts/analysis/architecture.txt)
|
||||
|
||||
Additional Security Focus:
|
||||
$(cat ~/.claude/workflows/gemini-templates/prompts/analysis/security.txt)
|
||||
EOF
|
||||
)"
|
||||
```
|
||||
|
||||
#### Basic Structure (Manual Prompts)
|
||||
```bash
|
||||
gemini --all-files -p "@{target_patterns} @{CLAUDE.md,**/*CLAUDE.md}
|
||||
### 🔄 Execution Modes
|
||||
|
||||
Context: [Analysis type] targeting @{target_patterns}
|
||||
Guidelines: Include CLAUDE.md standards
|
||||
- **1. Directory-Scoped**: Navigate to a directory first, then run `gemini`.
|
||||
```bash
|
||||
cd src/components && gemini --all-files -p "@{CLAUDE.md} Analyze component patterns"
|
||||
```
|
||||
- **2. Pattern-Based**: Target files directly from any location using patterns.
|
||||
```bash
|
||||
gemini -p "@{src/components/**/*} @{CLAUDE.md} Analyze component patterns"
|
||||
```
|
||||
- **3. Template-Injected**: Use `$(cat)` to inject a predefined prompt template.
|
||||
```bash
|
||||
gemini -p "@{src/**/*} $(cat ~/.claude/workflows/gemini-templates/prompts/analysis/pattern.txt)"
|
||||
```
|
||||
- **4. Parallel Execution**: Run multiple analyses concurrently for efficiency.
|
||||
```bash
|
||||
(
|
||||
gemini -p "@{**/*auth*} @{CLAUDE.md} Auth patterns" &
|
||||
gemini -p "@{**/api/**/*} @{CLAUDE.md} API patterns" &
|
||||
wait
|
||||
)
|
||||
```
|
||||
|
||||
## Analysis:
|
||||
1. [Point 1]
|
||||
2. [Point 2]
|
||||
3. [Point 3]
|
||||
### 📂 File Pattern Rules
|
||||
|
||||
## Output:
|
||||
- File:line references
|
||||
- Code examples
|
||||
- Actionable guidance
|
||||
- Standards compliance"
|
||||
- **Syntax**:
|
||||
- `@{pattern}`: Single file or directory pattern.
|
||||
- `@{pattern1,pattern2}`: Multiple patterns, comma-separated.
|
||||
- **Wildcards**:
|
||||
```bash
|
||||
* # Any character (excluding path separators)
|
||||
** # Any directory levels (recursive)
|
||||
? # Any single character
|
||||
[abc] # Any character within the brackets
|
||||
{a,b,c} # Any of the options within the braces
|
||||
```
|
||||
- **Cross-Platform Rules**:
|
||||
- Always use forward slashes (`/`) for paths.
|
||||
- Enclose paths with spaces in quotes: `@{"My Project/src/**/*"}`.
|
||||
- Escape special characters like brackets: `@{src/**/*\[bracket\]*}`.
|
||||
|
||||
### 🧠 Smart Pattern Discovery - Logic Flow
|
||||
|
||||
This feature automates the process of finding relevant files for analysis.
|
||||
|
||||
`Step 1: Analyze File Extensions` -> `Step 2: Generate Patterns` -> `Step 3: Execute Gemini`
|
||||
|
||||
```pseudo
|
||||
FUNCTION analyze_and_run_gemini(analysis_type):
|
||||
// Step 1: Analyze the project's file types.
|
||||
// Corresponds to the `discover_extensions` shell function.
|
||||
discovered_extensions = analyze_project_extensions()
|
||||
log("Discovered extensions:", discovered_extensions)
|
||||
|
||||
// Also identify the likely primary programming language.
|
||||
// Corresponds to the `detect_primary_language` shell function.
|
||||
primary_language = detect_main_language(discovered_extensions)
|
||||
log("Primary language:", primary_language)
|
||||
|
||||
// Step 2: Generate file patterns based on the analysis type (e.g., "code", "config").
|
||||
// Corresponds to the `generate_patterns_by_extension` shell function.
|
||||
patterns = generate_patterns(analysis_type, discovered_extensions)
|
||||
log("Generated patterns:", patterns)
|
||||
|
||||
// Step 3: Construct and execute the gemini command.
|
||||
// Always include project standards from CLAUDE.md.
|
||||
// Uses a pre-defined analysis template for consistency.
|
||||
command = "gemini -p \"" + patterns + " @{CLAUDE.md} $(cat ~/.claude/workflows/gemini-templates/prompts/analysis/pattern.txt)\""
|
||||
execute_shell(command)
|
||||
|
||||
END FUNCTION
|
||||
```
|
||||
|
||||
#### Template-Enhanced Structure (Recommended)
|
||||
```bash
|
||||
# Using predefined templates for consistent analysis
|
||||
gemini --all-files -p "@{target_patterns} @{CLAUDE.md,**/*CLAUDE.md}
|
||||
$(cat ~/.claude/workflows/gemini-templates/prompts/[category]/[template].txt)"
|
||||
```
|
||||
### 📜 Smart Discovery - Shell Implementation
|
||||
|
||||
#### Template Reference Examples
|
||||
```bash
|
||||
# Pattern analysis with template
|
||||
gemini -p "@{src/**/*} @{CLAUDE.md} $(cat ~/.claude/workflows/gemini-templates/prompts/analysis/pattern.txt)"
|
||||
These functions provide the concrete implementation for the smart discovery logic.
|
||||
|
||||
# Architecture analysis with template
|
||||
gemini -p "@{src/**/*} @{CLAUDE.md} $(cat ~/.claude/workflows/gemini-templates/prompts/analysis/architecture.txt)"
|
||||
- **Step 1: Analyze File Extensions & Language**
|
||||
```bash
|
||||
# Discover actual file types in project
|
||||
discover_extensions() {
|
||||
echo "=== File Extension Analysis ==="
|
||||
find . -type f -name "*.*" 2>/dev/null | \
|
||||
sed 's/.*\.//' | \
|
||||
sort | uniq -c | sort -rn | \
|
||||
head -10
|
||||
}
|
||||
|
||||
# Multi-template composition
|
||||
gemini -p "@{src/**/*} @{CLAUDE.md} $(cat <<'EOF'
|
||||
$(cat ~/.claude/workflows/gemini-templates/prompts/analysis/pattern.txt)
|
||||
# Identify primary language
|
||||
detect_primary_language() {
|
||||
local extensions=$(find . -type f -name "*.*" 2>/dev/null | sed 's/.*\.//' | sort | uniq -c | sort -rn)
|
||||
if echo "$extensions" | grep -q "js\|jsx\|ts\|tsx"; then
|
||||
echo "JavaScript/TypeScript"
|
||||
elif echo "$extensions" | grep -q "py\|pyw"; then
|
||||
echo "Python"
|
||||
# ... other language checks ...
|
||||
else
|
||||
echo "Unknown/Mixed"
|
||||
fi
|
||||
}
|
||||
```
|
||||
- **Step 2: Generate Patterns**
|
||||
```bash
|
||||
# Generate patterns from discovered extensions
|
||||
generate_patterns_by_extension() {
|
||||
local analysis_type="$1"
|
||||
local top_exts=$(find . -type f -name "*.*" 2>/dev/null | sed 's/.*\.//' | sort | uniq -c | sort -rn | head -5 | awk '{print $2}')
|
||||
local pattern=""
|
||||
case "$analysis_type" in
|
||||
"code")
|
||||
for ext in $top_exts; do
|
||||
case $ext in
|
||||
js|ts|jsx|tsx|py|java|go|rs|cpp|c|h)
|
||||
pattern="${pattern}**/*.${ext},"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo "@{${pattern%,}}"
|
||||
;;
|
||||
"config") echo "@{*.json,*.yml,*.yaml,*.toml,*.ini,*.env}" ;;
|
||||
"docs") echo "@{**/*.md,**/*.txt,**/README*}" ;;
|
||||
"all")
|
||||
for ext in $top_exts; do pattern="${pattern}**/*.${ext},"; done
|
||||
echo "@{${pattern%,}}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
```
|
||||
|
||||
Additional Security Focus:
|
||||
$(cat ~/.claude/workflows/gemini-templates/prompts/analysis/security.txt)
|
||||
EOF
|
||||
)"
|
||||
```
|
||||
### ⚡ Smart Discovery - Quick Commands
|
||||
|
||||
**Template Benefits:**
|
||||
- **Consistency**: Standardized analysis structure across all uses
|
||||
- **Completeness**: Pre-defined analysis points ensure comprehensive coverage
|
||||
- **Quality**: Proven analysis frameworks with specific output requirements
|
||||
- **Efficiency**: No need to manually construct analysis prompts
|
||||
| Need | Command | Description |
|
||||
|------|---------|-------------|
|
||||
| Analyze Extensions | `discover_extensions` | View project file type distribution. |
|
||||
| Code Files | `generate_patterns_by_extension "code"` | Generate patterns for source code files only. |
|
||||
| Config Files | `generate_patterns_by_extension "config"` | Generate patterns for configuration files. |
|
||||
| Docs | `generate_patterns_by_extension "docs"` | Generate patterns for documentation. |
|
||||
| All Top Types | `generate_patterns_by_extension "all"` | Generate patterns for all discovered file types. |
|
||||
|
||||
**Mandatory**: Always include `@{CLAUDE.md,**/*CLAUDE.md}` for project standards.
|
||||
### TPL (Templates)
|
||||
|
||||
## ⚙️ Command Syntax
|
||||
|
||||
### Basic Structure
|
||||
```bash
|
||||
gemini [flags] -p "@{patterns} prompt"
|
||||
```
|
||||
|
||||
### Key Arguments
|
||||
- `--all-files`: Includes all files in current directory (path-dependent)
|
||||
- `-p`: Prompt string with file patterns and query
|
||||
- `@{pattern}`: File reference pattern
|
||||
|
||||
### Execution Modes
|
||||
|
||||
#### 1. Directory-Scoped
|
||||
Navigate first, then execute:
|
||||
```bash
|
||||
cd src/components && gemini --all-files -p "@{CLAUDE.md} Analyze patterns"
|
||||
```
|
||||
|
||||
#### 2. Pattern-Based
|
||||
Target files directly:
|
||||
```bash
|
||||
gemini -p "@{src/components/**/*} @{CLAUDE.md} Component analysis"
|
||||
```
|
||||
|
||||
#### 3. Template-Injected
|
||||
Use `$(cat)` for templates:
|
||||
```bash
|
||||
gemini -p "@{src/**/*} $(cat ~/.claude/workflows/gemini-templates/prompts/analysis/pattern.txt)"
|
||||
```
|
||||
|
||||
#### 4. Parallel Execution
|
||||
Multiple analyses concurrently:
|
||||
```bash
|
||||
(
|
||||
gemini -p "@{**/*auth*} @{CLAUDE.md} Auth patterns" &
|
||||
gemini -p "@{**/api/**/*} @{CLAUDE.md} API patterns" &
|
||||
wait
|
||||
)
|
||||
```
|
||||
|
||||
## 📂 File Patterns
|
||||
|
||||
### Pattern Syntax
|
||||
```bash
|
||||
@{pattern} # Single pattern
|
||||
@{pattern1,pattern2} # Multiple patterns
|
||||
```
|
||||
|
||||
### Wildcards
|
||||
```bash
|
||||
* # Any character (not path separators)
|
||||
** # Any directory levels
|
||||
? # Single character
|
||||
[abc] # Character in brackets
|
||||
{a,b,c} # Any option in braces
|
||||
```
|
||||
|
||||
### Frontend Patterns
|
||||
```bash
|
||||
# React
|
||||
@{src/components/**/*.{jsx,tsx}}
|
||||
@{src/hooks/**/*.{js,ts}}
|
||||
@{src/context/**/*.{jsx,tsx}}
|
||||
|
||||
# Vue
|
||||
@{src/components/**/*.vue}
|
||||
@{src/composables/**/*.{js,ts}}
|
||||
|
||||
# Angular
|
||||
@{src/app/**/*.component.{ts,html}}
|
||||
@{src/app/**/*.service.ts}
|
||||
```
|
||||
|
||||
### Backend Patterns
|
||||
```bash
|
||||
# Node.js
|
||||
@{routes/**/*.js,controllers/**/*.js}
|
||||
@{middleware/**/*.js}
|
||||
@{models/**/*.js}
|
||||
|
||||
# Python
|
||||
@{**/views.py,**/models.py,**/urls.py}
|
||||
@{**/serializers.py}
|
||||
|
||||
# Java
|
||||
@{**/*Controller.java}
|
||||
@{**/*Service.java,**/*Repository.java}
|
||||
```
|
||||
|
||||
### Config & Testing
|
||||
```bash
|
||||
# Configuration
|
||||
@{*.config.{js,ts},**/*.config.*}
|
||||
@{package.json,yarn.lock}
|
||||
@{Dockerfile,docker-compose.yml}
|
||||
|
||||
# Tests
|
||||
@{**/*.test.{js,ts,jsx,tsx}}
|
||||
@{**/*.spec.{js,ts}}
|
||||
@{**/__tests__/**/*}
|
||||
|
||||
# Documentation
|
||||
@{**/*.md,**/README*}
|
||||
@{**/*.d.ts,**/types/**/*.ts}
|
||||
```
|
||||
|
||||
### Domain Patterns
|
||||
```bash
|
||||
# Auth & Security
|
||||
@{**/*auth*,**/*login*,**/*session*}
|
||||
@{**/*permission*,**/*role*}
|
||||
@{**/*crypto*,**/*hash*}
|
||||
|
||||
# API & Data
|
||||
@{**/api/**/*,**/routes/**/*}
|
||||
@{**/controllers/**/*,**/handlers/**/*}
|
||||
@{**/models/**/*,**/entities/**/*}
|
||||
|
||||
# UI & Styling
|
||||
@{src/components/**/*,src/ui/**/*}
|
||||
@{src/styles/**/*,**/*.{css,scss,sass}}
|
||||
@{src/layouts/**/*}
|
||||
```
|
||||
|
||||
### Cross-Platform Rules
|
||||
- Always use forward slashes: `@{src/components/**/*}`
|
||||
- Quote paths with spaces: `@{"My Project/src/**/*"}`
|
||||
- Escape special chars: `@{src/**/*\[bracket\]*}`
|
||||
|
||||
## 📋 Template System
|
||||
|
||||
### Template Categories and Functions
|
||||
|
||||
#### Analysis Templates (`prompts/analysis/`)
|
||||
- **`pattern.txt`** - 分析代码模式、工具库、编码标准和反模式
|
||||
- **`architecture.txt`** - 映射模块依赖、集成点、可扩展性评估
|
||||
- **`security.txt`** - 扫描安全漏洞、认证问题、加密方法
|
||||
- **`performance.txt`** - 识别瓶颈、算法复杂度、缓存策略
|
||||
- **`quality.txt`** - 评估可维护性、技术债务、代码组织
|
||||
|
||||
#### Planning Templates (`prompts/planning/`)
|
||||
- **`task-breakdown.txt`** - 任务分解、依赖关系、工作量估算
|
||||
- **`migration.txt`** - 系统迁移规划、兼容性、风险评估
|
||||
|
||||
#### Implementation Templates (`prompts/implementation/`)
|
||||
- **`component.txt`** - 组件接口设计、状态管理、测试方法
|
||||
|
||||
#### Review Templates (`prompts/review/`)
|
||||
- **`code-review.txt`** - 全面代码审查、质量检查、标准合规
|
||||
|
||||
#### DMS Templates (`prompts/dms/`)
|
||||
- **`hierarchy-analysis.txt`** - 项目复杂度分析、文档结构优化
|
||||
|
||||
### Directory Structure
|
||||
#### 🗂️ Template Directory Structure
|
||||
This structure must be located at `~/.claude/workflows/gemini-templates/`.
|
||||
```
|
||||
~/.claude/workflows/gemini-templates/
|
||||
├── prompts/
|
||||
│ ├── analysis/ # Code analysis templates
|
||||
│ │ ├── pattern.txt # ✨ Implementation patterns & conventions
|
||||
│ │ ├── architecture.txt # 🏗️ System architecture & dependencies
|
||||
│ │ ├── architecture.txt # 🏗️ System architecture & dependencies
|
||||
│ │ ├── security.txt # 🔒 Security vulnerabilities & protection
|
||||
│ │ ├── performance.txt # ⚡ Performance bottlenecks & optimization
|
||||
│ │ └── quality.txt # 📊 Code quality & maintainability
|
||||
@@ -247,127 +209,86 @@ Multiple analyses concurrently:
|
||||
│ └── dms/ # DMS-specific
|
||||
│ └── hierarchy-analysis.txt # 📚 Documentation structure optimization
|
||||
└── commands/ # Command examples
|
||||
├── context-analysis.md # Complete context gathering examples
|
||||
├── parallel-execution.md # Parallel analysis patterns
|
||||
└── folder-analysis.md # Directory-specific analysis
|
||||
```
|
||||
|
||||
### Template Selection Guide
|
||||
| 任务类型 | 主要模板 | 用途 |
|
||||
|---------|---------|------|
|
||||
| 理解现有代码 | `pattern.txt` | 学习代码库、入职培训 |
|
||||
| 规划新功能 | `task-breakdown.txt` | 功能开发规划 |
|
||||
| 安全审查 | `security.txt` | 安全审计、漏洞评估 |
|
||||
| 性能优化 | `performance.txt` | 性能问题排查 |
|
||||
| 代码质量改进 | `quality.txt` | 重构、技术债务减少 |
|
||||
| 系统现代化 | `migration.txt` | 技术升级、架构变更 |
|
||||
| 组件开发 | `component.txt` | 构建可复用组件 |
|
||||
| 发布前审查 | `code-review.txt` | 发布就绪检查 |
|
||||
#### 🧭 Template Selection Guide
|
||||
| Task Type | Primary Template | Purpose |
|
||||
|---|---|---|
|
||||
| Understand Existing Code | `pattern.txt` | Codebase learning, onboarding. |
|
||||
| Plan New Features | `task-breakdown.txt`| Feature development planning. |
|
||||
| Security Review | `security.txt` | Security audits, vulnerability assessment. |
|
||||
| Performance Tuning | `performance.txt` | Bottleneck investigation. |
|
||||
| Code Quality Improvement | `quality.txt` | Refactoring, technical debt reduction. |
|
||||
| System Modernization | `migration.txt` | Tech upgrades, architectural changes. |
|
||||
| Component Development | `component.txt` | Building reusable components. |
|
||||
| Pre-Release Review | `code-review.txt` | Release readiness checks. |
|
||||
|
||||
### Template Usage Examples
|
||||
|
||||
#### Basic Template Usage
|
||||
```bash
|
||||
# Single template - pattern analysis
|
||||
gemini -p "@{src/**/*} $(cat ~/.claude/workflows/gemini-templates/prompts/analysis/pattern.txt)"
|
||||
### 📦 Standard Command Structures
|
||||
|
||||
# Multi-template composition
|
||||
gemini -p "@{src/**/*} $(cat <<'EOF'
|
||||
$(cat ~/.claude/workflows/gemini-templates/prompts/analysis/architecture.txt)
|
||||
These are recommended command templates for common scenarios.
|
||||
|
||||
Additional Quality Focus:
|
||||
$(cat ~/.claude/workflows/gemini-templates/prompts/analysis/quality.txt)
|
||||
EOF
|
||||
)"
|
||||
```
|
||||
- **Basic Structure (Manual Prompt)**
|
||||
```bash
|
||||
gemini --all-files -p "@{target_patterns} @{CLAUDE.md,**/*CLAUDE.md}
|
||||
|
||||
#### Common Use Cases
|
||||
```bash
|
||||
# New feature development workflow
|
||||
gemini -p "@{src/**/*similar*} $(cat ~/.claude/workflows/gemini-templates/prompts/analysis/pattern.txt)"
|
||||
gemini -p "@{src/**/*} $(cat ~/.claude/workflows/gemini-templates/prompts/planning/task-breakdown.txt)"
|
||||
Context: [Analysis type] targeting @{target_patterns}
|
||||
Guidelines: Include CLAUDE.md standards
|
||||
|
||||
# Security audit
|
||||
gemini -p "@{**/*auth*,**/*login*} $(cat ~/.claude/workflows/gemini-templates/prompts/analysis/security.txt)"
|
||||
## Analysis:
|
||||
1. [Point 1]
|
||||
2. [Point 2]
|
||||
|
||||
# Performance optimization
|
||||
gemini -p "@{src/**/*} $(cat ~/.claude/workflows/gemini-templates/prompts/analysis/performance.txt)"
|
||||
```
|
||||
## Output:
|
||||
- File:line references
|
||||
- Code examples"
|
||||
```
|
||||
|
||||
#### Template Best Practices
|
||||
- **Single Template**: 专注分析、特定问题、时间限制
|
||||
- **Multiple Templates**: 综合审查、复杂项目、全面规划
|
||||
- **Performance**: 合并相关模板到单个命令,使用特定文件模式减少范围
|
||||
- **Template-Enhanced (Recommended)**
|
||||
```bash
|
||||
# Using a predefined template for consistent, high-quality analysis
|
||||
gemini --all-files -p "@{target_patterns} @{CLAUDE.md,**/*CLAUDE.md} $(cat ~/.claude/workflows/gemini-templates/prompts/[category]/[template].txt)
|
||||
|
||||
## 🧠 Intelligent Features
|
||||
## Analysis:
|
||||
1. [Point 1]
|
||||
2. [Point 2]
|
||||
|
||||
### Technology Detection
|
||||
```python
|
||||
# Simplified logic
|
||||
indicators = {
|
||||
'React': ['package.json contains react', '**/*.jsx'],
|
||||
'Vue': ['package.json contains vue', '**/*.vue'],
|
||||
'Python': ['requirements.txt', '**/*.py'],
|
||||
'Java': ['pom.xml', '**/*.java']
|
||||
}
|
||||
```
|
||||
## Output:
|
||||
- File:line references
|
||||
- Code examples"
|
||||
"
|
||||
```
|
||||
|
||||
### Domain Extraction
|
||||
```python
|
||||
# Domain mapping
|
||||
domains = {
|
||||
'auth': ['authentication', 'login', 'session'],
|
||||
'api': ['api', 'endpoint', 'route'],
|
||||
'frontend': ['component', 'ui', 'react'],
|
||||
'backend': ['server', 'database', 'model']
|
||||
}
|
||||
```
|
||||
- **Multi-Template Composition**
|
||||
```bash
|
||||
gemini -p "@{src/**/*} @{CLAUDE.md}
|
||||
$(cat ~/.claude/workflows/gemini-templates/prompts/analysis/pattern.txt)
|
||||
|
||||
### Fallback Strategy
|
||||
1. **Primary Pattern**: Try user-specified pattern
|
||||
2. **Simplified Pattern**: Remove extensions/specificity
|
||||
3. **Directory Pattern**: Use common directories like `@{src/**/*}`
|
||||
Additional Security Focus:
|
||||
$(cat ~/.claude/workflows/gemini-templates/prompts/analysis/security.txt)
|
||||
|
||||
### Performance Tips
|
||||
- Avoid patterns matching >1000 files
|
||||
- Use directory-scoped execution for large projects
|
||||
- Prefer specific patterns over broad ones
|
||||
- Process large datasets in parallel chunks
|
||||
## Analysis:
|
||||
1. [Point 1]
|
||||
2. [Point 2]
|
||||
|
||||
## ⭐ Best Practices
|
||||
## Output:
|
||||
- File:line references
|
||||
- Code examples"
|
||||
"
|
||||
```
|
||||
|
||||
### Core Principles
|
||||
- **Always include** `@{CLAUDE.md,**/*CLAUDE.md}` for project context
|
||||
- **Be specific** with patterns to reduce scope and improve performance
|
||||
- **Group logically** related patterns in single commands
|
||||
- **Use forward slashes** for cross-platform compatibility
|
||||
### ⭐ Best Practices & Rules
|
||||
|
||||
### Common Patterns
|
||||
```bash
|
||||
# Get project context
|
||||
gemini --all-files -p "@{src/**/*} @{CLAUDE.md} Extract patterns and standards"
|
||||
- **Mandatory Context**: Always include `@{CLAUDE.md,**/*CLAUDE.md}` to ground the analysis in project-specific standards.
|
||||
- **Specificity**: Use precise file patterns to reduce scope, improve performance, and increase accuracy.
|
||||
- **Performance**: Avoid overly broad patterns (`@{**/*}`) on large projects. Prefer directory-scoped execution or parallel chunks.
|
||||
- **Agent Integration**: All agent workflows **must** begin with a context analysis step using `gemini`.
|
||||
```bash
|
||||
# Mandatory first step for any agent task
|
||||
gemini --all-files -p "@{relevant_patterns} @{CLAUDE.md} Context for: [task_description]"
|
||||
```
|
||||
- **Error Handling**:
|
||||
- Validate patterns match existing files before executing a long analysis.
|
||||
- Quote paths that contain spaces or special characters.
|
||||
- Test complex patterns on a small subset of files first.
|
||||
|
||||
# Domain analysis
|
||||
gemini -p "@{**/*auth*} @{CLAUDE.md} Authentication implementation analysis"
|
||||
|
||||
# Technology-specific
|
||||
gemini -p "@{src/components/**/*} $(cat ~/.claude/workflows/gemini-templates/prompts/tech/react-component.txt)"
|
||||
```
|
||||
|
||||
### Error Handling
|
||||
- Validate patterns match files before execution
|
||||
- Use fallback patterns for robustness
|
||||
- Quote paths with spaces or special characters
|
||||
- Test patterns on small subsets first
|
||||
|
||||
### Agent Integration
|
||||
All agent workflows should begin with context analysis:
|
||||
```bash
|
||||
# Mandatory first step
|
||||
gemini --all-files -p "@{relevant_patterns} @{CLAUDE.md} Context for: [task_description]"
|
||||
```
|
||||
|
||||
### Integration References
|
||||
- This unified guide replaces all individual Gemini guideline files
|
||||
- Templates are stored in `~/.claude/workflows/gemini-templates/`
|
||||
- Always reference this file for Gemini CLI usage patterns
|
||||
Reference in New Issue
Block a user