analyze-yii2-project
Use this when user provides a Yii2 codebase for analysis or migration planning. Provides 6-phase workflow: scan, capability extraction, dependency analysis, requirements extraction, semantic indexing, and migration roadmap. Apply when user mentions Yii2, PHP legacy modernization, or framework migration to NestJS
Best use case
analyze-yii2-project is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Use this when user provides a Yii2 codebase for analysis or migration planning. Provides 6-phase workflow: scan, capability extraction, dependency analysis, requirements extraction, semantic indexing, and migration roadmap. Apply when user mentions Yii2, PHP legacy modernization, or framework migration to NestJS
Teams using analyze-yii2-project should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/analyze-yii2-project/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How analyze-yii2-project Compares
| Feature / Agent | analyze-yii2-project | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Use this when user provides a Yii2 codebase for analysis or migration planning. Provides 6-phase workflow: scan, capability extraction, dependency analysis, requirements extraction, semantic indexing, and migration roadmap. Apply when user mentions Yii2, PHP legacy modernization, or framework migration to NestJS
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Analyze Yii2 Project Workflow
## Purpose
Comprehensive workflow for analyzing legacy Yii2 projects to extract business logic, understand architecture, and plan modernization.
## When to Use
- ✅ User provides Yii2 codebase for analysis
- ✅ Planning Yii2 → NestJS/Modern framework migration
- ✅ Need to understand undocumented Yii2 project
- ✅ Extracting business requirements from Yii2 code
- ✅ Technical debt assessment of Yii2 application
## Prerequisites
### Infrastructure Check
```bash
codecompass health
```
**Verify**:
- ✅ Weaviate running (localhost:8081)
- ✅ Ollama running (localhost:11434)
- ✅ PostgreSQL running (localhost:5433)
### Project Requirements
- Yii2 project directory accessible
- `vendor/` directory present (run `composer install` if missing)
- Read permissions on all files
## Step-by-Step Workflow
### Phase 1: Initial Scan (Quick Overview)
**Step 1.1: Run Yii2 Analyzer**
```bash
codecompass analyze:yii2 <path-to-yii2-project>
```
**What this does**:
- Scans directory structure
- Detects Yii2 version
- Identifies conventions (controllers, models, views)
- Extracts routing patterns
- Maps database migrations
**Expected output**:
- Framework version
- Directory structure validation
- Controller/Model counts
- Migration history
**Step 1.2: Validate Results**
Check for:
- ❌ Missing `vendor/` → Run `composer install`
- ❌ Old Yii2 version (<2.0.40) → Check compatibility notes in `docs/YII2_QUICK_REFERENCE.md`
- ❌ Non-standard structure → May need manual configuration
### Phase 2: Business Capability Extraction
**Step 2.1: Extract Controllers → Capabilities**
```bash
# Analyzer automatically extracts business capabilities from controllers
```
**What this maps**:
```
Controller → Business Capability
├── UserController → User Management
├── OrderController → Order Processing
├── PaymentController → Payment Handling
└── ReportController → Reporting & Analytics
```
**Step 2.2: Extract Models → Domain Entities**
**Identifies**:
- ActiveRecord models → Database entities
- Validation rules → Business rules
- Relationships → Domain model connections
**Step 2.3: Extract Migrations → Data Model Evolution**
**Traces**:
- Schema changes over time
- Business logic embedded in migrations
- Data transformation patterns
### Phase 3: Dependency Analysis
**Step 3.1: Analyze Class Dependencies**
Uses: `AstAnalyzerService` for PHP parsing
**Maps**:
- Tight coupling (classes depending on many others)
- Circular dependencies (refactoring red flags)
- Inheritance hierarchies
- Service dependencies
**Step 3.2: Identify Core vs Supporting Logic**
**Categorizes**:
- **Core Domain**: Business-critical logic (preserve carefully)
- **Supporting**: Infrastructure, utilities (can be replaced)
- **Generic**: Framework boilerplate (discard in migration)
### Phase 4: Requirements Extraction
**Step 4.1: Run Requirements Extractor**
```bash
codecompass requirements:extract --project-id <yii2-project-id>
```
**Extracts**:
- Validation rules from models → Business constraints
- Controller actions → Use cases
- RBAC rules (if present) → Authorization requirements
- Database constraints → Data integrity rules
**Step 4.2: Generate Documentation**
**Outputs**:
- Business capability map (Markdown)
- Domain model diagram (Mermaid)
- Use case catalog
- Data dictionary
### Phase 5: Semantic Indexing (Optional but Recommended)
**Step 5.1: Index Codebase**
```bash
codecompass batch:index <path-to-yii2-project>
```
**Why**:
- Enables semantic search for "business logic for payment processing"
- Cross-file pattern discovery
- Similar code detection
- Natural language queries
**Step 5.2: Verify Indexing**
```bash
curl http://localhost:8081/v1/schema
# Check for CodeContext or AtlasCode collection
```
**Step 5.3: Test Semantic Search**
```bash
codecompass search:semantic "validation rules for customer registration"
```
Should return: User model validators, controller logic, related code
### Phase 6: Migration Planning
**Step 6.1: Identify Migration Complexity**
**Assess**:
- **Low complexity**: CRUD operations, standard patterns
- **Medium complexity**: Custom workflows, business rules
- **High complexity**: Legacy integrations, undocumented logic
**Step 6.2: Prioritize by Business Value**
**Map**:
```
Business Capability → Migration Priority
├── Core Revenue Generating → HIGH (do first, carefully)
├── Customer-Facing → MEDIUM (visible impact)
└── Internal Tools → LOW (can defer)
```
**Step 6.3: Generate Migration Roadmap**
**Structure**:
1. Infrastructure setup (NestJS, TypeORM, etc.)
2. Domain models (migrate ActiveRecords → TypeORM entities)
3. Core business logic (preserve carefully)
4. API layer (REST/GraphQL endpoints)
5. Background jobs (if using Yii2 queue)
6. Testing & validation
## Common Patterns to Look For
### Yii2 Controller Patterns
```php
// CRUD pattern
public function actionIndex() // → LIST endpoint
public function actionView($id) // → GET/:id endpoint
public function actionCreate() // → POST endpoint
public function actionUpdate($id) // → PUT/:id endpoint
public function actionDelete($id) // → DELETE/:id endpoint
```
**Maps to NestJS**:
```typescript
@Controller('users')
export class UsersController {
@Get() findAll()
@Get(':id') findOne()
@Post() create()
@Put(':id') update()
@Delete(':id') remove()
}
```
### Yii2 Model Patterns
```php
// Validation rules
public function rules() {
return [
[['email'], 'required'],
[['email'], 'email'],
];
}
```
**Maps to NestJS DTO**:
```typescript
export class CreateUserDto {
@IsNotEmpty()
@IsEmail()
email: string;
}
```
### Yii2 Database Patterns
```php
// ActiveRecord query
$users = User::find()
->where(['status' => User::STATUS_ACTIVE])
->orderBy('created_at DESC')
->all();
```
**Maps to TypeORM**:
```typescript
const users = await this.userRepository.find({
where: { status: UserStatus.ACTIVE },
order: { createdAt: 'DESC' },
});
```
## Output Artifacts
### 1. Architecture Diagram (Mermaid)
```mermaid
graph TD
Controller[Controllers] --> Service[Business Logic]
Service --> Model[ActiveRecord Models]
Model --> DB[(Database)]
Controller --> View[Views]
```
### 2. Business Capability Map
```markdown
## Core Capabilities
- User Management (UserController, User model)
- Order Processing (OrderController, Order/OrderItem models)
- Payment Handling (PaymentController, Payment model)
## Supporting Capabilities
- Reporting (ReportController)
- Notifications (EmailService)
```
### 3. Migration Checklist
- [ ] Set up NestJS project structure
- [ ] Migrate database schema (Yii2 migrations → TypeORM migrations)
- [ ] Port models (ActiveRecord → TypeORM entities)
- [ ] Reimplement business logic (preserve rules!)
- [ ] Create API endpoints (REST/GraphQL)
- [ ] Port authentication/authorization
- [ ] Migrate background jobs
- [ ] Integration testing
- [ ] Performance testing
- [ ] Gradual rollout
## Common Issues & Solutions
### Issue 1: Cannot find controllers
**Symptom**: Analyzer reports 0 controllers
**Cause**: Non-standard directory structure
**Solution**: Check `@app` alias configuration in Yii2, adjust paths
### Issue 2: Missing database schema
**Symptom**: Cannot extract models properly
**Cause**: Database not accessible or migrations not run
**Solution**: Ensure database connection configured, run pending migrations
### Issue 3: Circular dependencies detected
**Symptom**: Dependency graph shows circular references
**Meaning**: Code smell - tight coupling between modules
**Action**: Plan refactoring to break cycles during migration
### Issue 4: Undocumented business rules
**Symptom**: Complex logic in controllers with no comments
**Action**:
1. Use semantic search to find similar patterns
2. Interview original developers if available
3. Write tests to capture behavior before migration
4. Document assumptions in requirements docs
## Best Practices
### ✅ Do
- Run full analysis before planning migration
- Extract ALL business rules (even implicit ones)
- Document assumptions and unknowns
- Test semantic search to validate indexing
- Create comprehensive capability map
- Prioritize by business value, not technical ease
### ❌ Don't
- Skip dependency analysis (will bite you later)
- Assume standard Yii2 patterns everywhere
- Ignore validation rules (they're business requirements!)
- Start coding before understanding full architecture
- Migrate everything at once (strangler fig pattern instead)
## Related Skills
- `extract-requirements.md` - For detailed requirements extraction
- `semantic-search.md` - For code exploration
- `software-architect.md` - For architecture perspective
## Related Modules
From `.ai/capabilities.json`:
- `yii2-analyzer` - Main analysis module
- `ast-analyzer` - PHP parsing
- `database-analyzer` - Schema extraction
- `requirements` - Business rules extraction
- `business-analyzer` - Capability mapping
---
**Remember**: The goal is not just to understand the code, but to preserve the business knowledge embedded in it.Related Skills
awesome-copilot-root-create-spring-boot-java-project
Create Spring Boot Java Project Skeleton Use when: the task directly matches create spring boot java project responsibilities within plugin awesome-copilot-root. Do not use when: a more specific framework or task-focused skill is clearly a better match.
awareness-analyzer
Diagnose audience awareness level and market sophistication using Eugene Schwartz's Breakthrough Advertising framework
ast-analyzer
Deep Abstract Syntax Tree analysis for understanding code structure, dependencies, impact analysis, and pattern detection at the structural level across multiple programming languages
android-project
Navigate and analyze Android project structure, modules, and dependencies. Use when exploring project structure, finding related files, analyzing dependencies, or locating code patterns.
analyzing-projects
Analyzes codebases to understand structure, tech stack, patterns, and conventions. Use when onboarding to a new project, exploring unfamiliar code, or when asked "how does this work?" or "what's the architecture?"
analyzer-architecture-review
analyzerアプリケーションのアーキテクチャレビュー。Port&Adapterアーキテクチャ(ヘキサゴナルアーキテクチャ)のルールに従っているかをチェックします。新しいPort/Adapter/Usecase/Model追加時、PRレビュー時、またはアーキテクチャ違反の検出が必要な時に使用します。Port層の関数型定義、依存関係の方向、New*関数パターン、レイヤー分離などを検証します。
analyze-code
外部ライブラリや他言語で書かれたコードの実装を分析して知見を得る
analyze-wast
Analyze WebAssembly test (WAST) files to debug compilation issues and create regression tests. Use when the user asks to debug or analyze WAST test failures, investigate compilation bugs in wasmoon, or when encountering test failures in spec/*.wast files. Triggers include "analyze wast", "debug wast", "wast bug", or references to specific .wast test files.
analyze
Deep analysis mode - thorough multi-phase investigation with expert consultation for complex problems requiring careful examination
analyze-system
システム分析エージェント - ユビキタス言語、アクター、ロール、権限、ドメイン-コード対応表を抽出。/analyze-system [対象パス] で呼び出し。
analyze-size
Analyze codebase size and language distribution using cloc. Use when user wants to understand codebase scale, primary languages, code composition, or assess project complexity. Provides total LOC, size category, language breakdown percentages, and key insights.
analyze-rust-optimizations
This skill performs thorough analysis of Rust libraries to find optimization opportunities. It should be used when reviewing Rust code for performance improvements, memory efficiency, or when profiling indicates bottlenecks. Focuses on runtime performance and memory usage through dynamic profiling tools and static code analysis.