antigravity-ai-kit 3.2.0 → 3.4.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.
@@ -0,0 +1,111 @@
1
+ # Architecture Rules
2
+
3
+ > **Priority**: HIGH — Enforced in design reviews
4
+ > **Scope**: All workspaces — universal architectural constraints
5
+
6
+ ---
7
+
8
+ ## Architecture Principles
9
+
10
+ | Principle | Enforcement |
11
+ | :----------------------- | :------------------------------------------------------------ |
12
+ | Separation of Concerns | Each module has a single, well-defined responsibility |
13
+ | Dependency Direction | Dependencies ALWAYS point inward — domain never imports infra |
14
+ | Contract-First Design | Define API contracts before implementation begins |
15
+ | Explicit Over Implicit | Configuration, dependencies, and boundaries must be explicit |
16
+ | Composition Over Inherit | Prefer composition and dependency injection over inheritance |
17
+
18
+ ---
19
+
20
+ ## Boundary Enforcement
21
+
22
+ - **NEVER** import backend code from frontend or vice versa
23
+ - **NEVER** skip architectural layers — each layer imports only from the layer directly below
24
+ - **NEVER** hold direct object references across aggregate or module boundaries — use IDs
25
+ - Shared types and contracts are defined at the API boundary and replicated per consumer
26
+ - Cross-module communication uses events or explicit service interfaces, not direct coupling
27
+
28
+ ---
29
+
30
+ ## Project Structure
31
+
32
+ Projects should follow one of these organizational patterns:
33
+
34
+ | Pattern | When to Use |
35
+ | :--------------- | :------------------------------------------------------- |
36
+ | **Monorepo** | Multiple apps sharing code (Turborepo, Nx, Rush) |
37
+ | **Polyrepo** | Independent services with separate lifecycles |
38
+ | **Modular Mono** | Single deployable with clear bounded context separation |
39
+
40
+ > **Customization**: Project-specific structure decisions should be documented in `decisions/` as Architecture Decision Records (ADRs).
41
+
42
+ ---
43
+
44
+ ## Layered Architecture
45
+
46
+ ```
47
+ Thin Routes / Controllers → Service Layer → Models / Data Access
48
+
49
+ Domain Logic
50
+ ```
51
+
52
+ | Layer | Responsibility | Rules |
53
+ | :--------------- | :---------------------------------------- | :------------------------------------------------- |
54
+ | Routes | HTTP handling, auth enforcement | MAX 10 lines per handler, delegate to services |
55
+ | Services | Business logic, validation, orchestration | Pure functions where possible, fully testable |
56
+ | Models / Data | Database schema, relationships | ORM-managed, migration-controlled |
57
+ | Schemas | Request/response contracts | Validated models, explicit field constraints |
58
+
59
+ ---
60
+
61
+ ## Database Conventions
62
+
63
+ - **Migrations** for ALL schema changes — no manual SQL in production
64
+ - Table names: `snake_case`, plural (`users`, `funnel_events`)
65
+ - Column names: `snake_case`
66
+ - Always include: `id` (UUID recommended), `created_at`, `updated_at`
67
+ - Foreign keys: `<entity>_id` naming convention
68
+ - Indexes: create for all foreign keys and frequent query columns
69
+ - Soft deletes preferred over hard deletes for audit-sensitive data
70
+
71
+ ---
72
+
73
+ ## API Design Principles
74
+
75
+ | Principle | Standard |
76
+ | :------------------- | :---------------------------------------------------------- |
77
+ | Versioning | URL-prefix (`/api/v1/`) or header-based — be consistent |
78
+ | Methods | Standard HTTP methods and status codes (RESTful) |
79
+ | Response Format | All endpoints return validated, structured JSON |
80
+ | Pagination | Offset-based (`skip`/`limit`) or cursor-based — documented |
81
+ | Error Format | `{ "detail": "Human-readable message" }` minimum |
82
+ | Rate Limiting | Documented per endpoint, enforced server-side |
83
+
84
+ ---
85
+
86
+ ## Architecture Decision Records
87
+
88
+ When making significant architectural decisions, document them using ADRs in the `decisions/` directory:
89
+
90
+ - Choosing between architectural approaches (monolith vs microservices)
91
+ - Selecting a technology (database, framework, library)
92
+ - Establishing a pattern (event sourcing vs CRUD)
93
+ - Making a trade-off (consistency vs availability)
94
+
95
+ ADR format: `decisions/adr-NNN-<decision-title>.md`
96
+
97
+ ---
98
+
99
+ ## Related Resources
100
+
101
+ - **Skill**: `.agent/skills/architecture/SKILL.md` — deep architectural patterns (DDD, Clean Architecture, 12-Factor, SOLID)
102
+ - **Agent**: `.agent/agents/architect.md` — architecture review process and checklists
103
+
104
+ ---
105
+
106
+ ## Version History
107
+
108
+ | Version | Date | Changes |
109
+ | :------ | :--------- | :----------------------------------------------------- |
110
+ | 1.0.0 | 2026-03-16 | Initial generic architecture enforcement rules for kit |
111
+
@@ -0,0 +1,117 @@
1
+ # Quality Gate Rules
2
+
3
+ > **Priority**: HIGH — Enforced before implementation of new features and refactors
4
+ > **Scope**: All workspaces — applies to `feat()` and `refactor()` tasks only
5
+
6
+ ---
7
+
8
+ ## Scope Filter
9
+
10
+ | Task Type | Quality Gate Required? |
11
+ | :-------------------------------- | :--------------------- |
12
+ | `feat()` — new features | ✅ Required |
13
+ | `refactor()` — structural changes | ✅ Required |
14
+ | `fix()` — bug fixes | ❌ Skip |
15
+ | `chore()` — maintenance | ❌ Skip |
16
+ | `docs()` — documentation | ❌ Skip |
17
+ | `test()` — test additions | ❌ Skip |
18
+
19
+ ---
20
+
21
+ ## Pre-Execution Research Checklist
22
+
23
+ Before implementing any in-scope task, **ALL** items must be completed. If any item is incomplete, execution is forbidden.
24
+
25
+ ### ☐ 1. Market Research Completed
26
+
27
+ - Analyze **minimum 5** competitors or market leaders in the feature domain
28
+ - Document how each implements the same or similar feature
29
+ - Identify user adoption drivers: UX simplicity, accuracy, speed, transparency
30
+
31
+ ### ☐ 2. Outdated Pattern Verification
32
+
33
+ - Verify the proposed approach does not use deprecated, abandoned, or criticized patterns
34
+ - If outdated → propose a modern, evidence-based alternative (mandatory)
35
+ - Document which patterns are considered harmful or legacy
36
+
37
+ ### ☐ 3. Baseline Parity Validation
38
+
39
+ - Confirm the project **meets or exceeds** the current market baseline
40
+ - Gaps must be explicitly listed with severity assessment
41
+ - No gap left unaddressed without documented justification
42
+
43
+ ### ☐ 4. Enhancement Definition
44
+
45
+ - Define exactly how the project **improves upon** the market baseline
46
+ - Improvement must be intentional and documented
47
+ - Consider: transparency, ethical automation, user-centricity, measurable outcomes
48
+
49
+ ### ☐ 5. Ethics & Automation Risk Assessment
50
+
51
+ - Evaluate: privacy implications, AI bias risks, automation safety, user autonomy
52
+ - Mitigation strategies must be documented for each identified risk
53
+ - Data protection compliance must be considered for data-touching features
54
+
55
+ ### ☐ 6. Implementation Plan Prepared
56
+
57
+ - Structured plan ready before execution begins
58
+ - Plan includes research summary, key insights, risks, execution steps
59
+ - Plan reviewed and approved before implementation may begin
60
+
61
+ ---
62
+
63
+ ## Enhancement Principle
64
+
65
+ | Scenario | Required Action |
66
+ | :------------------------------------------ | :------------------------------- |
67
+ | Competitors offer a standard | **Meet or exceed** it |
68
+ | Competitors use unethical automation | **Reject and improve** |
69
+ | Feature can be more transparent | **Enhance by default** |
70
+ | Feature can be more user-centric | **Enhance by default** |
71
+ | Feature can offer measurable outcomes | **Enhance by default** |
72
+
73
+ **Never replicate patterns without improvement.**
74
+
75
+ ---
76
+
77
+ ## Cross-Cutting Deference
78
+
79
+ Quality gate enforcement defers to specialized rules for domain-specific checks:
80
+
81
+ - **Security**: See `rules/security.md` for input validation, auth, data protection
82
+ - **Testing**: See `rules/testing.md` for coverage requirements, test types
83
+ - **Code Quality**: See `rules/coding-style.md` for naming, file limits, immutability
84
+ - **Documentation**: See `rules/documentation.md` for doc hierarchy, SSOT
85
+
86
+ ---
87
+
88
+ ## Reject & Escalate Rules
89
+
90
+ | Condition | Action |
91
+ | :------------------------------------------ | :------------------------------------- |
92
+ | No market research provided | ❌ Reject — enforce research protocol |
93
+ | Clearly outdated or harmful patterns | ❌ Reject — propose modern alternative |
94
+ | Below-market standard solutions | ❌ Reject — document gap |
95
+ | Ethics, privacy, or automation safety risks | ❌ Reject — document mitigation |
96
+ | Bypassing research ("just implement it") | ❌ Reject — enforce protocol |
97
+
98
+ ### Escalation Response
99
+
100
+ > "This task cannot proceed in its current form, as it does not meet quality and market standards. Below are the identified risks and gaps. A revised, modern alternative is proposed."
101
+
102
+ ---
103
+
104
+ ## Related Resources
105
+
106
+ - **Workflow**: `.agent/workflows/quality-gate.md` — step-by-step research procedure
107
+ - **Skill**: `.agent/skills/brainstorming/SKILL.md` — Socratic questioning patterns
108
+ - **Next Step**: After approval, proceed to `/plan` for implementation planning
109
+
110
+ ---
111
+
112
+ ## Version History
113
+
114
+ | Version | Date | Changes |
115
+ | :------ | :--------- | :------------------------------------------------ |
116
+ | 1.0.0 | 2026-03-16 | Initial generic quality gate protocol for kit |
117
+
@@ -1,18 +1,18 @@
1
1
  ---
