Analyze and design optimal solution with comprehensive architecture evaluation and design decisions.

## CORE CHECKLIST ⚡
□ Read context-package.json to understand task requirements, source files, tech stack
□ Analyze current architecture patterns and code structure
□ Propose solution design with key decisions and rationale
□ Focus on SOLUTION IMPROVEMENTS and KEY DESIGN DECISIONS
□ Write output to specified .workflow/active/{session_id}/.process/ path

## ANALYSIS PRIORITY

### Source Hierarchy
1. **PRIMARY**: Individual role analysis.md files (system-architect, ui-designer, data-architect, etc.)
   - Technical details and implementation considerations
   - Architecture Decision Records (ADRs)
   - Design decision context and rationale

2. **SECONDARY**: role analysis documents
   - Integrated requirements across roles
   - Cross-role alignment and dependencies
   - Unified feature specifications

3. **REFERENCE**: guidance-specification.md
   - Discussion context and background
   - Initial problem framing

## REQUIRED ANALYSIS

### 1. Current State Assessment
- Identify existing architectural patterns and code structure
- Map integration points and dependencies
- Evaluate technical debt and pain points
- Assess framework compatibility and constraints

### 2. Solution Design
- Propose core architecture principles and approach
- Design component architecture and data flow
- Specify API contracts and integration strategy
- Define technology stack with justification

### 3. Key Design Decisions
For each critical decision:
- **Decision**: What is being decided
- **Rationale**: Why this approach
- **Alternatives Considered**: Other options and their tradeoffs
- **Impact**: Implications on architecture, performance, maintainability

Minimum 2 key decisions required.

### 4. Code Modification Targets
Identify specific code locations for changes:
- **Existing files**: `file:function:lines` format (e.g., `src/auth/login.ts:validateUser:45-52`)
- **New files**: `file` only (e.g., `src/auth/PasswordReset.ts`)
- **Unknown lines**: `file:function:*` (e.g., `src/auth/service.ts:refreshToken:*`)

For each target:
- Type: Modify existing | Create new
- Modification/Purpose: What changes needed
- Rationale: Why this target

### 5. Critical Insights
- Strengths: What works well in current/proposed design
- Gaps: Missing capabilities or concerns
- Risks: Technical, integration, performance, security
- Optimization Opportunities: Performance, security, code quality

### 6. Feasibility Assessment
- Technical Complexity: Rating and analysis
- Performance Impact: Expected characteristics
- Resource Requirements: Development effort
- Maintenance Burden: Ongoing considerations

## OUTPUT REQUIREMENTS

### Output File
**Path**: `.workflow/active/{session_id}/.process/gemini-solution-design.md`
**Format**: Follow structure from `~/.ccw/workflows/cli-templates/prompts/workflow/analysis-results-structure.txt`

### Required Sections
- Executive Summary with feasibility score
- Current State Analysis
- Proposed Solution Design with 2+ key decisions
- Implementation Strategy with code targets
- Solution Optimization (performance, security, quality)
- Critical Success Factors
- Confidence Scores with recommendation

### Content Guidelines
- ✅ Focus on solution improvements and key design decisions
- ✅ Include rationale, alternatives, and tradeoffs for decisions
- ✅ Provide specific code targets in correct format
- ✅ Quantify assessments with scores (X/5)
- ❌ Do NOT create task lists or implementation steps
- ❌ Do NOT include code examples or snippets
- ❌ Do NOT create project management timelines

## CONTEXT INTEGRATION

### Session Context
- Load context-package.json for task requirements
- Reference workflow-session.json for session state
- Review CLAUDE.md for project standards

### Brainstorm Context
If brainstorming artifacts exist:
- Prioritize individual role analysis.md files
- Use role analysis documents for integrated view
- Reference guidance-specification.md for context

### Codebase Context
- Identify similar patterns in existing code
- Evaluate success/failure of current approaches
- Ensure consistency with project architecture

## EXECUTION MODE

**Mode**: Analysis with write permission for output file
**CLI Tool**: Gemini wrapper with --approval-mode yolo
**Timeout**: 40-60 minutes based on complexity
**Output**: Single file gemini-solution-design.md

## VERIFICATION CHECKLIST ✓
□ context-package.json read and analyzed
□ All 7 required sections present in output
□ 2+ key design decisions with rationale and alternatives
□ Code targets specified in correct format
□ Feasibility scores provided (X/5)
□ Final recommendation (PROCEED/RECONSIDER/REJECT)
□ Output written to .workflow/active/{session_id}/.process/gemini-solution-design.md

Focus: Comprehensive solution design emphasizing architecture decisions and critical insights.
