create-ai-project 1.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/acceptance-test-generator.md +316 -0
- package/.claude/agents/code-reviewer.md +193 -0
- package/.claude/agents/document-reviewer.md +182 -0
- package/.claude/agents/prd-creator.md +186 -0
- package/.claude/agents/quality-fixer.md +295 -0
- package/.claude/agents/requirement-analyzer.md +161 -0
- package/.claude/agents/rule-advisor.md +194 -0
- package/.claude/agents/task-decomposer.md +291 -0
- package/.claude/agents/task-executor.md +270 -0
- package/.claude/agents/technical-designer.md +343 -0
- package/.claude/agents/work-planner.md +181 -0
- package/.claude/agents-en/acceptance-test-generator.md +256 -0
- package/.claude/agents-en/code-reviewer.md +195 -0
- package/.claude/agents-en/design-sync.md +225 -0
- package/.claude/agents-en/document-reviewer.md +190 -0
- package/.claude/agents-en/integration-test-reviewer.md +195 -0
- package/.claude/agents-en/prd-creator.md +196 -0
- package/.claude/agents-en/quality-fixer-frontend.md +334 -0
- package/.claude/agents-en/quality-fixer.md +291 -0
- package/.claude/agents-en/requirement-analyzer.md +165 -0
- package/.claude/agents-en/rule-advisor.md +194 -0
- package/.claude/agents-en/task-decomposer.md +291 -0
- package/.claude/agents-en/task-executor-frontend.md +276 -0
- package/.claude/agents-en/task-executor.md +272 -0
- package/.claude/agents-en/technical-designer-frontend.md +441 -0
- package/.claude/agents-en/technical-designer.md +371 -0
- package/.claude/agents-en/work-planner.md +216 -0
- package/.claude/agents-ja/acceptance-test-generator.md +256 -0
- package/.claude/agents-ja/code-reviewer.md +195 -0
- package/.claude/agents-ja/design-sync.md +225 -0
- package/.claude/agents-ja/document-reviewer.md +192 -0
- package/.claude/agents-ja/integration-test-reviewer.md +195 -0
- package/.claude/agents-ja/prd-creator.md +194 -0
- package/.claude/agents-ja/quality-fixer-frontend.md +335 -0
- package/.claude/agents-ja/quality-fixer.md +292 -0
- package/.claude/agents-ja/requirement-analyzer.md +164 -0
- package/.claude/agents-ja/rule-advisor.md +194 -0
- package/.claude/agents-ja/task-decomposer.md +291 -0
- package/.claude/agents-ja/task-executor-frontend.md +276 -0
- package/.claude/agents-ja/task-executor.md +272 -0
- package/.claude/agents-ja/technical-designer-frontend.md +442 -0
- package/.claude/agents-ja/technical-designer.md +370 -0
- package/.claude/agents-ja/work-planner.md +213 -0
- package/.claude/commands/build.md +78 -0
- package/.claude/commands/design.md +27 -0
- package/.claude/commands/implement.md +79 -0
- package/.claude/commands/plan.md +43 -0
- package/.claude/commands/project-inject.md +76 -0
- package/.claude/commands/refine-rule.md +206 -0
- package/.claude/commands/review.md +78 -0
- package/.claude/commands/sync-rules.md +116 -0
- package/.claude/commands/task.md +13 -0
- package/.claude/commands-en/build.md +77 -0
- package/.claude/commands-en/design.md +39 -0
- package/.claude/commands-en/front-build.md +103 -0
- package/.claude/commands-en/front-design.md +42 -0
- package/.claude/commands-en/front-plan.md +40 -0
- package/.claude/commands-en/implement.md +75 -0
- package/.claude/commands-en/plan.md +45 -0
- package/.claude/commands-en/project-inject.md +76 -0
- package/.claude/commands-en/refine-rule.md +208 -0
- package/.claude/commands-en/review.md +78 -0
- package/.claude/commands-en/sync-rules.md +116 -0
- package/.claude/commands-en/task.md +13 -0
- package/.claude/commands-ja/build.md +75 -0
- package/.claude/commands-ja/design.md +37 -0
- package/.claude/commands-ja/front-build.md +103 -0
- package/.claude/commands-ja/front-design.md +42 -0
- package/.claude/commands-ja/front-plan.md +40 -0
- package/.claude/commands-ja/implement.md +73 -0
- package/.claude/commands-ja/plan.md +43 -0
- package/.claude/commands-ja/project-inject.md +76 -0
- package/.claude/commands-ja/refine-rule.md +206 -0
- package/.claude/commands-ja/review.md +78 -0
- package/.claude/commands-ja/sync-rules.md +116 -0
- package/.claude/commands-ja/task.md +13 -0
- package/.claude/settings.local.json +74 -0
- package/.husky/pre-commit +1 -0
- package/.husky/pre-push +3 -0
- package/.madgerc +14 -0
- package/.tsprunerc +11 -0
- package/CLAUDE.en.md +102 -0
- package/CLAUDE.ja.md +102 -0
- package/CLAUDE.md +111 -0
- package/LICENSE +21 -0
- package/README.ja.md +233 -0
- package/README.md +243 -0
- package/bin/create-project.js +87 -0
- package/biome.json +51 -0
- package/docs/adr/template-en.md +64 -0
- package/docs/adr/template-ja.md +64 -0
- package/docs/design/template-en.md +281 -0
- package/docs/design/template-ja.md +285 -0
- package/docs/guides/en/quickstart.md +111 -0
- package/docs/guides/en/rule-editing-guide.md +266 -0
- package/docs/guides/en/sub-agents.md +343 -0
- package/docs/guides/en/use-cases.md +308 -0
- package/docs/guides/ja/quickstart.md +112 -0
- package/docs/guides/ja/rule-editing-guide.md +266 -0
- package/docs/guides/ja/sub-agents.md +343 -0
- package/docs/guides/ja/use-cases.md +290 -0
- package/docs/guides/sub-agents.md +306 -0
- package/docs/plans/20250123-integration-test-improvement.md +993 -0
- package/docs/plans/template-en.md +130 -0
- package/docs/plans/template-ja.md +130 -0
- package/docs/prd/template-en.md +109 -0
- package/docs/prd/template-ja.md +109 -0
- package/docs/rules/ai-development-guide.md +260 -0
- package/docs/rules/architecture/implementation-approach.md +136 -0
- package/docs/rules/documentation-criteria.md +180 -0
- package/docs/rules/project-context.md +38 -0
- package/docs/rules/rules-index.yaml +137 -0
- package/docs/rules/technical-spec.md +47 -0
- package/docs/rules/typescript-testing.md +188 -0
- package/docs/rules/typescript.md +166 -0
- package/docs/rules-en/architecture/implementation-approach.md +136 -0
- package/docs/rules-en/coding-standards.md +333 -0
- package/docs/rules-en/documentation-criteria.md +184 -0
- package/docs/rules-en/frontend/technical-spec.md +143 -0
- package/docs/rules-en/frontend/typescript-testing.md +124 -0
- package/docs/rules-en/frontend/typescript.md +131 -0
- package/docs/rules-en/integration-e2e-testing.md +149 -0
- package/docs/rules-en/project-context.md +38 -0
- package/docs/rules-en/rules-index.yaml +211 -0
- package/docs/rules-en/technical-spec.md +86 -0
- package/docs/rules-en/typescript-testing.md +149 -0
- package/docs/rules-en/typescript.md +116 -0
- package/docs/rules-ja/architecture/implementation-approach.md +136 -0
- package/docs/rules-ja/coding-standards.md +333 -0
- package/docs/rules-ja/documentation-criteria.md +180 -0
- package/docs/rules-ja/frontend/technical-spec.md +143 -0
- package/docs/rules-ja/frontend/typescript-testing.md +124 -0
- package/docs/rules-ja/frontend/typescript.md +131 -0
- package/docs/rules-ja/integration-e2e-testing.md +149 -0
- package/docs/rules-ja/project-context.md +38 -0
- package/docs/rules-ja/rules-index.yaml +196 -0
- package/docs/rules-ja/technical-spec.md +86 -0
- package/docs/rules-ja/typescript-testing.md +149 -0
- package/docs/rules-ja/typescript.md +116 -0
- package/package.json +98 -0
- package/scripts/check-unused-exports.js +69 -0
- package/scripts/cleanup-test-processes.sh +32 -0
- package/scripts/post-setup.js +110 -0
- package/scripts/set-language.js +310 -0
- package/scripts/setup-project.js +199 -0
- package/scripts/show-coverage.js +74 -0
- package/src/index.ts +11 -0
- package/templates/.gitignore.template +52 -0
- package/tsconfig.json +50 -0
- package/vitest.config.mjs +47 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Technical Design Rules
|
|
2
|
+
|
|
3
|
+
## Basic Technology Stack Policy
|
|
4
|
+
TypeScript-based application implementation. Architecture patterns should be selected according to project requirements and scale.
|
|
5
|
+
|
|
6
|
+
## Environment Variable Management and Security
|
|
7
|
+
|
|
8
|
+
### Environment Variable Management
|
|
9
|
+
- Centrally manage environment variables and build mechanisms to ensure type safety
|
|
10
|
+
- Avoid direct references to `process.env`, obtain through configuration management layer
|
|
11
|
+
- Properly implement default value settings and mandatory checks
|
|
12
|
+
|
|
13
|
+
### Security
|
|
14
|
+
- Do not include `.env` files in Git
|
|
15
|
+
- Always manage API keys and secrets as environment variables
|
|
16
|
+
- Prohibit logging of sensitive information
|
|
17
|
+
- Do not include sensitive information in error messages
|
|
18
|
+
|
|
19
|
+
## Architecture Design
|
|
20
|
+
|
|
21
|
+
### Architecture Design Principles
|
|
22
|
+
Select appropriate architecture for each project and define clearly:
|
|
23
|
+
|
|
24
|
+
- **Clear Definition**: Project architecture is defined in dedicated files under `docs/rules/architecture/`
|
|
25
|
+
- **Separation of Responsibilities**: Clearly define responsibilities for each layer and module, and maintain boundaries
|
|
26
|
+
|
|
27
|
+
## Pattern Application Consistency
|
|
28
|
+
|
|
29
|
+
Strictly follow selected architecture patterns. See `docs/rules/architecture/` for project-specific details.
|
|
30
|
+
|
|
31
|
+
## Unified Data Flow Principles
|
|
32
|
+
|
|
33
|
+
#### Basic Principles
|
|
34
|
+
1. **Single Data Source**: Store the same information in only one place
|
|
35
|
+
2. **Structured Data Priority**: Use parsed objects rather than JSON strings
|
|
36
|
+
3. **Clear Responsibility Separation**: Clearly define responsibilities for each layer
|
|
37
|
+
|
|
38
|
+
#### Data Flow Best Practices
|
|
39
|
+
- **Validation at Input**: Validate data at input layer and pass internally in type-safe form
|
|
40
|
+
- **Centralized Transformation**: Consolidate data transformation logic in dedicated utilities
|
|
41
|
+
- **Structured Logging**: Output structured logs at each stage of data flow
|
|
42
|
+
|
|
43
|
+
## Build and Testing
|
|
44
|
+
Use the appropriate run command based on the `packageManager` field in package.json.
|
|
45
|
+
|
|
46
|
+
### Build Commands
|
|
47
|
+
- `build` - TypeScript build
|
|
48
|
+
- `type-check` - Type check (no emit)
|
|
49
|
+
|
|
50
|
+
### Testing Commands
|
|
51
|
+
- `test` - Run tests
|
|
52
|
+
- `test:coverage` - Run tests with coverage
|
|
53
|
+
- `test:coverage:fresh` - Run tests with coverage (fresh cache)
|
|
54
|
+
- `test:safe` - Safe test execution (with auto cleanup)
|
|
55
|
+
- `cleanup:processes` - Cleanup Vitest processes
|
|
56
|
+
|
|
57
|
+
### Quality Check Requirements
|
|
58
|
+
|
|
59
|
+
Quality checks are mandatory upon implementation completion:
|
|
60
|
+
|
|
61
|
+
**Phase 1-3: Code Quality Checks**
|
|
62
|
+
- `check` - Biome (lint + format)
|
|
63
|
+
- `check:unused` - Detect unused exports
|
|
64
|
+
- `check:deps` - Detect circular dependencies
|
|
65
|
+
- `build` - TypeScript build
|
|
66
|
+
|
|
67
|
+
**Phase 4: Tests**
|
|
68
|
+
- `test` - Test execution
|
|
69
|
+
|
|
70
|
+
**Phase 5: Code Quality Re-verification**
|
|
71
|
+
- `check:code` - Re-verify code quality (clean up side effects from test fixes in Phase 4)
|
|
72
|
+
|
|
73
|
+
### Auxiliary Commands
|
|
74
|
+
- `check:all` - Overall integrated check (check:code + test) *for manual batch verification
|
|
75
|
+
- `open coverage/index.html` - Check coverage report
|
|
76
|
+
- `format` - Format fixes
|
|
77
|
+
- `lint:fix` - Lint fixes
|
|
78
|
+
|
|
79
|
+
### Troubleshooting
|
|
80
|
+
- **Port in use error**: Run the `cleanup:processes` script
|
|
81
|
+
- **Cache issues**: Run the `test:coverage:fresh` script
|
|
82
|
+
- **Dependency errors**: Clean reinstall dependencies
|
|
83
|
+
|
|
84
|
+
### Coverage Requirements
|
|
85
|
+
- **MANDATORY**: Unit test coverage MUST be 70% or higher
|
|
86
|
+
- **Metrics**: Statements, Branches, Functions, Lines
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# TypeScript Testing Rules
|
|
2
|
+
|
|
3
|
+
## Test Framework
|
|
4
|
+
|
|
5
|
+
- **Vitest**: This project uses Vitest
|
|
6
|
+
- Test imports: `import { describe, it, expect, beforeEach, vi } from 'vitest'`
|
|
7
|
+
- Mock creation: Use `vi.mock()`
|
|
8
|
+
|
|
9
|
+
## Basic Testing Policy
|
|
10
|
+
|
|
11
|
+
### Quality Requirements
|
|
12
|
+
- **Coverage**: Unit test coverage must be 70% or higher
|
|
13
|
+
- **Independence**: Each test can run independently without depending on other tests
|
|
14
|
+
- **Reproducibility**: Tests are environment-independent and always return the same results
|
|
15
|
+
- **Readability**: Test code maintains the same quality as production code
|
|
16
|
+
|
|
17
|
+
### Coverage Requirements
|
|
18
|
+
**Mandatory**: Unit test coverage must be 70% or higher
|
|
19
|
+
**Metrics**: Statements, Branches, Functions, Lines
|
|
20
|
+
|
|
21
|
+
### Test Types and Scope
|
|
22
|
+
1. **Unit Tests**
|
|
23
|
+
- Verify behavior of individual functions or classes
|
|
24
|
+
- Mock all external dependencies
|
|
25
|
+
- Most numerous, implemented with fine granularity
|
|
26
|
+
|
|
27
|
+
2. **Integration Tests**
|
|
28
|
+
- Verify coordination between multiple components
|
|
29
|
+
- Use actual dependencies (DB, API, etc.)
|
|
30
|
+
- Verify major functional flows
|
|
31
|
+
|
|
32
|
+
3. **Cross-functional Verification in E2E Tests**
|
|
33
|
+
- Mandatory verification of impact on existing features when adding new features
|
|
34
|
+
- Cover integration points with "High" and "Medium" impact levels from Design Doc's "Integration Point Map"
|
|
35
|
+
- Verification pattern: Existing feature operation → Enable new feature → Verify continuity of existing features
|
|
36
|
+
- Success criteria: No change in response content, processing time within 5 seconds
|
|
37
|
+
- Designed for automatic execution in CI/CD pipelines
|
|
38
|
+
|
|
39
|
+
## Test Implementation Conventions
|
|
40
|
+
|
|
41
|
+
### Directory Structure
|
|
42
|
+
```
|
|
43
|
+
src/
|
|
44
|
+
└── application/
|
|
45
|
+
└── services/
|
|
46
|
+
├── __tests__/
|
|
47
|
+
│ ├── service.test.ts # Unit tests
|
|
48
|
+
│ └── service.int.test.ts # Integration tests
|
|
49
|
+
└── service.ts
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Naming Conventions
|
|
53
|
+
- Test files: `{target-file-name}.test.ts`
|
|
54
|
+
- Integration test files: `{target-file-name}.int.test.ts`
|
|
55
|
+
- Test suites: Names describing target features or situations
|
|
56
|
+
- Test cases: Names describing expected behavior
|
|
57
|
+
|
|
58
|
+
### Test Code Quality Rules
|
|
59
|
+
|
|
60
|
+
✅ **Recommended: Keep all tests always active**
|
|
61
|
+
- Merit: Guarantees test suite completeness
|
|
62
|
+
- Practice: Fix problematic tests and activate them
|
|
63
|
+
|
|
64
|
+
❌ **Avoid: test.skip() or commenting out**
|
|
65
|
+
- Reason: Creates test gaps and incomplete quality checks
|
|
66
|
+
- Solution: Completely delete unnecessary tests
|
|
67
|
+
|
|
68
|
+
## Test Quality Criteria
|
|
69
|
+
|
|
70
|
+
### Boundary and Error Case Coverage
|
|
71
|
+
Include boundary values and error cases alongside happy paths.
|
|
72
|
+
```typescript
|
|
73
|
+
it('returns 0 for empty array', () => expect(calc([])).toBe(0))
|
|
74
|
+
it('throws on negative price', () => expect(() => calc([{price: -1}])).toThrow())
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Literal Expected Values
|
|
78
|
+
Use literal values for assertions. Do not replicate implementation logic.
|
|
79
|
+
```typescript
|
|
80
|
+
expect(calcTax(100)).toBe(10) // not: 100 * TAX_RATE
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Result-Based Verification
|
|
84
|
+
Verify results, not invocation order or count.
|
|
85
|
+
```typescript
|
|
86
|
+
expect(mock).toHaveBeenCalledWith('a') // not: toHaveBeenNthCalledWith
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Meaningful Assertions
|
|
90
|
+
Each test must include at least one verification.
|
|
91
|
+
```typescript
|
|
92
|
+
it('creates user', async () => {
|
|
93
|
+
const user = await createUser({name: 'test'})
|
|
94
|
+
expect(user.id).toBeDefined()
|
|
95
|
+
})
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Appropriate Mock Scope
|
|
99
|
+
Mock only direct external I/O dependencies. Use real implementations for indirect dependencies.
|
|
100
|
+
```typescript
|
|
101
|
+
vi.mock('./database') // external I/O only
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Property-based Testing (fast-check)
|
|
105
|
+
Use fast-check when verifying invariants or properties.
|
|
106
|
+
```typescript
|
|
107
|
+
import fc from 'fast-check'
|
|
108
|
+
|
|
109
|
+
it('reverses twice equals original', () => {
|
|
110
|
+
fc.assert(fc.property(fc.array(fc.integer()), (arr) => {
|
|
111
|
+
return JSON.stringify(arr.reverse().reverse()) === JSON.stringify(arr)
|
|
112
|
+
}))
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Usage condition**: Use when Property annotations are assigned to ACs in Design Doc.
|
|
117
|
+
|
|
118
|
+
## Mock Type Safety Enforcement
|
|
119
|
+
|
|
120
|
+
### Minimal Type Definition Requirements
|
|
121
|
+
```typescript
|
|
122
|
+
// ✅ Only required parts
|
|
123
|
+
type TestRepo = Pick<Repository, 'find' | 'save'>
|
|
124
|
+
const mock: TestRepo = { find: vi.fn(), save: vi.fn() }
|
|
125
|
+
|
|
126
|
+
// Only when absolutely necessary, with clear justification
|
|
127
|
+
const sdkMock = {
|
|
128
|
+
call: vi.fn()
|
|
129
|
+
} as unknown as ExternalSDK // Complex external SDK type structure
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Basic Vitest Example
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
136
|
+
|
|
137
|
+
vi.mock('./userService', () => ({
|
|
138
|
+
getUserById: vi.fn(),
|
|
139
|
+
updateUser: vi.fn()
|
|
140
|
+
}))
|
|
141
|
+
|
|
142
|
+
describe('ComponentName', () => {
|
|
143
|
+
it('should follow AAA pattern', () => {
|
|
144
|
+
const input = 'test'
|
|
145
|
+
const result = someFunction(input)
|
|
146
|
+
expect(result).toBe('expected')
|
|
147
|
+
})
|
|
148
|
+
})
|
|
149
|
+
```
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# TypeScript Development Rules
|
|
2
|
+
|
|
3
|
+
## Type Safety in Backend Implementation
|
|
4
|
+
|
|
5
|
+
**Type Safety in Data Flow**
|
|
6
|
+
Input Layer (`unknown`) → Type Guard → Business Layer (Type Guaranteed) → Output Layer (Serialization)
|
|
7
|
+
|
|
8
|
+
**Backend-Specific Type Scenarios**:
|
|
9
|
+
- **API Communication**: Always receive responses as `unknown`, validate with type guards
|
|
10
|
+
- **Form Input**: External input as `unknown`, type determined after validation
|
|
11
|
+
- **Legacy Integration**: Stepwise assertion like `window as unknown as LegacyWindow`
|
|
12
|
+
- **Test Code**: Always define types for mocks, utilize `Partial<T>` and `vi.fn<[Args], Return>()`
|
|
13
|
+
|
|
14
|
+
## Coding Conventions
|
|
15
|
+
|
|
16
|
+
**Class Usage Criteria**
|
|
17
|
+
- **Recommended: Implementation with Functions and Interfaces**
|
|
18
|
+
- Rationale: Improves testability and flexibility of function composition
|
|
19
|
+
- **Classes Allowed**:
|
|
20
|
+
- Framework requirements (NestJS Controller/Service, TypeORM Entity, etc.)
|
|
21
|
+
- Custom error class definitions
|
|
22
|
+
- When state and business logic are tightly coupled (e.g., ShoppingCart, Session, StateMachine)
|
|
23
|
+
- **Decision Criterion**: If "Does this data have behavior?" is Yes, consider using a class
|
|
24
|
+
```typescript
|
|
25
|
+
// ✅ Functions and interfaces
|
|
26
|
+
interface UserService { create(data: UserData): User }
|
|
27
|
+
const userService: UserService = { create: (data) => {...} }
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Function Design**
|
|
31
|
+
- **0-2 parameters maximum**: Use object for 3+ parameters
|
|
32
|
+
```typescript
|
|
33
|
+
// ✅ Object parameter
|
|
34
|
+
function createUser({ name, email, role }: CreateUserParams) {}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Dependency Injection**
|
|
38
|
+
- **Inject external dependencies as parameters**: Ensure testability and modularity
|
|
39
|
+
```typescript
|
|
40
|
+
// ✅ Receive dependency as parameter
|
|
41
|
+
function createService(repository: Repository) { return {...} }
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Asynchronous Processing**
|
|
45
|
+
- Promise Handling: Always use `async/await`
|
|
46
|
+
- Error Handling: Always handle with `try-catch`
|
|
47
|
+
- Type Definition: Explicitly define return value types (e.g., `Promise<Result>`)
|
|
48
|
+
|
|
49
|
+
**Format Rules**
|
|
50
|
+
- Semicolon omission (follow Biome settings)
|
|
51
|
+
- Types in `PascalCase`, variables/functions in `camelCase`
|
|
52
|
+
- Imports use absolute paths (`src/`)
|
|
53
|
+
|
|
54
|
+
**Clean Code Principles**
|
|
55
|
+
- ✅ Delete unused code immediately
|
|
56
|
+
- ✅ Delete debug `console.log()`
|
|
57
|
+
- ❌ Commented-out code (manage history with version control)
|
|
58
|
+
- ✅ Comments explain "why" (not "what")
|
|
59
|
+
|
|
60
|
+
## Error Handling
|
|
61
|
+
|
|
62
|
+
**Absolute Rule**: Error suppression prohibited. All errors must have log output and appropriate handling.
|
|
63
|
+
|
|
64
|
+
**Fail-Fast Principle**: Fail quickly on errors to prevent continued processing in invalid states
|
|
65
|
+
```typescript
|
|
66
|
+
// ❌ Prohibited: Unconditional fallback
|
|
67
|
+
catch (error) {
|
|
68
|
+
return defaultValue // Hides error
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ✅ Required: Explicit failure
|
|
72
|
+
catch (error) {
|
|
73
|
+
logger.error('Processing failed', error)
|
|
74
|
+
throw error // Handle appropriately at higher layer
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Result Type Pattern**: Express errors with types for explicit handling
|
|
79
|
+
```typescript
|
|
80
|
+
type Result<T, E> = { ok: true; value: T } | { ok: false; error: E }
|
|
81
|
+
|
|
82
|
+
// Example: Express error possibility with types
|
|
83
|
+
function parseUser(data: unknown): Result<User, ValidationError> {
|
|
84
|
+
if (!isValid(data)) return { ok: false, error: new ValidationError() }
|
|
85
|
+
return { ok: true, value: data as User }
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Custom Error Classes**
|
|
90
|
+
```typescript
|
|
91
|
+
export class AppError extends Error {
|
|
92
|
+
constructor(message: string, public readonly code: string, public readonly statusCode = 500) {
|
|
93
|
+
super(message)
|
|
94
|
+
this.name = this.constructor.name
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Purpose-specific: ValidationError(400), BusinessRuleError(400), DatabaseError(500), ExternalServiceError(502)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Layer-Specific Error Handling (Backend)**
|
|
101
|
+
- API Layer: Convert to HTTP response, log output excluding sensitive information
|
|
102
|
+
- Service Layer: Detect business rule violations, propagate AppError as-is
|
|
103
|
+
- Repository Layer: Convert technical errors to domain errors
|
|
104
|
+
|
|
105
|
+
**Structured Logging and Sensitive Information Protection**
|
|
106
|
+
Never include sensitive information (password, token, apiKey, secret, creditCard) in logs
|
|
107
|
+
|
|
108
|
+
**Asynchronous Error Handling**
|
|
109
|
+
- Global handler setup mandatory: `unhandledRejection`, `uncaughtException`
|
|
110
|
+
- Use try-catch with all async/await
|
|
111
|
+
- Always log and re-throw errors
|
|
112
|
+
|
|
113
|
+
## Performance Optimization
|
|
114
|
+
|
|
115
|
+
- Streaming Processing: Process large datasets with streams
|
|
116
|
+
- Memory Leak Prevention: Explicitly release unnecessary objects
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# 実装戦略選択フレームワーク(メタ認知的アプローチ)
|
|
2
|
+
|
|
3
|
+
## メタ認知的戦略選択プロセス
|
|
4
|
+
|
|
5
|
+
### Phase 1: 現状の包括的分析
|
|
6
|
+
|
|
7
|
+
**核心質問**: 「既存の実装はどうなっているのか?」
|
|
8
|
+
|
|
9
|
+
#### 分析フレームワーク
|
|
10
|
+
```yaml
|
|
11
|
+
アーキテクチャ分析: 責務分離、データフロー、依存関係、技術的負債
|
|
12
|
+
実装品質評価: コード品質、テストカバレッジ、パフォーマンス、セキュリティ
|
|
13
|
+
歴史的文脈理解: 現在の形の理由、過去判断の妥当性、制約の変化、要求の進化
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
#### メタ認知質問リスト
|
|
17
|
+
- この実装の真の責務は何か?
|
|
18
|
+
- どの部分がビジネス本質で、どの部分が技術的制約由来か?
|
|
19
|
+
- コードから明確でない依存関係や暗黙の前提条件は何か?
|
|
20
|
+
- 現在の設計がもたらしている利点と制約は?
|
|
21
|
+
|
|
22
|
+
### Phase 2: 戦略探索と創造
|
|
23
|
+
|
|
24
|
+
**核心質問**: 「before → after を判断する時に、参考にすべき実装パターンや戦略は何なのか?」
|
|
25
|
+
|
|
26
|
+
#### 戦略発見プロセス
|
|
27
|
+
```yaml
|
|
28
|
+
調査・探索: 技術スタック事例(WebSearch活用)、同種プロジェクト、OSS実装、文献・ブログ
|
|
29
|
+
創造的思考: 戦略組み合わせ、制約前提設計、フェーズ分け、拡張ポイント設計
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### 参考戦略パターン(創造的組み合わせを推奨)
|
|
33
|
+
|
|
34
|
+
**レガシー対応戦略**:
|
|
35
|
+
- ストラングラーパターン: 段階的置換による漸進的移行
|
|
36
|
+
- ファサードパターン: 統一インターフェースによる複雑性の隠蔽
|
|
37
|
+
- アダプターパターン: 既存システムとの橋渡し
|
|
38
|
+
|
|
39
|
+
**新規開発戦略**:
|
|
40
|
+
- 機能駆動開発: ユーザー価値重視の縦断実装
|
|
41
|
+
- 基盤駆動開発: 安定性重視の基盤優先構築
|
|
42
|
+
- リスク駆動開発: 最大リスク要素から優先的に対処
|
|
43
|
+
|
|
44
|
+
**統合・移行戦略**:
|
|
45
|
+
- プロキシパターン: 透過的な機能拡張
|
|
46
|
+
- デコレーターパターン: 既存機能の段階的強化
|
|
47
|
+
- ブリッジパターン: 抽象化による柔軟性確保
|
|
48
|
+
|
|
49
|
+
**重要**: 最適解は各プロジェクトの文脈に応じた創造的思考により発見される。
|
|
50
|
+
|
|
51
|
+
### Phase 3: リスク評価とコントロール
|
|
52
|
+
|
|
53
|
+
**核心質問**: 「既存の実装にそれを当てはめた時にどういうリスクが発生し、それをどうコントロールするのが最良なのか?」
|
|
54
|
+
|
|
55
|
+
#### リスク分析マトリクス
|
|
56
|
+
```yaml
|
|
57
|
+
技術的リスク: 既存システム影響、データ整合性、パフォーマンス劣化、統合複雑性
|
|
58
|
+
運用リスク: サービス可用性、デプロイダウンタイム、運用プロセス変更、切り戻し手順
|
|
59
|
+
プロジェクトリスク: スケジュール遅延、技術習得コスト、品質達成度、チーム連携
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### リスクコントロール戦略
|
|
63
|
+
```yaml
|
|
64
|
+
予防的対策: 段階的移行、並行動作検証、統合・回帰テスト追加、監視設定
|
|
65
|
+
発生時対応: 切り戻し手順、ログ・メトリクス準備、連絡体制定義、サービス継続手順
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Phase 4: 制約適合性検証
|
|
69
|
+
|
|
70
|
+
**核心質問**: 「このプロジェクトの制約は何か?」
|
|
71
|
+
|
|
72
|
+
#### 制約チェックリスト
|
|
73
|
+
```yaml
|
|
74
|
+
技術的制約: ライブラリ互換性、リソース容量、義務要件、数値目標
|
|
75
|
+
時間的制約: 期限・優先度、依存関係、マイルストーン、学習期間
|
|
76
|
+
リソース制約: チーム・スキル、作業時間・体制、予算、外部契約
|
|
77
|
+
ビジネス制約: 市場投入時期、顧客影響、法規制・標準
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Phase 5: 実装アプローチ決定
|
|
81
|
+
|
|
82
|
+
基本的な実装アプローチから最適解を選択(創造的組み合わせも推奨):
|
|
83
|
+
|
|
84
|
+
#### 垂直スライス(機能駆動)
|
|
85
|
+
**特徴**: 機能単位で全層を縦断実装
|
|
86
|
+
**適用条件**: 機能間の依存が少ない、ユーザーが利用可能な形で出力、アーキテクチャ全層への変更が必要
|
|
87
|
+
**確認方法**: 各機能完成時のエンドユーザー価値提供
|
|
88
|
+
|
|
89
|
+
#### 水平スライス(基盤駆動)
|
|
90
|
+
**特徴**: アーキテクチャ層別の段階的構築
|
|
91
|
+
**適用条件**: 基盤システムの安定性が重要、複数機能が共通基盤に依存、層別の段階的確認が有効
|
|
92
|
+
**確認方法**: 全基盤層完成時の統合動作確認
|
|
93
|
+
|
|
94
|
+
#### ハイブリッド(創造的組み合わせ)
|
|
95
|
+
**特徴**: プロジェクト特性に応じた柔軟な組み合わせ
|
|
96
|
+
**適用条件**: 要件が明確でない、フェーズごとにアプローチ変更が必要、プロトタイピングから本格実装への移行
|
|
97
|
+
**確認方法**: 各フェーズの目標に応じてL1/L2/L3の適切なレベルで確認
|
|
98
|
+
|
|
99
|
+
### Phase 6: 判断根拠の文書化
|
|
100
|
+
|
|
101
|
+
**Design Docでの記載**:実装戦略の選択理由と根拠を明記する。
|
|
102
|
+
|
|
103
|
+
## 確認レベル定義
|
|
104
|
+
|
|
105
|
+
各タスクの完了確認における優先順位:
|
|
106
|
+
|
|
107
|
+
- **L1: 機能動作確認** - エンドユーザー機能として動作(例:検索実行可能)
|
|
108
|
+
- **L2: テスト動作確認** - 新規テストが追加されパス(例:型定義テスト)
|
|
109
|
+
- **L3: ビルド成功確認** - コンパイルエラーなし(例:インターフェース定義)
|
|
110
|
+
|
|
111
|
+
**優先順位**: L1 > L2 > L3 の順で確認可能性を重視
|
|
112
|
+
|
|
113
|
+
## 統合ポイントの定義
|
|
114
|
+
|
|
115
|
+
選択した戦略に応じて統合ポイントを定義:
|
|
116
|
+
- **ストラングラー系**: 各機能の新旧システム切り替え時
|
|
117
|
+
- **機能駆動**: ユーザーが実際に機能を利用可能になった時
|
|
118
|
+
- **基盤駆動**: 全アーキテクチャ層が揃いE2Eテストが通った時
|
|
119
|
+
- **ハイブリッド**: 各フェーズで定義した個別目標達成時
|
|
120
|
+
|
|
121
|
+
## アンチパターン
|
|
122
|
+
|
|
123
|
+
- **パターン固執**: リスト内の戦略のみで選択し、独自の組み合わせを検討しない
|
|
124
|
+
- **分析不足**: Phase 1の分析フレームワークを飛ばして戦略選択
|
|
125
|
+
- **リスク軽視**: Phase 3のリスク分析マトリクスを省略して実装着手
|
|
126
|
+
- **制約無視**: Phase 4の制約チェックリストを確認せず戦略決定
|
|
127
|
+
- **根拠省略**: Phase 6の文書化テンプレートを使用せず戦略選択
|
|
128
|
+
|
|
129
|
+
## メタ認知的実行のための指針
|
|
130
|
+
|
|
131
|
+
1. **既知パターンの活用**: 出発点として参考し、創造的組み合わせを探索
|
|
132
|
+
2. **WebSearch積極活用**: 同種技術スタックの実装事例を調査
|
|
133
|
+
3. **5 Whys適用**: 根本理由を追求し本質を把握
|
|
134
|
+
4. **複数観点評価**: Phase 1-4の各観点から網羅的に評価
|
|
135
|
+
5. **創造的思考**: 複数戦略の順序適用やプロジェクト固有の制約を活かした設計を検討
|
|
136
|
+
6. **判断根拠明示**: 設計ドキュメントでの戦略選択根拠を明示化
|