2
2
  name: architecture
3
- description: System design patterns and architectural principles
3
+ description: "System design patterns, DDD, 12-Factor App, SOLID principles, event-driven architecture, and architectural decision frameworks"
4
4
  triggers: [context, architecture, design, system]
5
5
  ---
6
6
 
7
7
  # Architecture Skill
8
8
 
9
- > **Purpose**: Apply proven architectural patterns for scalable systems
9
+ > **Purpose**: Apply proven architectural patterns for scalable, maintainable systems using industry-standard methodologies
10
10
 
11
11
  ---
12
12
 
13
13
  ## Overview
14
14
 
15
- This skill provides guidance for designing maintainable, scalable software architectures using industry-standard patterns.
15
+ This skill provides deep guidance for designing software architectures using Domain-Driven Design, Clean Architecture, the 12-Factor App methodology, event-driven patterns, and SOLID principles.
16
16
 
17
17
  ---
18
18
 
@@ -22,88 +22,209 @@ This skill provides guidance for designing maintainable, scalable software archi
22
22
 
23
23
  ```
24
24
  ┌─────────────────────────┐
25
- │ Presentation Layer │ ← Controllers, Views
25
+ │ Presentation Layer │ ← Controllers, Views, API endpoints
26
26
  ├─────────────────────────┤
27
- │ Application Layer │ ← Use Cases, Services
27
+ │ Application Layer │ ← Use Cases, Services, Orchestration
28
28
  ├─────────────────────────┤
29
- │ Domain Layer │ ← Entities, Business Logic
29
+ │ Domain Layer │ ← Entities, Business Logic, Domain Events
30
30
  ├─────────────────────────┤
31
- │ Infrastructure Layer │ ← Database, External APIs
31
+ │ Infrastructure Layer │ ← Database, External APIs, Messaging
32
32
  └─────────────────────────┘
33
33
  ```
