phase-8-review
16
总安装量
6
周安装量
#21629
全站排名
安装命令
npx skills add https://github.com/popup-studio-ai/bkit-claude-code --skill phase-8-review
Agent 安装分布
claude-code
5
opencode
4
gemini-cli
4
github-copilot
3
cursor
3
Skill 文档
Phase 8: Architecture/Convention Review
Overall codebase quality verification
Purpose
Review the entire codebase before deployment. Identify architecture consistency, convention compliance, and potential issues.
What to Do in This Phase
- Architecture Review: Review structural consistency
- Convention Review: Verify rule compliance
- Code Quality Review: Duplication, complexity, potential bugs
- Refactoring: Fix discovered issues
Deliverables
docs/03-analysis/
âââ architecture-review.md # Architecture review
âââ convention-review.md # Convention review
âââ refactoring-plan.md # Refactoring plan
PDCA Application
- Plan: Define review scope/criteria
- Design: Design checklist
- Do: Execute code review
- Check: Analyze issues
- Act: Refactor and proceed to Phase 9
Level-wise Application
| Level | Application Method |
|---|---|
| Starter | Can be skipped (simple projects) |
| Dynamic | Required |
| Enterprise | Required + security review |
Full Phase Verification Matrix
Cross-Phase Consistency Verification
Phase 8 verifies that all Phase outputs and rules are consistently applied.
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â Cross-Phase Dependency Flow â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â â
â Phase 1 (Schema/Terminology) â
â â Glossary, entity definitions â
â Phase 2 (Coding Convention) â
â â Naming rules, environment variable conventions â
â Phase 3 (Mockup) â
â â Component structure, Props design â
â Phase 4 (API) â
â â RESTful principles, response format, error codes â
â Phase 5 (Design System) â
â â Design tokens, component variants â
â Phase 6 (UI Implementation) â
â â API client, type sharing, error handling â
â Phase 7 (SEO/Security) â
â â Security rules, metadata â
â Phase 8 (Review) â Current stage: Full verification â
â â â
â Phase 9 (Deployment) â
â â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Phase-specific Verification Checklist
Phase 1 â Verify: Terminology/Schema Consistency
â¡ Are glossary.md terms consistently used in code?
- Business terms â Code naming matching
- Global standard terms â API response field names matching
â¡ Do entity definitions match actual types?
â¡ Do relationship definitions match actual implementation?
Phase 2 â Verify: Convention Compliance
â¡ Naming rule compliance (PascalCase, camelCase, UPPER_SNAKE_CASE)
â¡ Folder structure rule compliance
â¡ Environment variable naming rule compliance (NEXT_PUBLIC_*, DB_*, API_*, etc.)
â¡ .env.example template completion
â¡ Environment variable validation logic (lib/env.ts) exists
Phase 4 â Verify: API Consistency
â¡ RESTful principle compliance
- Resource-based URLs (nouns, plural)
- Correct HTTP method usage
- Status code consistency
â¡ Response format consistency
- Success: { data, meta? }
- Error: { error: { code, message, details? } }
- Pagination: { data, pagination }
â¡ Error code standardization (matches ERROR_CODES constant)
Phase 5 â Verify: Design System Consistency
â¡ Are design tokens defined? (CSS Variables / ThemeData)
â¡ Do components use tokens? (no hardcoded colors)
â¡ Are component variants consistent?
â¡ Dark mode support (if defined)
Phase 6 â Verify: UI-API Integration Consistency
â¡ API client layer structure compliance
- Components â hooks â services â apiClient
- No direct fetch calls
â¡ Type consistency
- Phase 4 API spec types = Phase 6 client types
â¡ Error handling consistency
- Global error handler usage
- Error code-specific handling logic
â¡ State management pattern consistency
Phase 7 â Verify: Security/SEO Application
â¡ Authentication/authorization middleware applied
â¡ Input validation (server-side)
â¡ XSS, CSRF defense
â¡ No sensitive info exposed to client
â¡ SEO meta tags applied
Phase 9 â Verify: Deployment Readiness
â¡ Environment variable Secrets registered (based on Phase 2 list)
â¡ Environment separation (dev/staging/prod)
â¡ Build successful
â¡ Environment variable validation script passes
Clean Architecture Verification
Layer Separation Principles
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â Presentation Layer â
â (pages, components, hooks - UI concerns) â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â Application Layer â
â (services, use-cases - business logic) â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â Domain Layer â
â (entities, types - core domain models) â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ¤
â Infrastructure Layer â
â (api client, db, external services) â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Dependency direction: Outside â Inside (Presentation â Domain)
Inner layers must not know about outer layers
Layer-specific Verification Checklist
Presentation Layer (UI)
â¡ Is there business logic in components?
â¡ Are there direct API calls? (should go through hooks)
â¡ Is state management properly separated?
â¡ Do components have single responsibility?
Application Layer (Services)
â¡ Are domain logic and infrastructure logic separated?
â¡ Are external dependencies abstracted?
â¡ Is the structure testable?
â¡ Are use cases clearly defined?
Domain Layer (Types/Entities)
â¡ Are there no external library dependencies?
â¡ Does it contain only pure business rules?
â¡ Do types match Phase 1 schema?
Infrastructure Layer (API Client)
â¡ Are external service calls abstracted?
â¡ Is error handling consistent?
â¡ Is configuration managed via environment variables?
Architecture Review Checklist
Structure
- Does folder structure match conventions
- Is separation of concerns well done
- Is dependency direction correct (outside â inside)
Patterns
- Are consistent patterns used
- Is there unnecessary abstraction
- Is proper encapsulation done
Convention Review Checklist
Naming
- Does it follow Phase 2 defined rules
- Are meaningful names used
- Is there consistency
Code Style
- Unified indentation, quotes, etc.
- Is file length appropriate
- Is function length appropriate
Code Quality Checklist
- Is there duplicate code
- Are there highly complex functions
- Is error handling appropriate
- Is type safety ensured
AI-Assisted Review
Request code review from Claude:
"Review this project's code.
- Does it follow CONVENTIONS.md rules
- Is there architecture consistency
- Are there potential bugs or improvements"
Template
See templates/pipeline/phase-8-review.template.md
Next Phase
Phase 9: Deployment â After review completion, deploy to production
6. In-Depth Code Quality Review
6.1 Duplicate Code Detection
Detection Methods
# 1. Search for similar function names
grep -r "function.*format" src/
grep -r "function.*calculate" src/
grep -r "function.*get.*By" src/
# 2. Search for similar patterns
grep -rn "reduce.*sum" src/
grep -rn "filter.*map" src/
grep -rn "useState.*useEffect" src/
Handling by Duplication Type
| Type | Example | Solution |
|---|---|---|
| Exact duplicate | Same code copy-paste | Extract to function |
| Structural similarity | Same logic, different data | Parameterize |
| Conceptual similarity | Different implementations for similar purpose | Integrate or interface |
Duplicate Code Checklist
â¡ Is the same logic in 2+ places?
â¡ Are there multiple functions with similar names?
â¡ Is the same data transformation repeated?
â¡ Are similar UI patterns repeated?
â¡ Is the same API call pattern repeated?
â¡ Is similar error handling repeated?
6.2 Reusability Assessment
Assessment Criteria
| Score | Criteria | Description |
|---|---|---|
| âââ | High | Can be used in other projects |
| ââ | Medium | Can be used in multiple places within same project |
| â | Low | Used only for specific feature |
Reusability Checklist
Check for each function/component:
â¡ Is it tied to a specific domain?
â¡ Does it depend on external state?
â¡ Are parameters generic?
â¡ Is the return value predictable?
â¡ Are there side effects?
6.3 Extensibility Assessment
Extensibility Check
When new requirements come:
â¡ Can it be added without modifying existing code?
â¡ Can behavior be changed by configuration only?
â¡ Is adding new types/cases easy?
â¡ Can it be extended without adding conditionals?
Extensibility Anti-patterns
// â Requires modification for each extension
function process(type: string) {
if (type === 'a') { /* ... */ }
else if (type === 'b') { /* ... */ }
// Add else if for each new type...
}
// â Hardcoded list
const ALLOWED_TYPES = ['a', 'b', 'c']
// â Enumerated switch statements
switch (action.type) {
case 'ADD': // ...
case 'REMOVE': // ...
// Add case for each new action...
}
Good Extensibility Patterns
// â
Registry pattern
const handlers: Record<string, Handler> = {}
function register(type: string, handler: Handler) {
handlers[type] = handler
}
function process(type: string, data: unknown) {
return handlers[type]?.(data)
}
// â
Configuration-based
const CONFIG = {
types: ['a', 'b', 'c'],
handlers: { ... }
}
// â
Plugin structure
interface Plugin { execute(data): Result }
const plugins: Plugin[] = []
6.4 Object-Oriented Principles Check
SOLID Principles Checklist
S – Single Responsibility (SRP)
â¡ Does the class/function change for only one reason?
â¡ Does the name clearly explain the role?
â¡ Is "and" in the name? â Needs separation
O – Open/Closed (OCP)
â¡ Is it open for extension? (new features can be added)
â¡ Is it closed for modification? (no existing code changes needed)
â¡ Are interfaces/abstractions used?
L – Liskov Substitution (LSP)
â¡ Can subtypes replace parent types?
â¡ Do overridden methods keep the contract?
I – Interface Segregation (ISP)
â¡ Is the interface too large?
â¡ Must unused methods be implemented?
â¡ Can the interface be split smaller?
D – Dependency Inversion (DIP)
â¡ Does it depend on abstractions instead of concrete classes?
â¡ Are dependencies injected? (DI)
â¡ Is the structure testable?
6.5 Refactoring Priority
Urgent (Required before deployment):
1. Duplication that can cause bugs
2. Security vulnerabilities
3. Performance bottlenecks
High (As soon as possible):
4. Same logic duplicated in 3+ places
5. Files over 200 lines
6. Nesting deeper than 5 levels
Medium (Next sprint):
7. Structure lacking extensibility
8. Naming inconsistencies
9. Structure difficult to test
Low (Backlog):
10. Style inconsistencies
11. Excessive comments
12. Unused code
7. AI Code Review Request Template
Please review the code from these perspectives:
1. Duplicate Code
- Are there similar functions/components?
- Is there common logic that can be extracted?
2. Reusability
- Can it be used generically?
- Is it tied to a specific domain?
3. Extensibility
- Can it flexibly respond to new requirements?
- Are there hardcoded parts?
4. SOLID Principles
- Does it follow single responsibility?
- Is it open for extension and closed for modification?
5. Convention Compliance
- Does it follow CONVENTIONS.md rules?
- Is naming consistent?
Please identify parts that need refactoring and their priority.
8. Gap Analysis (Design vs Implementation)
Gap Analysis Report Template
# Gap Analysis Report
## Analysis Target
- Design document: docs/02-design/{feature}.design.md
- Implementation path: src/features/{feature}/
## Results by Category
### API Endpoints
| Design | Implementation | Status |
|--------|----------------|--------|
| POST /api/users | POST /api/users | â
Match |
| GET /api/users/:id | - | â Not implemented |
| - | DELETE /api/users/:id | â ï¸ Missing from design |
### Data Model
| Design Entity | Implementation | Status |
|---------------|----------------|--------|
| User | types/user.ts | â
Match |
| UserRole | - | â Not implemented |
### Match Rate
- Total items: 10
- Matches: 7
- Not implemented: 2
- Missing from design: 1
- **Match Rate: 70%**
Gap Types and Actions
| Gap Type | Meaning | Action |
|---|---|---|
| â Match | Design = Implementation | None |
| â Not implemented | In design, not in code | Implement or update design |
| â ï¸ Missing from design | In code, not in design | Add to design document |
| ð Different | Exists but different | Align (code is truth) |
When to Run Gap Analysis
- After completing feature implementation
- Before deployment
- When design document is updated
- During code review