@riligar/agents-kit 1.2.0 → 1.3.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/.agent/skills/riligar-design-system/assets/theme.js +23 -18
- package/.agent/skills/riligar-dev-api/SKILL.md +81 -0
- package/.agent/skills/riligar-dev-api/api-style.md +42 -0
- package/.agent/skills/riligar-dev-api/auth.md +24 -0
- package/.agent/skills/riligar-dev-api/documentation.md +26 -0
- package/.agent/skills/riligar-dev-api/graphql.md +41 -0
- package/.agent/skills/riligar-dev-api/rate-limiting.md +31 -0
- package/.agent/skills/riligar-dev-api/response.md +37 -0
- package/.agent/skills/riligar-dev-api/rest.md +40 -0
- package/.agent/skills/riligar-dev-api/scripts/api_validator.py +211 -0
- package/.agent/skills/riligar-dev-api/security-testing.md +122 -0
- package/.agent/skills/riligar-dev-api/trpc.md +41 -0
- package/.agent/skills/riligar-dev-api/versioning.md +22 -0
- package/.agent/skills/riligar-dev-architecture/SKILL.md +55 -0
- package/.agent/skills/riligar-dev-architecture/context-discovery.md +43 -0
- package/.agent/skills/riligar-dev-architecture/examples.md +94 -0
- package/.agent/skills/riligar-dev-architecture/pattern-selection.md +68 -0
- package/.agent/skills/riligar-dev-architecture/patterns-reference.md +50 -0
- package/.agent/skills/riligar-dev-architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/riligar-dev-autopilot/SKILL.md +24 -24
- package/.agent/skills/riligar-dev-clean-code/SKILL.md +201 -0
- package/.agent/skills/riligar-dev-code-review/SKILL.md +109 -0
- package/.agent/skills/riligar-dev-database/SKILL.md +52 -0
- package/.agent/skills/riligar-dev-database/database-selection.md +43 -0
- package/.agent/skills/riligar-dev-database/indexing.md +39 -0
- package/.agent/skills/riligar-dev-database/migrations.md +48 -0
- package/.agent/skills/riligar-dev-database/optimization.md +36 -0
- package/.agent/skills/riligar-dev-database/orm-selection.md +30 -0
- package/.agent/skills/riligar-dev-database/schema-design.md +56 -0
- package/.agent/skills/riligar-dev-database/scripts/schema_validator.py +172 -0
- package/.agent/skills/riligar-dev-react/SKILL.md +198 -0
- package/.agent/skills/riligar-plan-writing/SKILL.md +152 -0
- package/package.json +1 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# API Security Testing
|
|
2
|
+
|
|
3
|
+
> Principles for testing API security. OWASP API Top 10, authentication, authorization testing.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## OWASP API Security Top 10
|
|
8
|
+
|
|
9
|
+
| Vulnerability | Test Focus |
|
|
10
|
+
|---------------|------------|
|
|
11
|
+
| **API1: BOLA** | Access other users' resources |
|
|
12
|
+
| **API2: Broken Auth** | JWT, session, credentials |
|
|
13
|
+
| **API3: Property Auth** | Mass assignment, data exposure |
|
|
14
|
+
| **API4: Resource Consumption** | Rate limiting, DoS |
|
|
15
|
+
| **API5: Function Auth** | Admin endpoints, role bypass |
|
|
16
|
+
| **API6: Business Flow** | Logic abuse, automation |
|
|
17
|
+
| **API7: SSRF** | Internal network access |
|
|
18
|
+
| **API8: Misconfiguration** | Debug endpoints, CORS |
|
|
19
|
+
| **API9: Inventory** | Shadow APIs, old versions |
|
|
20
|
+
| **API10: Unsafe Consumption** | Third-party API trust |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Authentication Testing
|
|
25
|
+
|
|
26
|
+
### JWT Testing
|
|
27
|
+
|
|
28
|
+
| Check | What to Test |
|
|
29
|
+
|-------|--------------|
|
|
30
|
+
| Algorithm | None, algorithm confusion |
|
|
31
|
+
| Secret | Weak secrets, brute force |
|
|
32
|
+
| Claims | Expiration, issuer, audience |
|
|
33
|
+
| Signature | Manipulation, key injection |
|
|
34
|
+
|
|
35
|
+
### Session Testing
|
|
36
|
+
|
|
37
|
+
| Check | What to Test |
|
|
38
|
+
|-------|--------------|
|
|
39
|
+
| Generation | Predictability |
|
|
40
|
+
| Storage | Client-side security |
|
|
41
|
+
| Expiration | Timeout enforcement |
|
|
42
|
+
| Invalidation | Logout effectiveness |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Authorization Testing
|
|
47
|
+
|
|
48
|
+
| Test Type | Approach |
|
|
49
|
+
|-----------|----------|
|
|
50
|
+
| **Horizontal** | Access peer users' data |
|
|
51
|
+
| **Vertical** | Access higher privilege functions |
|
|
52
|
+
| **Context** | Access outside allowed scope |
|
|
53
|
+
|
|
54
|
+
### BOLA/IDOR Testing
|
|
55
|
+
|
|
56
|
+
1. Identify resource IDs in requests
|
|
57
|
+
2. Capture request with user A's session
|
|
58
|
+
3. Replay with user B's session
|
|
59
|
+
4. Check for unauthorized access
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Input Validation Testing
|
|
64
|
+
|
|
65
|
+
| Injection Type | Test Focus |
|
|
66
|
+
|----------------|------------|
|
|
67
|
+
| SQL | Query manipulation |
|
|
68
|
+
| NoSQL | Document queries |
|
|
69
|
+
| Command | System commands |
|
|
70
|
+
| LDAP | Directory queries |
|
|
71
|
+
|
|
72
|
+
**Approach:** Test all parameters, try type coercion, test boundaries, check error messages.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Rate Limiting Testing
|
|
77
|
+
|
|
78
|
+
| Aspect | Check |
|
|
79
|
+
|--------|-------|
|
|
80
|
+
| Existence | Is there any limit? |
|
|
81
|
+
| Bypass | Headers, IP rotation |
|
|
82
|
+
| Scope | Per-user, per-IP, global |
|
|
83
|
+
|
|
84
|
+
**Bypass techniques:** X-Forwarded-For, different HTTP methods, case variations, API versioning.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## GraphQL Security
|
|
89
|
+
|
|
90
|
+
| Test | Focus |
|
|
91
|
+
|------|-------|
|
|
92
|
+
| Introspection | Schema disclosure |
|
|
93
|
+
| Batching | Query DoS |
|
|
94
|
+
| Nesting | Depth-based DoS |
|
|
95
|
+
| Authorization | Field-level access |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Security Testing Checklist
|
|
100
|
+
|
|
101
|
+
**Authentication:**
|
|
102
|
+
- [ ] Test for bypass
|
|
103
|
+
- [ ] Check credential strength
|
|
104
|
+
- [ ] Verify token security
|
|
105
|
+
|
|
106
|
+
**Authorization:**
|
|
107
|
+
- [ ] Test BOLA/IDOR
|
|
108
|
+
- [ ] Check privilege escalation
|
|
109
|
+
- [ ] Verify function access
|
|
110
|
+
|
|
111
|
+
**Input:**
|
|
112
|
+
- [ ] Test all parameters
|
|
113
|
+
- [ ] Check for injection
|
|
114
|
+
|
|
115
|
+
**Config:**
|
|
116
|
+
- [ ] Check CORS
|
|
117
|
+
- [ ] Verify headers
|
|
118
|
+
- [ ] Test error handling
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
> **Remember:** APIs are the backbone of modern apps. Test them like attackers will.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# tRPC Principles
|
|
2
|
+
|
|
3
|
+
> End-to-end type safety for TypeScript monorepos.
|
|
4
|
+
|
|
5
|
+
## When to Use
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
✅ Perfect fit:
|
|
9
|
+
├── TypeScript on both ends
|
|
10
|
+
├── Monorepo structure
|
|
11
|
+
├── Internal tools
|
|
12
|
+
├── Rapid development
|
|
13
|
+
└── Type safety critical
|
|
14
|
+
|
|
15
|
+
❌ Poor fit:
|
|
16
|
+
├── Non-TypeScript clients
|
|
17
|
+
├── Public API
|
|
18
|
+
├── Need REST conventions
|
|
19
|
+
└── Multiple language backends
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Key Benefits
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Why tRPC:
|
|
26
|
+
├── Zero schema maintenance
|
|
27
|
+
├── End-to-end type inference
|
|
28
|
+
├── IDE autocomplete across stack
|
|
29
|
+
├── Instant API changes reflected
|
|
30
|
+
└── No code generation step
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Integration Patterns
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
Common setups:
|
|
37
|
+
├── Next.js + tRPC (most common)
|
|
38
|
+
├── Monorepo with shared types
|
|
39
|
+
├── Remix + tRPC
|
|
40
|
+
└── Any TS frontend + backend
|
|
41
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Versioning Strategies
|
|
2
|
+
|
|
3
|
+
> Plan for API evolution from day one.
|
|
4
|
+
|
|
5
|
+
## Decision Factors
|
|
6
|
+
|
|
7
|
+
| Strategy | Implementation | Trade-offs |
|
|
8
|
+
|----------|---------------|------------|
|
|
9
|
+
| **URI** | /v1/users | Clear, easy caching |
|
|
10
|
+
| **Header** | Accept-Version: 1 | Cleaner URLs, harder discovery |
|
|
11
|
+
| **Query** | ?version=1 | Easy to add, messy |
|
|
12
|
+
| **None** | Evolve carefully | Best for internal, risky for public |
|
|
13
|
+
|
|
14
|
+
## Versioning Philosophy
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
Consider:
|
|
18
|
+
├── Public API? → Version in URI
|
|
19
|
+
├── Internal only? → May not need versioning
|
|
20
|
+
├── GraphQL? → Typically no versions (evolve schema)
|
|
21
|
+
├── tRPC? → Types enforce compatibility
|
|
22
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architecture
|
|
3
|
+
description: Architectural decision-making framework. Requirements analysis, trade-off evaluation, ADR documentation. Use when making architecture decisions or analyzing system design.
|
|
4
|
+
allowed-tools: Read, Glob, Grep
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Architecture Decision Framework
|
|
8
|
+
|
|
9
|
+
> "Requirements drive architecture. Trade-offs inform decisions. ADRs capture rationale."
|
|
10
|
+
|
|
11
|
+
## 🎯 Selective Reading Rule
|
|
12
|
+
|
|
13
|
+
**Read ONLY files relevant to the request!** Check the content map, find what you need.
|
|
14
|
+
|
|
15
|
+
| File | Description | When to Read |
|
|
16
|
+
|------|-------------|--------------|
|
|
17
|
+
| `context-discovery.md` | Questions to ask, project classification | Starting architecture design |
|
|
18
|
+
| `trade-off-analysis.md` | ADR templates, trade-off framework | Documenting decisions |
|
|
19
|
+
| `pattern-selection.md` | Decision trees, anti-patterns | Choosing patterns |
|
|
20
|
+
| `examples.md` | MVP, SaaS, Enterprise examples | Reference implementations |
|
|
21
|
+
| `patterns-reference.md` | Quick lookup for patterns | Pattern comparison |
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 🔗 Related Skills
|
|
26
|
+
|
|
27
|
+
| Skill | Use For |
|
|
28
|
+
|-------|---------|
|
|
29
|
+
| `@[skills/database-design]` | Database schema design |
|
|
30
|
+
| `@[skills/api-patterns]` | API design patterns |
|
|
31
|
+
| `@[skills/deployment-procedures]` | Deployment architecture |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Core Principle
|
|
36
|
+
|
|
37
|
+
**"Simplicity is the ultimate sophistication."**
|
|
38
|
+
|
|
39
|
+
- Start simple
|
|
40
|
+
- Add complexity ONLY when proven necessary
|
|
41
|
+
- You can always add patterns later
|
|
42
|
+
- Removing complexity is MUCH harder than adding it
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Validation Checklist
|
|
47
|
+
|
|
48
|
+
Before finalizing architecture:
|
|
49
|
+
|
|
50
|
+
- [ ] Requirements clearly understood
|
|
51
|
+
- [ ] Constraints identified
|
|
52
|
+
- [ ] Each decision has trade-off analysis
|
|
53
|
+
- [ ] Simpler alternatives considered
|
|
54
|
+
- [ ] ADRs written for significant decisions
|
|
55
|
+
- [ ] Team expertise matches chosen patterns
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Context Discovery
|
|
2
|
+
|
|
3
|
+
> Before suggesting any architecture, gather context.
|
|
4
|
+
|
|
5
|
+
## Question Hierarchy (Ask User FIRST)
|
|
6
|
+
|
|
7
|
+
1. **Scale**
|
|
8
|
+
- How many users? (10, 1K, 100K, 1M+)
|
|
9
|
+
- Data volume? (MB, GB, TB)
|
|
10
|
+
- Transaction rate? (per second/minute)
|
|
11
|
+
|
|
12
|
+
2. **Team**
|
|
13
|
+
- Solo developer or team?
|
|
14
|
+
- Team size and expertise?
|
|
15
|
+
- Distributed or co-located?
|
|
16
|
+
|
|
17
|
+
3. **Timeline**
|
|
18
|
+
- MVP/Prototype or long-term product?
|
|
19
|
+
- Time to market pressure?
|
|
20
|
+
|
|
21
|
+
4. **Domain**
|
|
22
|
+
- CRUD-heavy or business logic complex?
|
|
23
|
+
- Real-time requirements?
|
|
24
|
+
- Compliance/regulations?
|
|
25
|
+
|
|
26
|
+
5. **Constraints**
|
|
27
|
+
- Budget limitations?
|
|
28
|
+
- Legacy systems to integrate?
|
|
29
|
+
- Technology stack preferences?
|
|
30
|
+
|
|
31
|
+
## Project Classification Matrix
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
MVP SaaS Enterprise
|
|
35
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
36
|
+
│ Scale │ <1K │ 1K-100K │ 100K+ │
|
|
37
|
+
│ Team │ Solo │ 2-10 │ 10+ │
|
|
38
|
+
│ Timeline │ Fast (weeks) │ Medium (months)│ Long (years)│
|
|
39
|
+
│ Architecture │ Simple │ Modular │ Distributed │
|
|
40
|
+
│ Patterns │ Minimal │ Selective │ Comprehensive│
|
|
41
|
+
│ Example │ Next.js API │ NestJS │ Microservices│
|
|
42
|
+
└─────────────────────────────────────────────────────────────┘
|
|
43
|
+
```
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Architecture Examples
|
|
2
|
+
|
|
3
|
+
> Real-world architecture decisions by project type.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Example 1: MVP E-commerce (Solo Developer)
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
Requirements:
|
|
11
|
+
- <1000 users initially
|
|
12
|
+
- Solo developer
|
|
13
|
+
- Fast to market (8 weeks)
|
|
14
|
+
- Budget-conscious
|
|
15
|
+
|
|
16
|
+
Architecture Decisions:
|
|
17
|
+
App Structure: Monolith (simpler for solo)
|
|
18
|
+
Framework: Next.js (full-stack, fast)
|
|
19
|
+
Data Layer: Prisma direct (no over-abstraction)
|
|
20
|
+
Authentication: JWT (simpler than OAuth)
|
|
21
|
+
Payment: Stripe (hosted solution)
|
|
22
|
+
Database: PostgreSQL (ACID for orders)
|
|
23
|
+
|
|
24
|
+
Trade-offs Accepted:
|
|
25
|
+
- Monolith → Can't scale independently (team doesn't justify it)
|
|
26
|
+
- No Repository → Less testable (simple CRUD doesn't need it)
|
|
27
|
+
- JWT → No social login initially (can add later)
|
|
28
|
+
|
|
29
|
+
Future Migration Path:
|
|
30
|
+
- Users > 10K → Extract payment service
|
|
31
|
+
- Team > 3 → Add Repository pattern
|
|
32
|
+
- Social login requested → Add OAuth
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Example 2: SaaS Product (5-10 Developers)
|
|
38
|
+
|
|
39
|
+
```yaml
|
|
40
|
+
Requirements:
|
|
41
|
+
- 1K-100K users
|
|
42
|
+
- 5-10 developers
|
|
43
|
+
- Long-term (12+ months)
|
|
44
|
+
- Multiple domains (billing, users, core)
|
|
45
|
+
|
|
46
|
+
Architecture Decisions:
|
|
47
|
+
App Structure: Modular Monolith (team size optimal)
|
|
48
|
+
Framework: NestJS (modular by design)
|
|
49
|
+
Data Layer: Repository pattern (testing, flexibility)
|
|
50
|
+
Domain Model: Partial DDD (rich entities)
|
|
51
|
+
Authentication: OAuth + JWT
|
|
52
|
+
Caching: Redis
|
|
53
|
+
Database: PostgreSQL
|
|
54
|
+
|
|
55
|
+
Trade-offs Accepted:
|
|
56
|
+
- Modular Monolith → Some module coupling (microservices not justified)
|
|
57
|
+
- Partial DDD → No full aggregates (no domain experts)
|
|
58
|
+
- RabbitMQ later → Initial synchronous (add when proven needed)
|
|
59
|
+
|
|
60
|
+
Migration Path:
|
|
61
|
+
- Team > 10 → Consider microservices
|
|
62
|
+
- Domains conflict → Extract bounded contexts
|
|
63
|
+
- Read performance issues → Add CQRS
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Example 3: Enterprise (100K+ Users)
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
Requirements:
|
|
72
|
+
- 100K+ users
|
|
73
|
+
- 10+ developers
|
|
74
|
+
- Multiple business domains
|
|
75
|
+
- Different scaling needs
|
|
76
|
+
- 24/7 availability
|
|
77
|
+
|
|
78
|
+
Architecture Decisions:
|
|
79
|
+
App Structure: Microservices (independent scale)
|
|
80
|
+
API Gateway: Kong/AWS API GW
|
|
81
|
+
Domain Model: Full DDD
|
|
82
|
+
Consistency: Event-driven (eventual OK)
|
|
83
|
+
Message Bus: Kafka
|
|
84
|
+
Authentication: OAuth + SAML (enterprise SSO)
|
|
85
|
+
Database: Polyglot (right tool per job)
|
|
86
|
+
CQRS: Selected services
|
|
87
|
+
|
|
88
|
+
Operational Requirements:
|
|
89
|
+
- Service mesh (Istio/Linkerd)
|
|
90
|
+
- Distributed tracing (Jaeger/Tempo)
|
|
91
|
+
- Centralized logging (ELK/Loki)
|
|
92
|
+
- Circuit breakers (Resilience4j)
|
|
93
|
+
- Kubernetes/Helm
|
|
94
|
+
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Pattern Selection Guidelines
|
|
2
|
+
|
|
3
|
+
> Decision trees for choosing architectural patterns.
|
|
4
|
+
|
|
5
|
+
## Main Decision Tree
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
START: What's your MAIN concern?
|
|
9
|
+
|
|
10
|
+
┌─ Data Access Complexity?
|
|
11
|
+
│ ├─ HIGH (complex queries, testing needed)
|
|
12
|
+
│ │ → Repository Pattern + Unit of Work
|
|
13
|
+
│ │ VALIDATE: Will data source change frequently?
|
|
14
|
+
│ │ ├─ YES → Repository worth the indirection
|
|
15
|
+
│ │ └─ NO → Consider simpler ORM direct access
|
|
16
|
+
│ └─ LOW (simple CRUD, single database)
|
|
17
|
+
│ → ORM directly (Prisma, Drizzle)
|
|
18
|
+
│ Simpler = Better, Faster
|
|
19
|
+
│
|
|
20
|
+
├─ Business Rules Complexity?
|
|
21
|
+
│ ├─ HIGH (domain logic, rules vary by context)
|
|
22
|
+
│ │ → Domain-Driven Design
|
|
23
|
+
│ │ VALIDATE: Do you have domain experts on team?
|
|
24
|
+
│ │ ├─ YES → Full DDD (Aggregates, Value Objects)
|
|
25
|
+
│ │ └─ NO → Partial DDD (rich entities, clear boundaries)
|
|
26
|
+
│ └─ LOW (mostly CRUD, simple validation)
|
|
27
|
+
│ → Transaction Script pattern
|
|
28
|
+
│ Simpler = Better, Faster
|
|
29
|
+
│
|
|
30
|
+
├─ Independent Scaling Needed?
|
|
31
|
+
│ ├─ YES (different components scale differently)
|
|
32
|
+
│ │ → Microservices WORTH the complexity
|
|
33
|
+
│ │ REQUIREMENTS (ALL must be true):
|
|
34
|
+
│ │ - Clear domain boundaries
|
|
35
|
+
│ │ - Team > 10 developers
|
|
36
|
+
│ │ - Different scaling needs per service
|
|
37
|
+
│ │ IF NOT ALL MET → Modular Monolith instead
|
|
38
|
+
│ └─ NO (everything scales together)
|
|
39
|
+
│ → Modular Monolith
|
|
40
|
+
│ Can extract services later when proven needed
|
|
41
|
+
│
|
|
42
|
+
└─ Real-time Requirements?
|
|
43
|
+
├─ HIGH (immediate updates, multi-user sync)
|
|
44
|
+
│ → Event-Driven Architecture
|
|
45
|
+
│ → Message Queue (RabbitMQ, Redis, Kafka)
|
|
46
|
+
│ VALIDATE: Can you handle eventual consistency?
|
|
47
|
+
│ ├─ YES → Event-driven valid
|
|
48
|
+
│ └─ NO → Synchronous with polling
|
|
49
|
+
└─ LOW (eventual consistency acceptable)
|
|
50
|
+
→ Synchronous (REST/GraphQL)
|
|
51
|
+
Simpler = Better, Faster
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## The 3 Questions (Before ANY Pattern)
|
|
55
|
+
|
|
56
|
+
1. **Problem Solved**: What SPECIFIC problem does this pattern solve?
|
|
57
|
+
2. **Simpler Alternative**: Is there a simpler solution?
|
|
58
|
+
3. **Deferred Complexity**: Can we add this LATER when needed?
|
|
59
|
+
|
|
60
|
+
## Red Flags (Anti-patterns)
|
|
61
|
+
|
|
62
|
+
| Pattern | Anti-pattern | Simpler Alternative |
|
|
63
|
+
|---------|-------------|-------------------|
|
|
64
|
+
| Microservices | Premature splitting | Start monolith, extract later |
|
|
65
|
+
| Clean/Hexagonal | Over-abstraction | Concrete first, interfaces later |
|
|
66
|
+
| Event Sourcing | Over-engineering | Append-only audit log |
|
|
67
|
+
| CQRS | Unnecessary complexity | Single model |
|
|
68
|
+
| Repository | YAGNI for simple CRUD | ORM direct access |
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Architecture Patterns Reference
|
|
2
|
+
|
|
3
|
+
> Quick reference for common patterns with usage guidance.
|
|
4
|
+
|
|
5
|
+
## Data Access Patterns
|
|
6
|
+
|
|
7
|
+
| Pattern | When to Use | When NOT to Use | Complexity |
|
|
8
|
+
|---------|-------------|-----------------|------------|
|
|
9
|
+
| **Active Record** | Simple CRUD, rapid prototyping | Complex queries, multiple sources | Low |
|
|
10
|
+
| **Repository** | Testing needed, multiple sources | Simple CRUD, single database | Medium |
|
|
11
|
+
| **Unit of Work** | Complex transactions | Simple operations | High |
|
|
12
|
+
| **Data Mapper** | Complex domain, performance | Simple CRUD, rapid dev | High |
|
|
13
|
+
|
|
14
|
+
## Domain Logic Patterns
|
|
15
|
+
|
|
16
|
+
| Pattern | When to Use | When NOT to Use | Complexity |
|
|
17
|
+
|---------|-------------|-----------------|------------|
|
|
18
|
+
| **Transaction Script** | Simple CRUD, procedural | Complex business rules | Low |
|
|
19
|
+
| **Table Module** | Record-based logic | Rich behavior needed | Low |
|
|
20
|
+
| **Domain Model** | Complex business logic | Simple CRUD | Medium |
|
|
21
|
+
| **DDD (Full)** | Complex domain, domain experts | Simple domain, no experts | High |
|
|
22
|
+
|
|
23
|
+
## Distributed System Patterns
|
|
24
|
+
|
|
25
|
+
| Pattern | When to Use | When NOT to Use | Complexity |
|
|
26
|
+
|---------|-------------|-----------------|------------|
|
|
27
|
+
| **Modular Monolith** | Small teams, unclear boundaries | Clear contexts, different scales | Medium |
|
|
28
|
+
| **Microservices** | Different scales, large teams | Small teams, simple domain | Very High |
|
|
29
|
+
| **Event-Driven** | Real-time, loose coupling | Simple workflows, strong consistency | High |
|
|
30
|
+
| **CQRS** | Read/write performance diverges | Simple CRUD, same model | High |
|
|
31
|
+
| **Saga** | Distributed transactions | Single database, simple ACID | High |
|
|
32
|
+
|
|
33
|
+
## API Patterns
|
|
34
|
+
|
|
35
|
+
| Pattern | When to Use | When NOT to Use | Complexity |
|
|
36
|
+
|---------|-------------|-----------------|------------|
|
|
37
|
+
| **REST** | Standard CRUD, resources | Real-time, complex queries | Low |
|
|
38
|
+
| **GraphQL** | Flexible queries, multiple clients | Simple CRUD, caching needs | Medium |
|
|
39
|
+
| **gRPC** | Internal services, performance | Public APIs, browser clients | Medium |
|
|
40
|
+
| **WebSocket** | Real-time updates | Simple request/response | Medium |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Simplicity Principle
|
|
45
|
+
|
|
46
|
+
**"Start simple, add complexity only when proven necessary."**
|
|
47
|
+
|
|
48
|
+
- You can always add patterns later
|
|
49
|
+
- Removing complexity is MUCH harder than adding it
|
|
50
|
+
- When in doubt, choose simpler option
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Trade-off Analysis & ADR
|
|
2
|
+
|
|
3
|
+
> Document every architectural decision with trade-offs.
|
|
4
|
+
|
|
5
|
+
## Decision Framework
|
|
6
|
+
|
|
7
|
+
For EACH architectural component, document:
|
|
8
|
+
|
|
9
|
+
```markdown
|
|
10
|
+
## Architecture Decision Record
|
|
11
|
+
|
|
12
|
+
### Context
|
|
13
|
+
- **Problem**: [What problem are we solving?]
|
|
14
|
+
- **Constraints**: [Team size, scale, timeline, budget]
|
|
15
|
+
|
|
16
|
+
### Options Considered
|
|
17
|
+
|
|
18
|
+
| Option | Pros | Cons | Complexity | When Valid |
|
|
19
|
+
|--------|------|------|------------|-----------|
|
|
20
|
+
| Option A | Benefit 1 | Cost 1 | Low | [Conditions] |
|
|
21
|
+
| Option B | Benefit 2 | Cost 2 | High | [Conditions] |
|
|
22
|
+
|
|
23
|
+
### Decision
|
|
24
|
+
**Chosen**: [Option B]
|
|
25
|
+
|
|
26
|
+
### Rationale
|
|
27
|
+
1. [Reason 1 - tied to constraints]
|
|
28
|
+
2. [Reason 2 - tied to requirements]
|
|
29
|
+
|
|
30
|
+
### Trade-offs Accepted
|
|
31
|
+
- [What we're giving up]
|
|
32
|
+
- [Why this is acceptable]
|
|
33
|
+
|
|
34
|
+
### Consequences
|
|
35
|
+
- **Positive**: [Benefits we gain]
|
|
36
|
+
- **Negative**: [Costs/risks we accept]
|
|
37
|
+
- **Mitigation**: [How we'll address negatives]
|
|
38
|
+
|
|
39
|
+
### Revisit Trigger
|
|
40
|
+
- [When to reconsider this decision]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## ADR Template
|
|
44
|
+
|
|
45
|
+
```markdown
|
|
46
|
+
# ADR-[XXX]: [Decision Title]
|
|
47
|
+
|
|
48
|
+
## Status
|
|
49
|
+
Proposed | Accepted | Deprecated | Superseded by [ADR-YYY]
|
|
50
|
+
|
|
51
|
+
## Context
|
|
52
|
+
[What problem? What constraints?]
|
|
53
|
+
|
|
54
|
+
## Decision
|
|
55
|
+
[What we chose - be specific]
|
|
56
|
+
|
|
57
|
+
## Rationale
|
|
58
|
+
[Why - tie to requirements and constraints]
|
|
59
|
+
|
|
60
|
+
## Trade-offs
|
|
61
|
+
[What we're giving up - be honest]
|
|
62
|
+
|
|
63
|
+
## Consequences
|
|
64
|
+
- **Positive**: [Benefits]
|
|
65
|
+
- **Negative**: [Costs]
|
|
66
|
+
- **Mitigation**: [How to address]
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## ADR Storage
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
docs/
|
|
73
|
+
└── architecture/
|
|
74
|
+
├── adr-001-use-nextjs.md
|
|
75
|
+
├── adr-002-postgresql-over-mongodb.md
|
|
76
|
+
└── adr-003-adopt-repository-pattern.md
|
|
77
|
+
```
|
|
@@ -13,10 +13,10 @@ Você é responsável por garantir que cada interação do chat resulte em códi
|
|
|
13
13
|
|
|
14
14
|
## 1. Filosofia do Loop
|
|
15
15
|
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
16
|
+
- **Confiança:** O código não é considerado pronto até ser validado.
|
|
17
|
+
- **Autonomia:** Corrigir erros triviais (lint, build, testes simples) sem onerar o usuário.
|
|
18
|
+
- **Velocidade:** Uso intensivo do Bun para ciclos de feedback instantâneos.
|
|
19
|
+
- **Transparência:** Commits claros que explicam a evolução da história/bug.
|
|
20
20
|
|
|
21
21
|
## 2. Fluxo de Trabalho Obrigatório
|
|
22
22
|
|
|
@@ -24,40 +24,40 @@ Toda vez que uma alteração de código for finalizada, você deve seguir este f
|
|
|
24
24
|
|
|
25
25
|
### Passo 1: Validação (Bun)
|
|
26
26
|
|
|
27
|
-
-
|
|
28
|
-
- **Testes:** Rodar testes unitários/integração com `bun test`.
|
|
29
|
-
- **Build:** Se for um projeto compilado (Vite), rodar `bun run build`.
|
|
30
|
-
-
|
|
27
|
+
- **Check:** Executar `bun run lint` ou `bun x eslint .` para garantir padrões.
|
|
28
|
+
<!-- - **Testes:** Rodar testes unitários/integração com `bun test`. -->
|
|
29
|
+
<!-- - **Build:** Se for um projeto compilado (Vite), rodar `bun run build`. -->
|
|
30
|
+
- **Auto-Correção:** Se houver erros, ANALISE a stack trace, CORRIJA o código e RE-VALIDE. Tente até 2 vezes antes de pedir ajuda ao usuário.
|
|
31
31
|
|
|
32
32
|
### Passo 2: Versionamento (Commit Semântico)
|
|
33
33
|
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
34
|
+
- Se a validação passar, gere uma mensagem de commit seguindo o padrão **Conventional Commits**:
|
|
35
|
+
- `feat:` para novas histórias.
|
|
36
|
+
- `fix:` para correções de bugs.
|
|
37
|
+
- `refactor:` para melhorias de código sem mudança de comportamento.
|
|
38
|
+
- `docs:` para documentação.
|
|
39
39
|
|
|
40
40
|
### Passo 3: Publicação & Deploy
|
|
41
41
|
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
42
|
+
- **Push:** Executar o comando `git-publish` (ou o atalho `gcp`).
|
|
43
|
+
- **Deploy:**
|
|
44
|
+
- Se for infra Fly.io: Executar `fly deploy`.
|
|
45
|
+
- Se for via GitHub Actions: O push para a branch principal deve disparar o fluxo.
|
|
46
46
|
|
|
47
47
|
## 3. Regras de Interface com o Usuário
|
|
48
48
|
|
|
49
49
|
Ao concluir o loop com sucesso, apresente um resumo:
|
|
50
50
|
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
51
|
+
- ✅ **Validado:** [Comando executado] (ex: `bun test` passou).
|
|
52
|
+
- 📦 **Commit:** `[mensagem de commit]`
|
|
53
|
+
- 🚀 **Status:** Deploy iniciado/concluído.
|
|
54
54
|
|
|
55
55
|
Se falhar após as tentativas de auto-correção:
|
|
56
56
|
|
|
57
|
-
-
|
|
58
|
-
-
|
|
57
|
+
- ❌ **Erro:** Explique detalhadamente o que falhou e mostre o log.
|
|
58
|
+
- 💡 **Ação:** Pergunte como o usuário deseja proceder.
|
|
59
59
|
|
|
60
60
|
## 4. Integração com Tech Stack
|
|
61
61
|
|
|
62
|
-
-
|
|
63
|
-
-
|
|
62
|
+
- **Bun First:** Sempre prefira `bun` como gerenciador de pacotes e runtime.
|
|
63
|
+
- **Mantine/React:** Verifique se as novas bibliotecas seguem o `riligar-design-system`.
|