34
34
 
35
+ **Rule**: Each layer ONLY imports from the layer directly below it. Never skip layers.
36
+
35
37
  ### 2. Clean Architecture
36
38
 
37
- - **Entities**: Core business objects
38
- - **Use Cases**: Application-specific business rules
39
- - **Interface Adapters**: Controllers, Presenters, Gateways
40
- - **Frameworks**: External concerns (DB, Web, Devices)
39
+ ```
40
+ ┌─────────────┐
41
+ │ Frameworks │ ← Web, DB, UI (outermost)
42
+ ┌─┤ ├─┐
43
+ │ │ Adapters │ │ ← Controllers, Gateways, Presenters
44
+ ┌─┤ │ │ ├─┐
45
+ │ │ │ Use Cases │ │ │ ← Application business rules
46
+ ┌─┤ │ │ │ │ ├─┐
47
+ │ │ │ │ Entities │ │ │ │ ← Core business objects (innermost)
48
+ └─┤ │ │ │ │ ├─┘
49
+ └─┤ │ │ ├─┘
50
+ └─┤ ├─┘
51
+ └─────────────┘
52
+ ```
53
+
54
+ **Dependency Rule**: Source code dependencies ALWAYS point inward. Inner layers know nothing about outer layers.
41
55
 
42
56
  ### 3. Hexagonal Architecture (Ports & Adapters)
