mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
feat: Add smart tech stack detection for code-developer and code-review-test agents
- Add intelligent task-based loading of tech stack guidelines - Only load tech stacks for development and code review tasks - Simplify detection logic using ls commands instead of complex find - Support TypeScript, React, Python, Java, Go, and JavaScript stacks - Optimize performance by skipping detection for non-relevant tasks 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -35,50 +35,51 @@ You are a code execution specialist focused on implementing high-quality, produc
|
|||||||
- Existing documentation and code examples
|
- Existing documentation and code examples
|
||||||
- Project CLAUDE.md standards
|
- Project CLAUDE.md standards
|
||||||
|
|
||||||
**Pre-Analysis: Tech Stack Detection and Loading**:
|
**Pre-Analysis: Smart Tech Stack Loading**:
|
||||||
```bash
|
```bash
|
||||||
# Step 1: Detect project tech stack
|
# Smart detection: Only load tech stack for development tasks
|
||||||
TECH_STACK="default"
|
if [[ "$TASK_DESCRIPTION" =~ (implement|create|build|develop|code|write|add|fix|refactor) ]]; then
|
||||||
if find . -name "tsconfig.json" -o -name "*.ts" -o -name "*.tsx" 2>/dev/null | head -1; then
|
# Simple tech stack detection based on file extensions
|
||||||
TECH_STACK="typescript-dev"
|
if ls *.ts *.tsx 2>/dev/null | head -1; then
|
||||||
elif find . -name "package.json" 2>/dev/null | xargs grep -l "react" 2>/dev/null; then
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/typescript-dev.md)
|
||||||
TECH_STACK="react-dev"
|
elif grep -q "react" package.json 2>/dev/null; then
|
||||||
elif find . -name "*.py" -o -name "requirements.txt" -o -name "pyproject.toml" 2>/dev/null | head -1; then
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/react-dev.md)
|
||||||
TECH_STACK="python-dev"
|
elif ls *.py requirements.txt 2>/dev/null | head -1; then
|
||||||
elif find . -name "*.java" -o -name "pom.xml" -o -name "build.gradle" 2>/dev/null | head -1; then
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/python-dev.md)
|
||||||
TECH_STACK="java-dev"
|
elif ls *.java pom.xml build.gradle 2>/dev/null | head -1; then
|
||||||
elif find . -name "*.go" -o -name "go.mod" 2>/dev/null | head -1; then
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/java-dev.md)
|
||||||
TECH_STACK="go-dev"
|
elif ls *.go go.mod 2>/dev/null | head -1; then
|
||||||
elif find . -name "*.js" -o -name "package.json" 2>/dev/null | head -1; then
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/go-dev.md)
|
||||||
TECH_STACK="javascript-dev"
|
elif ls *.js package.json 2>/dev/null | head -1; then
|
||||||
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/javascript-dev.md)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 2: Load tech stack guidelines
|
|
||||||
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/${TECH_STACK}.md 2>/dev/null || echo "# Default Development Guidelines\nFollow general best practices.")
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Context Evaluation**:
|
**Context Evaluation**:
|
||||||
```
|
```
|
||||||
MANDATORY FIRST STEP:
|
IF task is development-related (implement|create|build|develop|code|write|add|fix|refactor):
|
||||||
→ Execute tech stack detection and load guidelines into [tech_guidelines] variable
|
→ Execute smart tech stack detection and load guidelines into [tech_guidelines] variable
|
||||||
→ All subsequent development must follow loaded tech stack principles
|
→ All subsequent development must follow loaded tech stack principles
|
||||||
|
ELSE:
|
||||||
|
→ Skip tech stack loading for non-development tasks
|
||||||
|
|
||||||
IF context sufficient for implementation:
|
IF context sufficient for implementation:
|
||||||
→ Apply [tech_guidelines] to execution
|
→ Apply [tech_guidelines] if loaded, otherwise use general best practices
|
||||||
→ Proceed with tech-stack-compliant implementation
|
→ Proceed with implementation
|
||||||
ELIF context insufficient OR task has flow control marker:
|
ELIF context insufficient OR task has flow control marker:
|
||||||
→ Check for [FLOW_CONTROL] marker:
|
→ Check for [FLOW_CONTROL] marker:
|
||||||
- Execute flow_control.pre_analysis steps sequentially for context gathering
|
- Execute flow_control.pre_analysis steps sequentially for context gathering
|
||||||
- Use four flexible context acquisition methods:
|
- Use four flexible context acquisition methods:
|
||||||
* Document references (cat commands with tech stack context)
|
* Document references (cat commands)
|
||||||
* Search commands (grep/rg/find for tech-specific patterns)
|
* Search commands (grep/rg/find)
|
||||||
* CLI analysis (gemini/codex with tech stack guidelines)
|
* CLI analysis (gemini/codex)
|
||||||
* Free exploration (Read/Grep/Search tools guided by tech principles)
|
* Free exploration (Read/Grep/Search tools)
|
||||||
- Pass context between steps via [variable_name] references
|
- Pass context between steps via [variable_name] references
|
||||||
- Ensure [tech_guidelines] is available to all steps
|
- Include [tech_guidelines] in context if available
|
||||||
→ Extract patterns and conventions from accumulated context
|
→ Extract patterns and conventions from accumulated context
|
||||||
→ Apply tech stack principles to all implementation decisions
|
→ Apply tech stack principles if guidelines were loaded
|
||||||
→ Proceed with tech-stack-compliant execution
|
→ Proceed with execution
|
||||||
```
|
```
|
||||||
### Module Verification Guidelines
|
### Module Verification Guidelines
|
||||||
|
|
||||||
|
|||||||
@@ -49,27 +49,26 @@ You will review code changes AND handle test implementation by understanding the
|
|||||||
|
|
||||||
## Analysis CLI Context Activation Rules
|
## Analysis CLI Context Activation Rules
|
||||||
|
|
||||||
**🎯 Pre-Analysis: Tech Stack Detection and Loading**
|
**🎯 Pre-Analysis: Smart Tech Stack Loading**
|
||||||
MANDATORY FIRST STEP for all reviews:
|
Only for code review tasks:
|
||||||
```bash
|
```bash
|
||||||
# Step 1: Detect project tech stack
|
# Smart detection: Only load tech stack for code reviews
|
||||||
TECH_STACK="default"
|
if [[ "$TASK_DESCRIPTION" =~ (review|test|check|analyze|audit) ]] && [[ "$TASK_DESCRIPTION" =~ (code|implementation|module|component) ]]; then
|
||||||
if find . -name "tsconfig.json" -o -name "*.ts" -o -name "*.tsx" 2>/dev/null | head -1; then
|
# Simple tech stack detection
|
||||||
TECH_STACK="typescript-dev"
|
if ls *.ts *.tsx 2>/dev/null | head -1; then
|
||||||
elif find . -name "package.json" 2>/dev/null | xargs grep -l "react" 2>/dev/null; then
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/typescript-dev.md)
|
||||||
TECH_STACK="react-dev"
|
elif grep -q "react" package.json 2>/dev/null; then
|
||||||
elif find . -name "*.py" -o -name "requirements.txt" -o -name "pyproject.toml" 2>/dev/null | head -1; then
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/react-dev.md)
|
||||||
TECH_STACK="python-dev"
|
elif ls *.py requirements.txt 2>/dev/null | head -1; then
|
||||||
elif find . -name "*.java" -o -name "pom.xml" -o -name "build.gradle" 2>/dev/null | head -1; then
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/python-dev.md)
|
||||||
TECH_STACK="java-dev"
|
elif ls *.java pom.xml build.gradle 2>/dev/null | head -1; then
|
||||||
elif find . -name "*.go" -o -name "go.mod" 2>/dev/null | head -1; then
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/java-dev.md)
|
||||||
TECH_STACK="go-dev"
|
elif ls *.go go.mod 2>/dev/null | head -1; then
|
||||||
elif find . -name "*.js" -o -name "package.json" 2>/dev/null | head -1; then
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/go-dev.md)
|
||||||
TECH_STACK="javascript-dev"
|
elif ls *.js package.json 2>/dev/null | head -1; then
|
||||||
|
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/javascript-dev.md)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 2: Load tech stack guidelines
|
|
||||||
TECH_GUIDELINES=$(cat ~/.claude/workflows/cli-templates/tech-stacks/${TECH_STACK}.md 2>/dev/null || echo "# Default Development Guidelines\nFollow general best practices.")
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**🎯 Flow Control Detection**
|
**🎯 Flow Control Detection**
|
||||||
@@ -85,24 +84,26 @@ When task assignment includes flow control marker:
|
|||||||
|
|
||||||
**Context Gathering Decision Logic**:
|
**Context Gathering Decision Logic**:
|
||||||
```
|
```
|
||||||
MANDATORY FIRST STEP:
|
IF task is code review related (review|test|check|analyze|audit + code|implementation|module|component):
|
||||||
→ Execute tech stack detection and load guidelines into [tech_guidelines] variable
|
→ Execute smart tech stack detection and load guidelines into [tech_guidelines] variable
|
||||||
→ All subsequent review criteria must align with loaded tech stack principles
|
→ All subsequent review criteria must align with loaded tech stack principles
|
||||||
|
ELSE:
|
||||||
|
→ Skip tech stack loading for non-code-review tasks
|
||||||
|
|
||||||
IF task contains [FLOW_CONTROL] flag:
|
IF task contains [FLOW_CONTROL] flag:
|
||||||
→ Execute each flow control step sequentially for context gathering
|
→ Execute each flow control step sequentially for context gathering
|
||||||
→ Use four flexible context acquisition methods:
|
→ Use four flexible context acquisition methods:
|
||||||
* Document references (cat commands with tech stack context)
|
* Document references (cat commands)
|
||||||
* Search commands (grep/rg/find for tech-specific patterns)
|
* Search commands (grep/rg/find)
|
||||||
* CLI analysis (gemini/codex with tech stack guidelines)
|
* CLI analysis (gemini/codex)
|
||||||
* Free exploration (Read/Grep/Search tools guided by tech principles)
|
* Free exploration (Read/Grep/Search tools)
|
||||||
→ Process [variable_name] references in commands
|
→ Process [variable_name] references in commands
|
||||||
→ Accumulate context through step outputs
|
→ Accumulate context through step outputs
|
||||||
→ Ensure [tech_guidelines] informs all analysis steps
|
→ Include [tech_guidelines] in analysis if available
|
||||||
ELIF reviewing >3 files OR security changes OR architecture modifications:
|
ELIF reviewing >3 files OR security changes OR architecture modifications:
|
||||||
→ Execute default flow control analysis (AUTO-TRIGGER) with tech stack guidelines
|
→ Execute default flow control analysis (AUTO-TRIGGER)
|
||||||
ELSE:
|
ELSE:
|
||||||
→ Proceed with tech-stack-informed review using standard quality checks
|
→ Proceed with review using standard quality checks (with tech guidelines if loaded)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Review Process (Mode-Adaptive)
|
## Review Process (Mode-Adaptive)
|
||||||
|
|||||||
Reference in New Issue
Block a user