@wipal/agent-team 1.0.0
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/rules/common/general-rules.md +141 -0
- package/.claude/rules/lessons/lessons.md +91 -0
- package/.claude/rules/role-rules/dev-fe-rules.md +146 -0
- package/.claude/rules/role-rules/sa-rules.md +226 -0
- package/.claude/skills/SKILL-INDEX.md +299 -0
- package/.claude/skills/community/security-validator/SKILL.md +392 -0
- package/.claude/skills/core/agent-creation/SKILL.md +338 -0
- package/.claude/skills/core/code-review/SKILL.md +154 -0
- package/.claude/skills/core/git-automation/SKILL.md +93 -0
- package/.claude/skills/core/retrospect-work/SKILL.md +172 -0
- package/.claude/skills/domain/architecture/adr-writing/SKILL.md +254 -0
- package/.claude/skills/domain/architecture/adr-writing/references/adr-best-practices.md +257 -0
- package/.claude/skills/domain/architecture/adr-writing/references/adr-examples.md +246 -0
- package/.claude/skills/domain/architecture/adr-writing/references/adr-template.md +160 -0
- package/.claude/skills/domain/architecture/architecture-patterns/SKILL.md +316 -0
- package/.claude/skills/domain/architecture/architecture-patterns/references/event-driven.md +393 -0
- package/.claude/skills/domain/architecture/architecture-patterns/references/microservices.md +315 -0
- package/.claude/skills/domain/architecture/architecture-patterns/references/monolith.md +321 -0
- package/.claude/skills/domain/architecture/architecture-patterns/references/serverless.md +457 -0
- package/.claude/skills/domain/architecture/performance-engineering/SKILL.md +227 -0
- package/.claude/skills/domain/architecture/performance-engineering/references/benchmarking.md +336 -0
- package/.claude/skills/domain/architecture/performance-engineering/references/caching-strategies.md +284 -0
- package/.claude/skills/domain/architecture/performance-engineering/references/optimization.md +298 -0
- package/.claude/skills/domain/architecture/security-architecture/SKILL.md +206 -0
- package/.claude/skills/domain/architecture/security-architecture/references/auth-patterns.md +209 -0
- package/.claude/skills/domain/architecture/security-architecture/references/compliance.md +246 -0
- package/.claude/skills/domain/architecture/security-architecture/references/threat-modeling.md +219 -0
- package/.claude/skills/domain/architecture/system-design/SKILL.md +227 -0
- package/.claude/skills/domain/architecture/system-design/references/distributed-systems.md +231 -0
- package/.claude/skills/domain/architecture/system-design/references/resilience.md +344 -0
- package/.claude/skills/domain/architecture/system-design/references/scalability.md +303 -0
- package/.claude/skills/domain/architecture/tech-selection/SKILL.md +192 -0
- package/.claude/skills/domain/architecture/tech-selection/references/build-vs-buy.md +258 -0
- package/.claude/skills/domain/architecture/tech-selection/references/evaluation-framework.md +203 -0
- package/.claude/skills/domain/architecture/tech-selection/references/tech-radar.md +257 -0
- package/.claude/skills/domain/backend/api-design/SKILL.md +121 -0
- package/.claude/skills/domain/backend/database-design/SKILL.md +156 -0
- package/.claude/skills/domain/backend/performance-be/SKILL.md +210 -0
- package/.claude/skills/domain/backend/security/SKILL.md +138 -0
- package/.claude/skills/domain/backend/testing-be/SKILL.md +203 -0
- package/.claude/skills/domain/devops/ci-cd/SKILL.md +188 -0
- package/.claude/skills/domain/devops/containerization/SKILL.md +177 -0
- package/.claude/skills/domain/devops/deployment/SKILL.md +198 -0
- package/.claude/skills/domain/devops/infrastructure-as-code/SKILL.md +178 -0
- package/.claude/skills/domain/devops/monitoring/SKILL.md +163 -0
- package/.claude/skills/domain/frontend/accessibility/SKILL.md +179 -0
- package/.claude/skills/domain/frontend/frontend-design/SKILL.md +138 -0
- package/.claude/skills/domain/frontend/performance-fe/SKILL.md +195 -0
- package/.claude/skills/domain/frontend/state-management/SKILL.md +190 -0
- package/.claude/skills/domain/frontend/testing-fe/SKILL.md +193 -0
- package/.claude/skills/domain/product/requirements-gathering/SKILL.md +136 -0
- package/.claude/skills/domain/product/roadmap-planning/SKILL.md +169 -0
- package/.claude/skills/domain/product/sprint-planning/SKILL.md +151 -0
- package/.claude/skills/domain/product/stakeholder-communication/SKILL.md +162 -0
- package/.claude/skills/domain/product/user-stories/SKILL.md +141 -0
- package/.claude/skills/domain/quality/bug-reporting/SKILL.md +150 -0
- package/.claude/skills/domain/quality/regression-testing/SKILL.md +178 -0
- package/.claude/skills/domain/quality/test-automation/SKILL.md +185 -0
- package/.claude/skills/domain/quality/test-planning/SKILL.md +177 -0
- package/.claude/skills/leadership/code-review-advanced/SKILL.md +167 -0
- package/.claude/skills/leadership/mentoring/SKILL.md +151 -0
- package/.claude/skills/leadership/technical-debt/SKILL.md +166 -0
- package/.claude/skills/leadership/technical-decision/SKILL.md +160 -0
- package/.claude/skills/security-reports/.gitkeep +0 -0
- package/.claude/skills/skills-registry.yaml +441 -0
- package/README.md +232 -0
- package/bin/agent-team.js +107 -0
- package/package.json +51 -0
- package/src/commands/add.js +227 -0
- package/src/commands/init.js +136 -0
- package/src/commands/list.js +66 -0
- package/src/commands/remove.js +71 -0
- package/src/commands/switch.js +53 -0
- package/src/index.js +11 -0
- package/src/interactive/prompts.js +153 -0
- package/src/server/api/agents.js +150 -0
- package/src/server/api/roles.js +97 -0
- package/src/server/api/skills.js +79 -0
- package/src/server/index.js +78 -0
- package/src/ui/agents.html +174 -0
- package/src/ui/css/styles.css +470 -0
- package/src/ui/index.html +107 -0
- package/src/ui/roles.html +371 -0
- package/src/ui/skills.html +332 -0
- package/src/utils/file-utils.js +193 -0
- package/src/utils/skill-resolver.js +594 -0
- package/src/utils/skill-scanner.js +154 -0
- package/templates/CLAUDE.md.tmpl +42 -0
- package/templates/knowledge.md.tmpl +31 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# General Rules - Áp dụng cho TẤT CẢ agents
|
|
2
|
+
|
|
3
|
+
> **Nguồn tham khảo:** Boris Cherny (Anthropic engineer), everything-claude-code
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Workflow Orchestration
|
|
8
|
+
|
|
9
|
+
### 1. Plan Mode Default
|
|
10
|
+
- Enter plan mode for ANY non-trivial task (3+ steps or architectural decisions)
|
|
11
|
+
- If something goes sideways, STOP and re-plan immediately
|
|
12
|
+
- Use plan mode for verification steps, not just building
|
|
13
|
+
- Write detailed specs upfront to reduce ambiguity
|
|
14
|
+
|
|
15
|
+
### 2. Subagent Strategy
|
|
16
|
+
- Use subagents liberally to keep main context window clean
|
|
17
|
+
- Offload research, exploration, and parallel analysis to subagents
|
|
18
|
+
- For complex problems, throw more compute via subagents
|
|
19
|
+
- One task per subagent for focused execution
|
|
20
|
+
|
|
21
|
+
### 3. Self-Improvement Loop
|
|
22
|
+
- After ANY correction from user: update `lessons.md` with the pattern
|
|
23
|
+
- Write rules for yourself that prevent the same mistake
|
|
24
|
+
- Ruthlessly iterate on these lessons until mistake rate drops
|
|
25
|
+
- Review lessons at session start for relevant project
|
|
26
|
+
|
|
27
|
+
### 4. Verification Before Done
|
|
28
|
+
- Never mark task complete without proving it works
|
|
29
|
+
- Diff behavior between main and your changes when relevant
|
|
30
|
+
- Ask yourself: "Would a staff engineer approve this?"
|
|
31
|
+
- Run tests, check logs, demonstrate correctness
|
|
32
|
+
|
|
33
|
+
### 5. Autonomous Bug Fixing
|
|
34
|
+
- When given a bug report: just fix it. Don't ask for hand-holding
|
|
35
|
+
- Point at logs, errors, failing tests – then resolve them
|
|
36
|
+
- Zero context switching required from user
|
|
37
|
+
- Go fix failing CI tests without being told how
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Task Management
|
|
42
|
+
|
|
43
|
+
### Standard Process
|
|
44
|
+
1. **Plan First** - Write plan to `tasks/todo.md` with checkable items
|
|
45
|
+
2. **Verify Plan** - Check in before starting implementation
|
|
46
|
+
3. **Track Progress** - Mark items complete as you go
|
|
47
|
+
4. **Explain Changes** - High-level summary at each step
|
|
48
|
+
5. **Document Results** - Add review section to `tasks/todo.md`
|
|
49
|
+
6. **Capture Lessons** - Update `lessons.md` after corrections
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Core Principles
|
|
54
|
+
|
|
55
|
+
### Simplicity First
|
|
56
|
+
- Make every change as simple as possible
|
|
57
|
+
- Avoid over-engineering
|
|
58
|
+
- Choose the simplest solution that works
|
|
59
|
+
|
|
60
|
+
### No Laziness
|
|
61
|
+
- Find root causes. No temporary fixes.
|
|
62
|
+
- Senior engineer standards.
|
|
63
|
+
- Do it right or don't do it.
|
|
64
|
+
|
|
65
|
+
### Minimal Impact
|
|
66
|
+
- Changes should only touch what's necessary
|
|
67
|
+
- Don't refactor unrelated code
|
|
68
|
+
- Keep PRs focused
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Verification Protocol
|
|
73
|
+
|
|
74
|
+
### RED FLAGS - STOP
|
|
75
|
+
- Using "should"/"probably"/"seems to"
|
|
76
|
+
- Expressing satisfaction before verification
|
|
77
|
+
- Committing without verification
|
|
78
|
+
- Trusting agent reports without evidence
|
|
79
|
+
|
|
80
|
+
### REQUIRED Before Completion
|
|
81
|
+
1. IDENTIFY command to verify
|
|
82
|
+
2. RUN full command (not partial)
|
|
83
|
+
3. READ actual output
|
|
84
|
+
4. VERIFY output confirms claim
|
|
85
|
+
5. THEN make claim
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Context Management
|
|
90
|
+
|
|
91
|
+
### Strategic Compaction
|
|
92
|
+
- Compact at logical breakpoints, NOT mid-implementation
|
|
93
|
+
- After research/exploration, before implementation
|
|
94
|
+
- After completing a milestone, before starting next
|
|
95
|
+
- After debugging, before continuing feature work
|
|
96
|
+
|
|
97
|
+
### MCP Limits
|
|
98
|
+
- Keep under 10 MCPs enabled per project
|
|
99
|
+
- Keep under 80 tools active
|
|
100
|
+
- Use `disabledMcpServers` for unused servers
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Code Quality
|
|
105
|
+
|
|
106
|
+
### Before Writing Code
|
|
107
|
+
1. Check Context7 for latest documentation
|
|
108
|
+
2. Review existing patterns in codebase
|
|
109
|
+
3. Understand the requirement fully
|
|
110
|
+
4. Plan the approach
|
|
111
|
+
|
|
112
|
+
### While Writing Code
|
|
113
|
+
1. Follow existing conventions
|
|
114
|
+
2. Write self-documenting code
|
|
115
|
+
3. Handle errors explicitly
|
|
116
|
+
4. Add appropriate logging
|
|
117
|
+
|
|
118
|
+
### After Writing Code
|
|
119
|
+
1. Self-review the changes
|
|
120
|
+
2. Run relevant tests
|
|
121
|
+
3. Check for edge cases
|
|
122
|
+
4. Update documentation if needed
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Communication
|
|
127
|
+
|
|
128
|
+
### Status Updates
|
|
129
|
+
- Be clear about what's done
|
|
130
|
+
- Be honest about blockers
|
|
131
|
+
- Estimate only when confident
|
|
132
|
+
|
|
133
|
+
### Asking Questions
|
|
134
|
+
- Ask when truly unclear
|
|
135
|
+
- Provide context with questions
|
|
136
|
+
- Suggest options when possible
|
|
137
|
+
|
|
138
|
+
### Reporting Issues
|
|
139
|
+
- Describe the problem clearly
|
|
140
|
+
- Include relevant logs/errors
|
|
141
|
+
- Suggest potential solutions
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Lessons Learned
|
|
2
|
+
|
|
3
|
+
> **Purpose:** Track patterns and corrections to continuously improve
|
|
4
|
+
> **Update:** After receiving user corrections or discovering new patterns
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Format
|
|
9
|
+
|
|
10
|
+
### YYYY-MM-DD: [Lesson Title]
|
|
11
|
+
**What happened:** [Description of the situation]
|
|
12
|
+
**Context:** [When/where this occurred]
|
|
13
|
+
**Lesson:** [What we learned]
|
|
14
|
+
**Rule added:** [Rule to prevent same mistake]
|
|
15
|
+
**Code example:** (if applicable)
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// ✅ Good
|
|
19
|
+
good_code_here();
|
|
20
|
+
|
|
21
|
+
// ❌ Bad
|
|
22
|
+
bad_code_here();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Pattern Promotion
|
|
28
|
+
|
|
29
|
+
| Stage | Condition | Location |
|
|
30
|
+
|-------|-----------|----------|
|
|
31
|
+
| **Lesson** | New finding | lessons.md |
|
|
32
|
+
| **Pattern** | Used 3+ times successfully | knowledge.md |
|
|
33
|
+
| **Skill** | High confidence, reusable | SKILL.md |
|
|
34
|
+
| **Rule** | Proven reliable | rules/ |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Recent Lessons
|
|
39
|
+
|
|
40
|
+
### 2025-02-25: Always verify before claiming done
|
|
41
|
+
**What happened:** Claimed task was complete without running verification
|
|
42
|
+
**Context:** Implementing a feature
|
|
43
|
+
**Lesson:** Never mark task complete without proving it works
|
|
44
|
+
**Rule added:** "Run verification command before claiming success"
|
|
45
|
+
|
|
46
|
+
### 2025-02-25: Check Context7 before using APIs
|
|
47
|
+
**What happened:** Used outdated API that had changed
|
|
48
|
+
**Context:** Implementing with external library
|
|
49
|
+
**Lesson:** Always check Context7 for latest documentation
|
|
50
|
+
**Rule added:** "Use Context7 before any API implementation"
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Common Pitfalls to Avoid
|
|
55
|
+
|
|
56
|
+
### Frontend
|
|
57
|
+
- ❌ Using `useEffect` for derived state
|
|
58
|
+
- ❌ Storing props in state
|
|
59
|
+
- ❌ Missing loading/error states
|
|
60
|
+
- ❌ Prop drilling instead of context
|
|
61
|
+
|
|
62
|
+
### Backend
|
|
63
|
+
- ❌ N+1 queries
|
|
64
|
+
- ❌ Missing error handling
|
|
65
|
+
- ❌ Hardcoded configuration
|
|
66
|
+
- ❌ SQL injection (use parameterized queries)
|
|
67
|
+
|
|
68
|
+
### General
|
|
69
|
+
- ❌ Committing without verification
|
|
70
|
+
- ❌ Over-engineering simple solutions
|
|
71
|
+
- ❌ Not handling edge cases
|
|
72
|
+
- ❌ Ignoring user corrections
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Corrections Received
|
|
77
|
+
|
|
78
|
+
### [Date]: [Correction Description]
|
|
79
|
+
**From:** User/Reviewer
|
|
80
|
+
**What was wrong:** [Description]
|
|
81
|
+
**What I did:** [How I fixed it]
|
|
82
|
+
**Pattern identified:** [The underlying pattern]
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Statistics
|
|
87
|
+
|
|
88
|
+
- Total lessons: 2
|
|
89
|
+
- This week: 2
|
|
90
|
+
- This month: 2
|
|
91
|
+
- Most common category: Verification
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# dev-fe Rules - Rules riêng cho Frontend Developers
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## FE-Specific Rules
|
|
6
|
+
|
|
7
|
+
### 1. Context7 Mandatory
|
|
8
|
+
- ALWAYS use Context7 to lookup React/Vite docs BEFORE coding
|
|
9
|
+
- Never assume API behavior without verification
|
|
10
|
+
- Check for breaking changes in new versions
|
|
11
|
+
|
|
12
|
+
### 2. Component Structure
|
|
13
|
+
- Tách UI thành `src/components/` và `src/features/`
|
|
14
|
+
- Always use function components + hooks
|
|
15
|
+
- Write TypeScript rõ ràng, avoid `any`
|
|
16
|
+
- One component per file
|
|
17
|
+
|
|
18
|
+
### 3. State Management
|
|
19
|
+
- Use local state for UI-only concerns
|
|
20
|
+
- Use Zustand for client state
|
|
21
|
+
- Use TanStack Query for server state
|
|
22
|
+
- URL state for filters/pagination
|
|
23
|
+
|
|
24
|
+
### 4. Testing Requirements
|
|
25
|
+
- Every component should have corresponding test file
|
|
26
|
+
- Use Vitest + Testing Library
|
|
27
|
+
- Test user interactions, not implementation details
|
|
28
|
+
- Mock external dependencies
|
|
29
|
+
|
|
30
|
+
### 5. Performance Checks
|
|
31
|
+
- Check for unnecessary re-renders
|
|
32
|
+
- Use React DevTools Profiler
|
|
33
|
+
- Lazy load components when appropriate
|
|
34
|
+
- Virtualize long lists
|
|
35
|
+
|
|
36
|
+
### 6. Accessibility
|
|
37
|
+
- All interactive elements must be keyboard accessible
|
|
38
|
+
- Use semantic HTML
|
|
39
|
+
- Add ARIA labels where needed
|
|
40
|
+
- Test with screen reader
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Component Checklist
|
|
45
|
+
|
|
46
|
+
Before submitting component:
|
|
47
|
+
- [ ] TypeScript types defined
|
|
48
|
+
- [ ] Props documented
|
|
49
|
+
- [ ] Loading state handled
|
|
50
|
+
- [ ] Error state handled
|
|
51
|
+
- [ ] Responsive design
|
|
52
|
+
- [ ] Keyboard accessible
|
|
53
|
+
- [ ] Tests written
|
|
54
|
+
- [ ] No console errors
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Anti-Patterns to Avoid
|
|
59
|
+
|
|
60
|
+
### State Management
|
|
61
|
+
- ❌ Using `useEffect` for derived state
|
|
62
|
+
- ❌ Storing props in state
|
|
63
|
+
- ❌ Prop drilling (use context/store)
|
|
64
|
+
- ❌ Not memoizing expensive computations
|
|
65
|
+
|
|
66
|
+
### Performance
|
|
67
|
+
- ❌ Inline functions in render (use `useCallback`)
|
|
68
|
+
- ❌ Inline objects in render
|
|
69
|
+
- ❌ Importing entire libraries (use tree-shaking)
|
|
70
|
+
- ❌ Not code-splitting large bundles
|
|
71
|
+
|
|
72
|
+
### Code Quality
|
|
73
|
+
- ❌ Components > 300 lines
|
|
74
|
+
- ❌ Multiple responsibilities in one component
|
|
75
|
+
- ❌ Not handling loading/error states
|
|
76
|
+
- ❌ Magic numbers/strings
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## File Naming
|
|
81
|
+
|
|
82
|
+
| Type | Convention | Example |
|
|
83
|
+
|------|------------|---------|
|
|
84
|
+
| Component | PascalCase | `Button.tsx` |
|
|
85
|
+
| Hook | camelCase with use prefix | `useAuth.ts` |
|
|
86
|
+
| Utility | camelCase | `formatDate.ts` |
|
|
87
|
+
| Type | PascalCase | `UserTypes.ts` |
|
|
88
|
+
| Test | Same as file + .test | `Button.test.tsx` |
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Import Order
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
// 1. React
|
|
96
|
+
import { useState, useEffect } from 'react';
|
|
97
|
+
|
|
98
|
+
// 2. External packages
|
|
99
|
+
import { z } from 'zod';
|
|
100
|
+
import { useQuery } from '@tanstack/react-query';
|
|
101
|
+
|
|
102
|
+
// 3. Internal absolute imports
|
|
103
|
+
import { Button } from '@/components/Button';
|
|
104
|
+
import { useAuth } from '@/hooks/useAuth';
|
|
105
|
+
|
|
106
|
+
// 4. Relative imports
|
|
107
|
+
import { LocalComponent } from './LocalComponent';
|
|
108
|
+
|
|
109
|
+
// 5. Types
|
|
110
|
+
import type { User } from './types';
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Common Patterns
|
|
116
|
+
|
|
117
|
+
### Loading State
|
|
118
|
+
```typescript
|
|
119
|
+
// ✅ Good
|
|
120
|
+
const { data, isLoading, error } = useQuery(...);
|
|
121
|
+
|
|
122
|
+
if (isLoading) return <Loading />;
|
|
123
|
+
if (error) return <Error message={error.message} />;
|
|
124
|
+
return <Content data={data} />;
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Form Handling
|
|
128
|
+
```typescript
|
|
129
|
+
// ✅ Good - React Hook Form + Zod
|
|
130
|
+
const schema = z.object({
|
|
131
|
+
email: z.string().email(),
|
|
132
|
+
password: z.string().min(8),
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const { register, handleSubmit, formState: { errors } } = useForm({
|
|
136
|
+
resolver: zodResolver(schema),
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Error Boundary
|
|
141
|
+
```typescript
|
|
142
|
+
// ✅ Good - Wrap risky components
|
|
143
|
+
<ErrorBoundary fallback={<ErrorFallback />}>
|
|
144
|
+
<RiskyComponent />
|
|
145
|
+
</ErrorBoundary>
|
|
146
|
+
```
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# SA Rules - Rules riêng cho Solution Architects
|
|
2
|
+
|
|
3
|
+
> **Nguồn tham khảo:** Software Architecture patterns, AWS Architecture Well-Architected Framework, Google Cloud Architecture Framework, Microsoft Azure Architecture Center
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Architecture Design Rules
|
|
8
|
+
|
|
9
|
+
### 1. Document Before Implement
|
|
10
|
+
- ALWAYS write ADR before major architecture decisions
|
|
11
|
+
- Get stakeholder review before implementation begins
|
|
12
|
+
- Revisit and update decisions when context changes
|
|
13
|
+
- Keep ADRs in version control alongside code
|
|
14
|
+
|
|
15
|
+
### 2. Think in Trade-offs
|
|
16
|
+
- No solution is perfect - every choice has pros and cons
|
|
17
|
+
- Always document both positive and negative consequences
|
|
18
|
+
- Consider build vs buy for every component
|
|
19
|
+
- Evaluate at least 2-3 options before deciding
|
|
20
|
+
|
|
21
|
+
### 3. Start Simple, Evolve
|
|
22
|
+
- YAGNI (You Aren't Gonna Need It) - don't over-engineer
|
|
23
|
+
- Design for current scale + 10x, not 1000x
|
|
24
|
+
- Avoid premature optimization
|
|
25
|
+
- Make reversible decisions when possible
|
|
26
|
+
- Build for change, not for perfection
|
|
27
|
+
|
|
28
|
+
### 4. Design for Failure
|
|
29
|
+
- Assume every component will fail at some point
|
|
30
|
+
- Implement circuit breakers, retries with exponential backoff
|
|
31
|
+
- Have rollback plans for every change
|
|
32
|
+
- Design graceful degradation, not just fail-stop
|
|
33
|
+
- Test failure scenarios regularly
|
|
34
|
+
|
|
35
|
+
### 5. Security by Design
|
|
36
|
+
- Threat model every design decision
|
|
37
|
+
- Apply least privilege principle everywhere
|
|
38
|
+
- Defense in depth - multiple security layers
|
|
39
|
+
- Never trust user input
|
|
40
|
+
- Encrypt data at rest and in transit
|
|
41
|
+
- Plan for security incidents
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Technology Selection Rules
|
|
46
|
+
|
|
47
|
+
### 1. Use Decision Framework
|
|
48
|
+
- Create evaluation matrix with weighted criteria
|
|
49
|
+
- Score options objectively with evidence
|
|
50
|
+
- Get team input and buy-in
|
|
51
|
+
- Document the decision process
|
|
52
|
+
|
|
53
|
+
### 2. Consider Total Cost of Ownership
|
|
54
|
+
- Not just licensing/subscription costs
|
|
55
|
+
- Training and learning curve
|
|
56
|
+
- Hiring and retention (can you find talent?)
|
|
57
|
+
- Maintenance and operational burden
|
|
58
|
+
- Migration and integration costs
|
|
59
|
+
- Opportunity cost
|
|
60
|
+
|
|
61
|
+
### 3. Prefer Proven Technology
|
|
62
|
+
- Avoid 1.0 syndrome for critical systems
|
|
63
|
+
- Community size and activity matters
|
|
64
|
+
- Enterprise support availability
|
|
65
|
+
- Documentation quality
|
|
66
|
+
- Real-world production usage
|
|
67
|
+
|
|
68
|
+
### 4. POC When Uncertain
|
|
69
|
+
- Build small prototype to test assumptions
|
|
70
|
+
- Focus on risky or unknown aspects
|
|
71
|
+
- Time-box exploration (don't gold-plate)
|
|
72
|
+
- Document findings and share with team
|
|
73
|
+
- Kill failed experiments quickly
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Documentation Rules
|
|
78
|
+
|
|
79
|
+
### 1. ADR for All Major Decisions
|
|
80
|
+
- Use consistent template across all ADRs
|
|
81
|
+
- Include context, decision, consequences
|
|
82
|
+
- Document alternatives considered
|
|
83
|
+
- Update status over time (Proposed → Accepted → Deprecated)
|
|
84
|
+
- Link related ADRs together
|
|
85
|
+
|
|
86
|
+
### 2. Diagram Standards
|
|
87
|
+
- Use C4 model for system context
|
|
88
|
+
- Mermaid for version-controlled diagrams
|
|
89
|
+
- Keep diagrams updated with code changes
|
|
90
|
+
- Include both high-level and detailed views
|
|
91
|
+
- Annotate with decision references
|
|
92
|
+
|
|
93
|
+
### 3. Decision Reversibility
|
|
94
|
+
- Mark decisions as reversible or irreversible
|
|
95
|
+
- Plan rollback paths for reversible decisions
|
|
96
|
+
- Document dependencies between decisions
|
|
97
|
+
- Review irreversible decisions more carefully
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Communication Rules
|
|
102
|
+
|
|
103
|
+
### 1. Stakeholder Alignment
|
|
104
|
+
- Present options, not just decisions
|
|
105
|
+
- Explain trade-offs in business terms
|
|
106
|
+
- Get sign-off before major implementation
|
|
107
|
+
- Keep stakeholders informed of changes
|
|
108
|
+
|
|
109
|
+
### 2. Team Collaboration
|
|
110
|
+
- Involve Tech Lead in implementation planning
|
|
111
|
+
- Consult Dev-FE/BE on technical feasibility
|
|
112
|
+
- Work with DevOps on deployment strategy
|
|
113
|
+
- Include Security early in design process
|
|
114
|
+
|
|
115
|
+
### 3. Knowledge Sharing
|
|
116
|
+
- Present architecture decisions to team
|
|
117
|
+
- Create onboarding documentation
|
|
118
|
+
- Conduct architecture review sessions
|
|
119
|
+
- Mentor developers on architectural thinking
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Anti-Patterns to Avoid
|
|
124
|
+
|
|
125
|
+
### Architecture Anti-Patterns
|
|
126
|
+
|
|
127
|
+
| Anti-Pattern | Description | Better Approach |
|
|
128
|
+
|--------------|-------------|-----------------|
|
|
129
|
+
| **Big Design Up Front (BDUF)** | Too much planning upfront | Iterative design, evolve as you learn |
|
|
130
|
+
| **Resume-driven development** | Choosing tech for CV | Evaluate based on project needs |
|
|
131
|
+
| **Golden hammer** | One solution for everything | Match solution to problem |
|
|
132
|
+
| **Not invented here** | Always build vs buy | Evaluate build vs buy honestly |
|
|
133
|
+
| **Copy-paste architecture** | Copying without understanding | Understand before adopting |
|
|
134
|
+
| **Over-engineering** | Premature optimization | Start simple, measure, optimize |
|
|
135
|
+
| **Under-engineering** | Ignoring NFRs | Consider all quality attributes |
|
|
136
|
+
| **Architecture by implication** | Assumptions not documented | Document all decisions explicitly |
|
|
137
|
+
|
|
138
|
+
### Process Anti-Patterns
|
|
139
|
+
|
|
140
|
+
| Anti-Pattern | Description | Better Approach |
|
|
141
|
+
|--------------|-------------|-----------------|
|
|
142
|
+
| **Designing in isolation** | No stakeholder input | Collaborate early and often |
|
|
143
|
+
| **Ignoring operations** | Deployability as afterthought | Design for operations |
|
|
144
|
+
| **Security as afterthought** | Add security later | Security by design |
|
|
145
|
+
| **Skipping POC** | Untested assumptions | Validate risky choices |
|
|
146
|
+
| **No documentation** | Decisions without context | Write ADRs |
|
|
147
|
+
| **Analysis paralysis** | Endless evaluation | Time-box decisions |
|
|
148
|
+
| **HiPPO effect** | Highest Paid Person's Opinion | Data-driven decisions |
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Quality Attributes Checklist
|
|
153
|
+
|
|
154
|
+
When designing systems, always consider:
|
|
155
|
+
|
|
156
|
+
### Performance
|
|
157
|
+
- [ ] Response time requirements defined
|
|
158
|
+
- [ ] Throughput requirements defined
|
|
159
|
+
- [ ] Caching strategy defined
|
|
160
|
+
- [ ] Database query optimization plan
|
|
161
|
+
|
|
162
|
+
### Scalability
|
|
163
|
+
- [ ] Horizontal scaling capability
|
|
164
|
+
- [ ] Vertical scaling limits understood
|
|
165
|
+
- [ ] Auto-scaling strategy
|
|
166
|
+
- [ ] Data partitioning strategy
|
|
167
|
+
|
|
168
|
+
### Availability
|
|
169
|
+
- [ ] Uptime requirements defined (99.9%?)
|
|
170
|
+
- [ ] Failover strategy
|
|
171
|
+
- [ ] Disaster recovery plan
|
|
172
|
+
- [ ] Backup and restore procedures
|
|
173
|
+
|
|
174
|
+
### Security
|
|
175
|
+
- [ ] Authentication mechanism
|
|
176
|
+
- [ ] Authorization model
|
|
177
|
+
- [ ] Data encryption strategy
|
|
178
|
+
- [ ] Threat model completed
|
|
179
|
+
|
|
180
|
+
### Maintainability
|
|
181
|
+
- [ ] Code organization clear
|
|
182
|
+
- [ ] Documentation adequate
|
|
183
|
+
- [ ] Monitoring and alerting planned
|
|
184
|
+
- [ ] Debugging capability
|
|
185
|
+
|
|
186
|
+
### Cost
|
|
187
|
+
- [ ] Infrastructure cost estimated
|
|
188
|
+
- [ ] Cost optimization strategy
|
|
189
|
+
- [ ] Cost monitoring planned
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Review Checklist
|
|
194
|
+
|
|
195
|
+
Before finalizing any architecture:
|
|
196
|
+
|
|
197
|
+
### Functional
|
|
198
|
+
- [ ] All requirements addressed
|
|
199
|
+
- [ ] Edge cases considered
|
|
200
|
+
- [ ] Integration points identified
|
|
201
|
+
|
|
202
|
+
### Non-Functional
|
|
203
|
+
- [ ] Performance requirements met
|
|
204
|
+
- [ ] Scalability requirements met
|
|
205
|
+
- [ ] Availability requirements met
|
|
206
|
+
- [ ] Security requirements met
|
|
207
|
+
|
|
208
|
+
### Operational
|
|
209
|
+
- [ ] Deployment strategy defined
|
|
210
|
+
- [ ] Monitoring strategy defined
|
|
211
|
+
- [ ] Incident response plan exists
|
|
212
|
+
- [ ] Rollback plan exists
|
|
213
|
+
|
|
214
|
+
### Documentation
|
|
215
|
+
- [ ] ADRs written and reviewed
|
|
216
|
+
- [ ] Diagrams created and updated
|
|
217
|
+
- [ ] Runbooks created
|
|
218
|
+
- [ ] Team trained
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Related Documentation
|
|
223
|
+
|
|
224
|
+
- [General Rules](../common/general-rules.md)
|
|
225
|
+
- [Tech Lead Rules](./tech-lead-rules.md)
|
|
226
|
+
- [DevOps Rules](./devops-rules.md)
|