43
57
 
44
58
  ```
45
59
  ┌─────────────────┐
46
60
  ──────│ Ports │──────
47
- │ (Interfaces) │
48
- │ │
61
+ Input │ (Interfaces) │ Output
62
+ Ports │ │ Ports
49
63
  │ Domain Core │
50
64
  │ │
51
65
  ──────│ Adapters │──────
66
+ Input │ (Implementations)│ Output
67
+ Adapters Adapters
52
68
  └─────────────────┘
53
69
  ```
54
70
 
71
+ **Key Insight**: The domain core defines ports (interfaces). Adapters implement them. This makes the domain testable without infrastructure.
72
+
73
+ ---
74
+
75
+ ## Domain-Driven Design (DDD)
76
+
77
+ ### Strategic DDD — Bounded Contexts
78
+
79
+ | Concept | Definition | Example |
80
+ |:--------|:-----------|:--------|
81
+ | **Bounded Context** | A boundary within which a domain model is consistent | "Order" means different things in Sales vs Shipping |
82
+ | **Ubiquitous Language** | Shared vocabulary within a bounded context | "Customer" in Sales = "Recipient" in Shipping |
83
+ | **Context Map** | Visual map of relationships between bounded contexts | Sales ← Customer/Supplier → Fulfillment |
84
+ | **Anti-Corruption Layer** | Translation layer between contexts with different models | Adapter that maps external API models to domain models |
85
+
86
+ ### Tactical DDD — Building Blocks
87
+
88
+ | Building Block | Purpose | Rules |
89
+ |:--------------|:--------|:------|
90
+ | **Entity** | Object with identity that persists over time | Has unique ID, mutable state, lifecycle |
91
+ | **Value Object** | Immutable object defined by its attributes | No ID, compared by value, always valid |
92
+ | **Aggregate** | Cluster of entities with a root that enforces invariants | External access only through root, transactional consistency |
93
+ | **Repository** | Interface for aggregate persistence | One per aggregate, hides storage details |
94
+ | **Domain Service** | Stateless logic spanning multiple aggregates | When logic doesn't belong to a single entity |
95
+ | **Domain Event** | Record of something that happened in the domain | Immutable, past tense (OrderPlaced, PaymentReceived) |
96
+ | **Factory** | Complex object/aggregate creation | Encapsulates creation logic and invariant enforcement |
97
+
98
+ ### Aggregate Design Rules
99
+
100
+ 1. **Protect invariants within aggregate boundaries** — All business rules enforced by the aggregate root
101
+ 2. **Reference other aggregates by ID only** — Never hold direct object references across aggregate boundaries
102
+ 3. **One transaction per aggregate** — Don't modify multiple aggregates in a single transaction
103
+ 4. **Design small aggregates** — Smaller = less contention, better scalability
104
+ 5. **Use eventual consistency between aggregates** — Domain events for cross-aggregate communication
105
+
106
+ ---
107
+
108
+ ## 12-Factor App Methodology
109
+
110
+ | Factor | Principle | Implementation |
111
+ |:-------|:----------|:--------------|
112
+ | **I. Codebase** | One codebase tracked in VCS, many deploys | Git repo, branches for environments |
113
+ | **II. Dependencies** | Explicitly declare and isolate dependencies | `package.json` + lockfile, no global installs |
114
+ | **III. Config** | Store config in the environment | `process.env.*`, never in code |
115
+ | **IV. Backing Services** | Treat backing services as attached resources | Database URL as environment variable |
116
+ | **V. Build, Release, Run** | Strictly separate build and run stages | CI builds artifact → deploy artifact → run |
117
+ | **VI. Processes** | Execute the app as stateless processes | No sticky sessions, no in-memory state between requests |
118
+ | **VII. Port Binding** | Export services via port binding | `app.listen(PORT)`, no container-specific coupling |
119
+ | **VIII. Concurrency** | Scale out via the process model | Horizontal scaling, not bigger machines |
120
+ | **IX. Disposability** | Maximize robustness with fast startup and graceful shutdown | `SIGTERM` handler, connection draining |
121
+ | **X. Dev/Prod Parity** | Keep development, staging, and production as similar as possible | Same database, same services, Docker |
122
+ | **XI. Logs** | Treat logs as event streams | Write to stdout, let platform aggregate |
123
+ | **XII. Admin Processes** | Run admin/management tasks as one-off processes | Database migrations, data fixes as scripts |
124
+
125
+ ---
126
+
127
+ ## Event-Driven Architecture
128
+
129
+ ### Pattern Selection
130
+
131
+ | Pattern | Use When | Complexity | Consistency |
132
+ |:--------|:---------|:-----------|:-----------|
133
+ | **Request/Response** | Synchronous, simple operations | Low | Strong |
134
+ | **Event Notification** | Inform other services something happened | Low | Eventual |
135
+ | **Event-Carried State Transfer** | Share data without coupling to source | Medium | Eventual |
136
+ | **Event Sourcing** | Full audit trail, state reconstruction | High | Strong (per aggregate) |
137
+ | **CQRS** | Different read/write models needed | Medium-High | Eventual (between models) |
138
+
139
+ ### Event Design Principles
140
+
141
+ 1. **Events are facts** — Something that happened (past tense: `OrderPlaced`, not `PlaceOrder`)
142
+ 2. **Events are immutable** — Never modify or delete events
143
+ 3. **Events carry sufficient data** — Include everything consumers need (avoid callbacks)
144
+ 4. **Events have schemas** — Version and validate event structures
145
+ 5. **Events are ordered within an aggregate** — Global ordering is optional and expensive
146
+
55
147
  ---
56
148
 
57
149
  ## Design Principles
58
150
 
59
- ### SOLID
151
+ ### SOLID — Applied
60
152
 
61
- | Principle | Description |
62
- | :------------------------ | :------------------------------------------ |
63
- | **S**ingle Responsibility | One reason to change |
64
- | **O**pen/Closed | Open for extension, closed for modification |
65
- | **L**iskov Substitution | Subtypes must be substitutable |
66
- | **I**nterface Segregation | Many specific interfaces |
67
- | **D**ependency Inversion | Depend on abstractions |
153
+ | Principle | Description | Violation Smell | Fix |
154
+ |:----------|:-----------|:---------------|:----|
155
+ | **S**ingle Responsibility | One reason to change | Class does file I/O AND business logic | Split into Repository + Service |
156
+ | **O**pen/Closed | Open for extension, closed for modification | `if/else` chain for new types | Strategy pattern, polymorphism |
157
+ | **L**iskov Substitution | Subtypes must be substitutable | Subclass throws unexpected exception | Respect base class contract |
158
+ | **I**nterface Segregation | Many specific interfaces | God interface with 20 methods | Split into focused interfaces |
159
+ | **D**ependency Inversion | Depend on abstractions | Service directly imports Prisma client | Inject Repository interface |
68
160
 
69
- ### DRY, KISS, YAGNI
161
+ ### Additional Principles
70
162
 
71
- - **DRY**: Don't Repeat Yourself
72
- - **KISS**: Keep It Simple, Stupid
73
- - **YAGNI**: You Aren't Gonna Need It
163
+ - **DRY**: Don't Repeat Yourself — Extract shared logic, but avoid premature abstraction
164
+ - **KISS**: Keep It Simple — Prefer straightforward solutions over clever ones
165
+ - **YAGNI**: You Aren't Gonna Need It — Don't build for hypothetical future requirements
74
166
 
75
167
  ---
76
168
 
77
- ## Module Structure
169
+ ## Module Structure (DDD-Aligned)
78
170
 
79
171
  ```
80
172
  src/
81
- ├── domain/ # Core business logic
82
- │ ├── entities/
83
- │ ├── value-objects/
84
- └── services/
85
- ├── application/ # Use cases
86
- ├── commands/
87
- ├── queries/
88
- └── handlers/
89
- ├── infrastructure/ # External concerns
90
- ├── database/
91
- ├── messaging/
92
- └── external-apis/
93
- └── interfaces/ # Entry points
94
- ├── http/
95
- ├── graphql/
96
- └── cli/
173
+ ├── domain/ # Core business logic (no framework imports)
174
+ │ ├── entities/ # Entities with identity
175
+ │ ├── value-objects/ # Immutable value types
176
+ ├── events/ # Domain events
177
+ ├── services/ # Domain services
178
+ └── repositories/ # Repository interfaces (ports)
179
+ ├── application/ # Use cases / application services
180
+ ├── commands/ # Write operations
181
+ ├── queries/ # Read operations
182
+ └── handlers/ # Command/query handlers
183
+ ├── infrastructure/ # External concerns (adapters)
184
+ ├── database/ # Repository implementations
185
+ │ ├── messaging/ # Event bus, message queues
186
+ ├── external-apis/ # Third-party integrations
187
+ │ └── config/ # Environment configuration
188
+ └── interfaces/ # Entry points (driving adapters)
189
+ ├── http/ # REST/GraphQL controllers
190
+ ├── events/ # Event consumers
191
+ └── cli/ # CLI commands
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Architecture Decision Records (ADRs)
197
+
198
+ ### When to Write an ADR
199
+
200
+ - Choosing between architectural approaches (monolith vs microservices)
201
+ - Selecting a technology (PostgreSQL vs MongoDB)
202
+ - Establishing a pattern (event sourcing vs CRUD)
203
+ - Making a trade-off (consistency vs availability)
204
+
205
+ ### ADR Template
206
+
207
+ ```markdown
208
+ # ADR-NNN: [Decision Title]
209
+
210
+ **Status**: Proposed | Accepted | Deprecated | Superseded by ADR-XXX
211
+ **Date**: YYYY-MM-DD
212
+ **Context**: [What is the issue? What constraints exist?]
213
+ **Decision**: [What was decided?]
214
+ **Consequences**: [What are the trade-offs? What becomes easier/harder?]
215
+ **Alternatives Considered**: [What was rejected and why?]
97
216
  ```
98
217
 
99
218
  ---
100
219
 
101
220
  ## Quick Reference
102
221
 
103
- | Pattern | When to Use |
104
- | :------------ | :------------------------------- |
105
- | Monolith | MVP, small team |
106
- | Microservices | Scale, team autonomy |
107
- | Event-Driven | Async, decoupling |
108
- | CQRS | Read/write separation |
109
- | Serverless | Variable load, cost optimization |
222
+ | Pattern | When to Use |
223
+ |:--------|:-----------|
224
+ | Monolith | MVP, small team, simple domain |
225
+ | Modular Monolith | Growing team, clear bounded contexts, not ready for distributed |
226
+ | Microservices | Large team, independent scaling, domain maturity |
227
+ | Event-Driven | Async workflows, decoupling, audit requirements |
228
+ | CQRS | Different read/write patterns, high-traffic reads |
229
+ | Serverless | Variable load, cost optimization, simple functions |
230
+ | Event Sourcing | Audit trail, state reconstruction, complex domain |