opencode-metis 0.1.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/README.md +140 -0
- package/dist/cli.cjs +63 -0
- package/dist/mcp-server.cjs +51 -0
- package/dist/plugin.cjs +4 -0
- package/dist/worker.cjs +224 -0
- package/opencode/agent/the-analyst/feature-prioritization.md +66 -0
- package/opencode/agent/the-analyst/market-research.md +77 -0
- package/opencode/agent/the-analyst/project-coordination.md +81 -0
- package/opencode/agent/the-analyst/requirements-analysis.md +77 -0
- package/opencode/agent/the-architect/compatibility-review.md +138 -0
- package/opencode/agent/the-architect/complexity-review.md +137 -0
- package/opencode/agent/the-architect/quality-review.md +67 -0
- package/opencode/agent/the-architect/security-review.md +127 -0
- package/opencode/agent/the-architect/system-architecture.md +119 -0
- package/opencode/agent/the-architect/system-documentation.md +83 -0
- package/opencode/agent/the-architect/technology-research.md +85 -0
- package/opencode/agent/the-chief.md +79 -0
- package/opencode/agent/the-designer/accessibility-implementation.md +101 -0
- package/opencode/agent/the-designer/design-foundation.md +74 -0
- package/opencode/agent/the-designer/interaction-architecture.md +75 -0
- package/opencode/agent/the-designer/user-research.md +70 -0
- package/opencode/agent/the-meta-agent.md +155 -0
- package/opencode/agent/the-platform-engineer/ci-cd-pipelines.md +109 -0
- package/opencode/agent/the-platform-engineer/containerization.md +106 -0
- package/opencode/agent/the-platform-engineer/data-architecture.md +81 -0
- package/opencode/agent/the-platform-engineer/dependency-review.md +144 -0
- package/opencode/agent/the-platform-engineer/deployment-automation.md +81 -0
- package/opencode/agent/the-platform-engineer/infrastructure-as-code.md +107 -0
- package/opencode/agent/the-platform-engineer/performance-tuning.md +82 -0
- package/opencode/agent/the-platform-engineer/pipeline-engineering.md +81 -0
- package/opencode/agent/the-platform-engineer/production-monitoring.md +105 -0
- package/opencode/agent/the-qa-engineer/exploratory-testing.md +66 -0
- package/opencode/agent/the-qa-engineer/performance-testing.md +81 -0
- package/opencode/agent/the-qa-engineer/quality-assurance.md +77 -0
- package/opencode/agent/the-qa-engineer/test-execution.md +66 -0
- package/opencode/agent/the-software-engineer/api-development.md +78 -0
- package/opencode/agent/the-software-engineer/component-development.md +79 -0
- package/opencode/agent/the-software-engineer/concurrency-review.md +141 -0
- package/opencode/agent/the-software-engineer/domain-modeling.md +66 -0
- package/opencode/agent/the-software-engineer/performance-optimization.md +113 -0
- package/opencode/command/analyze.md +149 -0
- package/opencode/command/constitution.md +178 -0
- package/opencode/command/debug.md +194 -0
- package/opencode/command/document.md +178 -0
- package/opencode/command/implement.md +225 -0
- package/opencode/command/refactor.md +207 -0
- package/opencode/command/review.md +229 -0
- package/opencode/command/simplify.md +267 -0
- package/opencode/command/specify.md +191 -0
- package/opencode/command/validate.md +224 -0
- package/opencode/skill/accessibility-design/SKILL.md +566 -0
- package/opencode/skill/accessibility-design/checklists/wcag-checklist.md +435 -0
- package/opencode/skill/agent-coordination/SKILL.md +224 -0
- package/opencode/skill/api-contract-design/SKILL.md +550 -0
- package/opencode/skill/api-contract-design/templates/graphql-schema-template.md +818 -0
- package/opencode/skill/api-contract-design/templates/rest-api-template.md +417 -0
- package/opencode/skill/architecture-design/SKILL.md +160 -0
- package/opencode/skill/architecture-design/examples/architecture-examples.md +170 -0
- package/opencode/skill/architecture-design/template.md +749 -0
- package/opencode/skill/architecture-design/validation.md +99 -0
- package/opencode/skill/architecture-selection/SKILL.md +522 -0
- package/opencode/skill/architecture-selection/examples/adrs/001-example-adr.md +71 -0
- package/opencode/skill/architecture-selection/examples/architecture-patterns.md +239 -0
- package/opencode/skill/bug-diagnosis/SKILL.md +235 -0
- package/opencode/skill/code-quality-review/SKILL.md +337 -0
- package/opencode/skill/code-quality-review/examples/anti-patterns.md +629 -0
- package/opencode/skill/code-quality-review/reference.md +322 -0
- package/opencode/skill/code-review/SKILL.md +363 -0
- package/opencode/skill/code-review/reference.md +450 -0
- package/opencode/skill/codebase-analysis/SKILL.md +139 -0
- package/opencode/skill/codebase-navigation/SKILL.md +227 -0
- package/opencode/skill/codebase-navigation/examples/exploration-patterns.md +263 -0
- package/opencode/skill/coding-conventions/SKILL.md +178 -0
- package/opencode/skill/coding-conventions/checklists/accessibility-checklist.md +176 -0
- package/opencode/skill/coding-conventions/checklists/performance-checklist.md +154 -0
- package/opencode/skill/coding-conventions/checklists/security-checklist.md +127 -0
- package/opencode/skill/constitution-validation/SKILL.md +315 -0
- package/opencode/skill/constitution-validation/examples/CONSTITUTION.md +202 -0
- package/opencode/skill/constitution-validation/reference/rule-patterns.md +328 -0
- package/opencode/skill/constitution-validation/template.md +115 -0
- package/opencode/skill/context-preservation/SKILL.md +445 -0
- package/opencode/skill/data-modeling/SKILL.md +385 -0
- package/opencode/skill/data-modeling/templates/schema-design-template.md +268 -0
- package/opencode/skill/deployment-pipeline-design/SKILL.md +579 -0
- package/opencode/skill/deployment-pipeline-design/templates/pipeline-template.md +633 -0
- package/opencode/skill/documentation-extraction/SKILL.md +259 -0
- package/opencode/skill/documentation-sync/SKILL.md +431 -0
- package/opencode/skill/domain-driven-design/SKILL.md +509 -0
- package/opencode/skill/domain-driven-design/examples/ddd-patterns.md +688 -0
- package/opencode/skill/domain-driven-design/reference.md +465 -0
- package/opencode/skill/drift-detection/SKILL.md +383 -0
- package/opencode/skill/drift-detection/reference.md +340 -0
- package/opencode/skill/error-recovery/SKILL.md +162 -0
- package/opencode/skill/error-recovery/examples/error-patterns.md +484 -0
- package/opencode/skill/feature-prioritization/SKILL.md +419 -0
- package/opencode/skill/feature-prioritization/examples/rice-template.md +139 -0
- package/opencode/skill/feature-prioritization/reference.md +256 -0
- package/opencode/skill/git-workflow/SKILL.md +453 -0
- package/opencode/skill/implementation-planning/SKILL.md +215 -0
- package/opencode/skill/implementation-planning/examples/phase-examples.md +217 -0
- package/opencode/skill/implementation-planning/template.md +220 -0
- package/opencode/skill/implementation-planning/validation.md +88 -0
- package/opencode/skill/implementation-verification/SKILL.md +272 -0
- package/opencode/skill/knowledge-capture/SKILL.md +265 -0
- package/opencode/skill/knowledge-capture/reference/knowledge-capture.md +402 -0
- package/opencode/skill/knowledge-capture/reference.md +444 -0
- package/opencode/skill/knowledge-capture/templates/domain-template.md +325 -0
- package/opencode/skill/knowledge-capture/templates/interface-template.md +255 -0
- package/opencode/skill/knowledge-capture/templates/pattern-template.md +144 -0
- package/opencode/skill/observability-design/SKILL.md +291 -0
- package/opencode/skill/observability-design/references/monitoring-patterns.md +461 -0
- package/opencode/skill/pattern-detection/SKILL.md +171 -0
- package/opencode/skill/pattern-detection/examples/common-patterns.md +359 -0
- package/opencode/skill/performance-analysis/SKILL.md +266 -0
- package/opencode/skill/performance-analysis/references/profiling-tools.md +499 -0
- package/opencode/skill/requirements-analysis/SKILL.md +139 -0
- package/opencode/skill/requirements-analysis/examples/good-prd.md +66 -0
- package/opencode/skill/requirements-analysis/template.md +177 -0
- package/opencode/skill/requirements-analysis/validation.md +69 -0
- package/opencode/skill/requirements-elicitation/SKILL.md +518 -0
- package/opencode/skill/requirements-elicitation/examples/interview-questions.md +226 -0
- package/opencode/skill/requirements-elicitation/examples/user-stories.md +414 -0
- package/opencode/skill/safe-refactoring/SKILL.md +312 -0
- package/opencode/skill/safe-refactoring/reference/code-smells.md +347 -0
- package/opencode/skill/security-assessment/SKILL.md +421 -0
- package/opencode/skill/security-assessment/checklists/security-review-checklist.md +285 -0
- package/opencode/skill/specification-management/SKILL.md +143 -0
- package/opencode/skill/specification-management/readme-template.md +32 -0
- package/opencode/skill/specification-management/reference.md +115 -0
- package/opencode/skill/specification-management/spec.py +229 -0
- package/opencode/skill/specification-validation/SKILL.md +397 -0
- package/opencode/skill/specification-validation/reference/3cs-framework.md +306 -0
- package/opencode/skill/specification-validation/reference/ambiguity-detection.md +132 -0
- package/opencode/skill/specification-validation/reference/constitution-validation.md +301 -0
- package/opencode/skill/specification-validation/reference/drift-detection.md +383 -0
- package/opencode/skill/task-delegation/SKILL.md +607 -0
- package/opencode/skill/task-delegation/examples/file-coordination.md +495 -0
- package/opencode/skill/task-delegation/examples/parallel-research.md +337 -0
- package/opencode/skill/task-delegation/examples/sequential-build.md +504 -0
- package/opencode/skill/task-delegation/reference.md +825 -0
- package/opencode/skill/tech-stack-detection/SKILL.md +89 -0
- package/opencode/skill/tech-stack-detection/references/framework-signatures.md +598 -0
- package/opencode/skill/technical-writing/SKILL.md +190 -0
- package/opencode/skill/technical-writing/templates/adr-template.md +205 -0
- package/opencode/skill/technical-writing/templates/system-doc-template.md +380 -0
- package/opencode/skill/test-design/SKILL.md +464 -0
- package/opencode/skill/test-design/examples/test-pyramid.md +724 -0
- package/opencode/skill/testing/SKILL.md +213 -0
- package/opencode/skill/testing/examples/test-pyramid.md +724 -0
- package/opencode/skill/user-insight-synthesis/SKILL.md +576 -0
- package/opencode/skill/user-insight-synthesis/templates/research-plan-template.md +217 -0
- package/opencode/skill/user-research/SKILL.md +508 -0
- package/opencode/skill/user-research/examples/interview-questions.md +265 -0
- package/opencode/skill/user-research/examples/personas.md +267 -0
- package/opencode/skill/vibe-security/SKILL.md +654 -0
- package/package.json +45 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# ADR-001: Use PostgreSQL as the Primary Datastore
|
|
2
|
+
|
|
3
|
+
## Status
|
|
4
|
+
|
|
5
|
+
Accepted
|
|
6
|
+
|
|
7
|
+
## Context
|
|
8
|
+
|
|
9
|
+
The platform needs a primary datastore for user accounts, orders, products, and inventory. The data is relational: orders reference users and products, inventory adjustments are tied to orders, and reporting requires joins across multiple entities.
|
|
10
|
+
|
|
11
|
+
The team evaluated options against the following constraints:
|
|
12
|
+
|
|
13
|
+
- ACID transactions are required. An order creation must atomically decrement inventory and record the order — partial failures are not acceptable.
|
|
14
|
+
- The schema is not yet fully stabilized. Early product development will produce migrations frequently.
|
|
15
|
+
- The team has strong SQL skills but limited experience with document or wide-column stores.
|
|
16
|
+
- The system is expected to serve up to 10,000 requests per minute within the first 18 months, based on growth projections.
|
|
17
|
+
- Hosting budget is approximately $500/month for infrastructure at launch.
|
|
18
|
+
|
|
19
|
+
Three options were evaluated: PostgreSQL, MongoDB, and DynamoDB.
|
|
20
|
+
|
|
21
|
+
## Decision
|
|
22
|
+
|
|
23
|
+
Use PostgreSQL as the primary datastore, hosted on AWS RDS with a single read replica.
|
|
24
|
+
|
|
25
|
+
The decision is based on:
|
|
26
|
+
|
|
27
|
+
1. **Transactional correctness.** PostgreSQL provides full ACID transactions across tables. The order creation workflow (insert order, decrement inventory, record payment intent) requires this. MongoDB offers multi-document transactions since 4.0 but they carry a performance penalty and require deliberate session management that the team is not familiar with. DynamoDB transactions are limited to 25 items and do not generalize well to the relational access patterns of this domain.
|
|
28
|
+
|
|
29
|
+
2. **Team fluency.** All five developers on the current team have production PostgreSQL experience. MongoDB and DynamoDB would require a ramp-up period and introduce risk during the critical early launch phase.
|
|
30
|
+
|
|
31
|
+
3. **Relational access patterns.** Reporting requirements include queries like "orders by user with product details and shipment status." These are natural SQL joins. Document stores require either embedding (which causes data duplication) or application-level joins (which push complexity into service code).
|
|
32
|
+
|
|
33
|
+
4. **Operational familiarity.** RDS for PostgreSQL has predictable operational characteristics, automated backups, and point-in-time recovery. The team knows how to monitor, tune, and migrate it. DynamoDB's capacity planning model (provisioned vs. on-demand) and partition key selection require specialized knowledge to get right.
|
|
34
|
+
|
|
35
|
+
5. **Cost.** An RDS `db.t3.medium` instance with a read replica comes to approximately $180/month. DynamoDB costs are harder to predict at unknown access volumes. MongoDB Atlas at comparable durability settings costs approximately $250/month.
|
|
36
|
+
|
|
37
|
+
## Consequences
|
|
38
|
+
|
|
39
|
+
### Positive
|
|
40
|
+
|
|
41
|
+
- Developers can write and review schema changes using standard SQL migrations (using golang-migrate).
|
|
42
|
+
- ACID transactions eliminate a class of consistency bugs that would require compensating transactions or saga patterns with other datastores.
|
|
43
|
+
- Rich query capabilities mean reporting can be done directly against the database without an ETL pipeline or separate analytics store for the first year.
|
|
44
|
+
- Read replica allows reporting queries to be routed off the primary, protecting transactional write performance.
|
|
45
|
+
- pgvector extension is available if the product roadmap adds semantic search or recommendation features.
|
|
46
|
+
|
|
47
|
+
### Negative
|
|
48
|
+
|
|
49
|
+
- PostgreSQL is not horizontally scalable for writes. If write throughput exceeds what a single primary can handle, the migration path is complex: sharding, moving to CockroachDB, or extracting high-write domains into separate services with their own datastores.
|
|
50
|
+
- The schema is a shared artifact. All services that evolve from this monolith will need to coordinate schema migrations or extract their own databases — this is a known constraint of the modular monolith starting point.
|
|
51
|
+
- Full-text search capabilities are limited compared to a dedicated search engine. If product search becomes a core user experience feature, Elasticsearch or OpenSearch will need to be introduced.
|
|
52
|
+
- Column-oriented queries (large aggregations over historical data) will be slow at scale. A columnar store or materialized views will be needed for analytics beyond the first year.
|
|
53
|
+
|
|
54
|
+
### Neutral
|
|
55
|
+
|
|
56
|
+
- PostgreSQL's connection-per-process model requires connection pooling (PgBouncer or RDS Proxy) before the application scales to more than ~100 concurrent application instances.
|
|
57
|
+
- JSON/JSONB columns are available for semi-structured data, but using them to avoid schema definition should be treated as a deliberate trade-off, not a default, since it sacrifices query performance and type safety.
|
|
58
|
+
|
|
59
|
+
## Alternatives Considered
|
|
60
|
+
|
|
61
|
+
### MongoDB Atlas
|
|
62
|
+
|
|
63
|
+
- Pros: Flexible schema useful during early product discovery; horizontal write scaling via sharding; native document model fits product catalog with variable attribute sets.
|
|
64
|
+
- Cons: Multi-document transactions add complexity to the order creation workflow; team has no production MongoDB experience; costs more at equivalent durability; joins require application-level code.
|
|
65
|
+
- Why rejected: The consistency requirements of the financial transaction workflow outweigh the schema flexibility benefits. The team would spend more time learning the operational model than building product.
|
|
66
|
+
|
|
67
|
+
### DynamoDB
|
|
68
|
+
|
|
69
|
+
- Pros: Fully managed with no connection limits; seamlessly handles unpredictable traffic spikes; pay-per-use pricing works well for uncertain early workloads.
|
|
70
|
+
- Cons: Requires upfront access pattern design that is difficult to change later; no ad hoc queries; 25-item transaction limit does not fit the domain; requires DynamoDB-specific expertise for capacity planning and key design.
|
|
71
|
+
- Why rejected: The rigid access pattern requirement makes it unsuitable for a domain in early discovery. The cost of a wrong key design is a full table rebuild. PostgreSQL's flexibility is worth paying for at this stage.
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Architecture Patterns: Decision Guide
|
|
2
|
+
|
|
3
|
+
Practical catalog of architectural patterns with trade-offs. Use this alongside the pattern selection table in SKILL.md. Each entry answers the two questions that matter most: when to reach for this pattern, and when to avoid it.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Monolith
|
|
8
|
+
|
|
9
|
+
A single deployable unit. All modules share the same process, memory space, and database.
|
|
10
|
+
|
|
11
|
+
**Reach for this when:**
|
|
12
|
+
- Team is under 10 developers sharing the same codebase
|
|
13
|
+
- Domain is not yet well understood — premature decomposition locks in wrong boundaries
|
|
14
|
+
- Time to first working product is the dominant constraint
|
|
15
|
+
- Infrastructure expertise is limited or unavailable
|
|
16
|
+
- Transactions must be ACID across what would otherwise be service boundaries
|
|
17
|
+
|
|
18
|
+
**Do not use when:**
|
|
19
|
+
- Multiple teams need to deploy independently without coordinating releases
|
|
20
|
+
- Different parts of the system have wildly different scaling profiles (e.g., file uploads vs. real-time feeds)
|
|
21
|
+
- You need polyglot persistence (each domain using its most appropriate database)
|
|
22
|
+
- The codebase is already too large to hold in one developer's head
|
|
23
|
+
|
|
24
|
+
**Scaling characteristics:**
|
|
25
|
+
- Scale by cloning the entire application behind a load balancer
|
|
26
|
+
- All modules scale together regardless of where the bottleneck actually is
|
|
27
|
+
- Database becomes the bottleneck first; address with read replicas and caching before reaching for microservices
|
|
28
|
+
- Practical ceiling: tens of millions of requests per day with a well-tuned monolith on modern hardware
|
|
29
|
+
|
|
30
|
+
**Team size fit:** 1–10 developers
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Modular Monolith
|
|
35
|
+
|
|
36
|
+
A monolith with enforced internal module boundaries. Modules own their data and expose explicit interfaces to each other. No shared tables. No calling into another module's internals.
|
|
37
|
+
|
|
38
|
+
**Reach for this when:**
|
|
39
|
+
- You want the operational simplicity of a monolith but are building toward future service extraction
|
|
40
|
+
- Domain boundaries are becoming clearer but you are not ready to pay the operational cost of microservices
|
|
41
|
+
- Team is growing (10–20 developers) and you need to reduce coordination overhead without splitting deployment
|
|
42
|
+
- You have been burned by a big ball of mud monolith and want structure without the distributed systems tax
|
|
43
|
+
|
|
44
|
+
**Do not use when:**
|
|
45
|
+
- Teams genuinely need independent deployment pipelines today
|
|
46
|
+
- Module isolation is not enforced by tooling — without enforcement, boundaries erode under deadline pressure
|
|
47
|
+
- Scaling requirements are already differentiated between modules
|
|
48
|
+
|
|
49
|
+
**Scaling characteristics:**
|
|
50
|
+
- Same ceiling as a monolith: scale by replication
|
|
51
|
+
- Module isolation makes it significantly easier to extract a service later when a specific module becomes the bottleneck
|
|
52
|
+
- The database is still shared at the infrastructure level even if modules have schema ownership
|
|
53
|
+
|
|
54
|
+
**Team size fit:** 5–25 developers
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Microservices
|
|
59
|
+
|
|
60
|
+
Independent services each owning a bounded context, deployed and scaled separately.
|
|
61
|
+
|
|
62
|
+
**Reach for this when:**
|
|
63
|
+
- Multiple autonomous teams need to ship independently without release coordination
|
|
64
|
+
- Scaling needs are genuinely differentiated: the checkout service needs 50x more capacity than the admin dashboard
|
|
65
|
+
- Different services have legitimately different technology requirements (streaming processing vs. CRUD vs. ML inference)
|
|
66
|
+
- The domain is well understood and bounded contexts are stable — wrong boundaries are expensive to fix later
|
|
67
|
+
- High availability is a hard requirement: a failure in recommendations must not take down checkout
|
|
68
|
+
|
|
69
|
+
**Do not use when:**
|
|
70
|
+
- Team is under 20 developers — you will spend more time on distributed systems plumbing than on product
|
|
71
|
+
- Domain boundaries are still being discovered — wait until the seams are clear
|
|
72
|
+
- The team lacks experience with distributed systems, container orchestration, service meshes, and observability
|
|
73
|
+
- Transactions must be strongly consistent across what would be service boundaries — distributed sagas are a significant complexity investment
|
|
74
|
+
- You are starting a new product — the monolith-first rule exists for good reason
|
|
75
|
+
|
|
76
|
+
**Scaling characteristics:**
|
|
77
|
+
- Scale individual services independently based on measured demand
|
|
78
|
+
- Each service can adopt the database technology that fits its access patterns
|
|
79
|
+
- Horizontal scaling at the service level; the API gateway and message bus become new bottlenecks to manage
|
|
80
|
+
- Requires investment in service discovery, load balancing, distributed tracing, and centralized logging
|
|
81
|
+
|
|
82
|
+
**Team size fit:** 20+ developers, organized into product teams aligned to service ownership
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Event-Driven Architecture
|
|
87
|
+
|
|
88
|
+
Services communicate by publishing and subscribing to events on a message broker. No direct synchronous calls between services for primary workflows.
|
|
89
|
+
|
|
90
|
+
**Reach for this when:**
|
|
91
|
+
- Workflows span multiple services and you cannot afford to couple their availability
|
|
92
|
+
- You need a durable audit trail of everything that has happened in the system
|
|
93
|
+
- Processing is inherently asynchronous: order fulfillment, email delivery, report generation
|
|
94
|
+
- You need to replay historical events to rebuild state or feed new downstream consumers
|
|
95
|
+
- Fan-out is natural: one event (OrderPlaced) needs to trigger actions in multiple independent systems
|
|
96
|
+
|
|
97
|
+
**Do not use when:**
|
|
98
|
+
- The user needs a synchronous response to complete their action — eventual consistency is a user experience trade-off, not just a technical one
|
|
99
|
+
- The team has no experience operating a message broker under production load
|
|
100
|
+
- The domain has complex ordering requirements that are difficult to enforce across independent consumers
|
|
101
|
+
- Debugging and distributed tracing tooling is not in place — event-driven systems are significantly harder to debug without it
|
|
102
|
+
|
|
103
|
+
**Scaling characteristics:**
|
|
104
|
+
- Producers and consumers scale independently
|
|
105
|
+
- The message broker (Kafka, RabbitMQ, SQS) becomes the critical scaling and reliability component
|
|
106
|
+
- Consumer groups allow parallel processing of event streams
|
|
107
|
+
- Backpressure is managed through queue depth monitoring and consumer scaling policies
|
|
108
|
+
|
|
109
|
+
**Team size fit:** Any size, but requires operational maturity. Do not introduce event-driven patterns without investing in observability first.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## CQRS (Command Query Responsibility Segregation)
|
|
114
|
+
|
|
115
|
+
Separate models for write operations (commands) and read operations (queries). Often paired with event sourcing but does not require it.
|
|
116
|
+
|
|
117
|
+
**Reach for this when:**
|
|
118
|
+
- Read and write access patterns are fundamentally different: complex reporting queries on the same data used for transactional writes
|
|
119
|
+
- The read model needs to be denormalized for performance but the write model needs normalization for consistency
|
|
120
|
+
- Read throughput is orders of magnitude higher than write throughput
|
|
121
|
+
- You need multiple specialized read models from the same underlying data (e.g., search index, reporting database, and API response shape)
|
|
122
|
+
|
|
123
|
+
**Do not use when:**
|
|
124
|
+
- The domain is simple CRUD — CQRS adds complexity without benefit
|
|
125
|
+
- The team is not prepared to handle eventual consistency between the write and read sides
|
|
126
|
+
- You are in early product discovery — CQRS optimizes for a usage pattern you may not have confirmed yet
|
|
127
|
+
- Event sourcing is not in scope and the synchronization strategy between write and read stores has not been designed
|
|
128
|
+
|
|
129
|
+
**Scaling characteristics:**
|
|
130
|
+
- Read and write sides scale independently
|
|
131
|
+
- Read models can be replicated aggressively since they are derived, not authoritative
|
|
132
|
+
- Write side remains the consistency bottleneck; scale cautiously and measure before sharding
|
|
133
|
+
- Projection lag (time between a write and the read model reflecting it) must be measured and communicated to users where it matters
|
|
134
|
+
|
|
135
|
+
**Team size fit:** 5–50 developers, in systems where read/write asymmetry has been measured
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Hexagonal Architecture (Ports and Adapters)
|
|
140
|
+
|
|
141
|
+
The application core contains pure business logic with no framework or infrastructure dependencies. All external concerns (HTTP, databases, message queues, external APIs) connect through defined ports implemented by adapters.
|
|
142
|
+
|
|
143
|
+
**Reach for this when:**
|
|
144
|
+
- Business logic must be testable in isolation without spinning up databases or HTTP servers
|
|
145
|
+
- You need to swap infrastructure implementations: test database vs. production, email adapter vs. SMS adapter
|
|
146
|
+
- The domain is complex and protecting it from framework churn is a priority
|
|
147
|
+
- The team is practicing DDD and needs a clear boundary between domain and infrastructure
|
|
148
|
+
|
|
149
|
+
**Do not use when:**
|
|
150
|
+
- The application is primarily CRUD with little business logic — the overhead of ports and adapters is not justified
|
|
151
|
+
- The team is unfamiliar with the pattern — misapplied hexagonal architecture produces more abstractions than value
|
|
152
|
+
- Rapid prototyping is the goal — the pattern slows initial development in exchange for long-term maintainability
|
|
153
|
+
|
|
154
|
+
**Scaling characteristics:**
|
|
155
|
+
- The pattern is architectural, not a scaling strategy
|
|
156
|
+
- Infrastructure adapters can be swapped to use scaling-oriented implementations (e.g., swap in-memory queue adapter for SQS) without changing the domain
|
|
157
|
+
- Enables independent testing of scaling scenarios at the adapter level
|
|
158
|
+
|
|
159
|
+
**Team size fit:** Any size. Most valuable on teams of 5+ working on complex domains. Not worth the overhead for scripts or simple CRUD services.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Serverless
|
|
164
|
+
|
|
165
|
+
Business logic runs as short-lived functions invoked by events or HTTP requests. The platform manages all server provisioning, scaling, and availability.
|
|
166
|
+
|
|
167
|
+
**Reach for this when:**
|
|
168
|
+
- Workload is irregular or spiky — pay for actual execution time, not idle capacity
|
|
169
|
+
- Operations are event-triggered: file uploaded, webhook received, scheduled job
|
|
170
|
+
- Functions are short-lived (under 15 minutes) and stateless
|
|
171
|
+
- Time to production is the dominant constraint and the team cannot afford infrastructure management
|
|
172
|
+
- Cost optimization for low-traffic workloads is a priority
|
|
173
|
+
|
|
174
|
+
**Do not use when:**
|
|
175
|
+
- Operations are long-running or require persistent in-memory state
|
|
176
|
+
- Cold start latency is unacceptable for user-facing requests (sub-100ms response time requirements)
|
|
177
|
+
- Local development and testing parity with production is critical — serverless local emulation is imperfect
|
|
178
|
+
- Vendor lock-in is a hard constraint — serverless functions are deeply coupled to platform-specific runtimes and event formats
|
|
179
|
+
- The system has complex inter-function orchestration — function chaining becomes a debugging and reliability problem
|
|
180
|
+
|
|
181
|
+
**Scaling characteristics:**
|
|
182
|
+
- Scales to zero when idle — no cost for unused capacity
|
|
183
|
+
- Scales to thousands of concurrent invocations automatically
|
|
184
|
+
- Concurrency limits are platform-enforced and can cause throttling at high traffic without reserved concurrency configuration
|
|
185
|
+
- The database connection problem: functions scale to thousands; databases have connection limits. Use connection poolers (RDS Proxy, PgBouncer) or serverless-native databases (DynamoDB, Aurora Serverless)
|
|
186
|
+
|
|
187
|
+
**Team size fit:** 1–20 developers, particularly effective for small teams that cannot staff platform/infrastructure roles
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Layered Architecture (N-Tier)
|
|
192
|
+
|
|
193
|
+
Code organized into horizontal layers: Presentation, Application/Business Logic, Data Access. Each layer only communicates with the layer directly below it.
|
|
194
|
+
|
|
195
|
+
**Reach for this when:**
|
|
196
|
+
- Building a traditional web application where the layered model is well understood by the team
|
|
197
|
+
- Enforcing separation between UI, business logic, and data access is the primary goal
|
|
198
|
+
- The domain is not complex enough to warrant DDD but you still want structure
|
|
199
|
+
- The team is early-career or coming from frameworks (Spring, ASP.NET, Django) that naturally express this structure
|
|
200
|
+
|
|
201
|
+
**Do not use when:**
|
|
202
|
+
- Business logic needs to be tested in isolation without the data access layer — strict layering often causes domain logic to be expressed in terms of database rows rather than business concepts
|
|
203
|
+
- The architecture needs to evolve toward hexagonal or DDD — layered architecture is harder to refactor than ports and adapters
|
|
204
|
+
- The "layer" boundaries become a ritual rather than a structural constraint — teams often skip layers or create anemic domain models where business logic leaks into controllers
|
|
205
|
+
|
|
206
|
+
**Scaling characteristics:**
|
|
207
|
+
- The same scaling constraints as a monolith apply
|
|
208
|
+
- Each tier can in principle be scaled independently (stateless presentation tier, application server pool, database)
|
|
209
|
+
- In practice, the data layer is the constraint and the pattern does not provide meaningful tools for addressing it
|
|
210
|
+
|
|
211
|
+
**Team size fit:** 1–15 developers, particularly teams starting with a framework-centric approach
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Pattern Comparison at a Glance
|
|
216
|
+
|
|
217
|
+
| Pattern | Operational Complexity | Time to First Feature | Long-Term Maintainability | Scaling Ceiling |
|
|
218
|
+
|---|---|---|---|---|
|
|
219
|
+
| Monolith | Low | Fast | Medium | Medium |
|
|
220
|
+
| Modular Monolith | Low | Medium | High | Medium |
|
|
221
|
+
| Microservices | High | Slow | High (with discipline) | High |
|
|
222
|
+
| Event-Driven | High | Medium | High (with tooling) | High |
|
|
223
|
+
| CQRS | Medium | Slow | High | High |
|
|
224
|
+
| Hexagonal | Low | Medium | High | N/A (architectural) |
|
|
225
|
+
| Serverless | Low | Fast | Medium | High |
|
|
226
|
+
| Layered | Low | Fast | Low-Medium | Medium |
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## The Default Path
|
|
231
|
+
|
|
232
|
+
When in doubt, follow this sequence:
|
|
233
|
+
|
|
234
|
+
1. Start with a **modular monolith** using hexagonal architecture internally
|
|
235
|
+
2. Extract services only when a specific module has a scaling or deployment independence requirement that is measured, not anticipated
|
|
236
|
+
3. Introduce event-driven communication at service boundaries when synchronous coupling becomes a reliability risk
|
|
237
|
+
4. Add CQRS to specific modules when read/write asymmetry is measured and causing problems
|
|
238
|
+
|
|
239
|
+
Premature decomposition is the most common architecture mistake. The cost of splitting a well-structured monolith is low. The cost of merging a poorly-bounded microservices system is very high.
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bug-diagnosis
|
|
3
|
+
description: "Scientific debugging methodology through conversational investigation, hypothesis testing, and root cause analysis"
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: opencode
|
|
6
|
+
metadata:
|
|
7
|
+
category: development
|
|
8
|
+
version: "1.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Bug Diagnosis
|
|
12
|
+
|
|
13
|
+
Roleplay as a debugging methodology specialist that applies the scientific method to systematically diagnose and resolve bugs through natural conversation.
|
|
14
|
+
|
|
15
|
+
BugDiagnosis {
|
|
16
|
+
Activation {
|
|
17
|
+
When investigating error messages or stack traces
|
|
18
|
+
When diagnosing logic errors or wrong output
|
|
19
|
+
When troubleshooting integration failures
|
|
20
|
+
When debugging timing or async issues
|
|
21
|
+
When analyzing intermittent or flaky behavior
|
|
22
|
+
When investigating performance degradation
|
|
23
|
+
When resolving environment-specific issues
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Constraints {
|
|
27
|
+
ObservableActionsOnly {
|
|
28
|
+
Report only what you actually verified
|
|
29
|
+
State what you read, ran, or traced
|
|
30
|
+
- "I read auth/service.ts line 47 and found..."
|
|
31
|
+
- "I ran npm test and saw 3 failures"
|
|
32
|
+
- "I checked git log and found this file was last modified 2 days ago"
|
|
33
|
+
When you have not checked something, be honest: "I haven't looked at X yet."
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
ProgressiveDisclosure {
|
|
37
|
+
Start brief
|
|
38
|
+
Expand on request
|
|
39
|
+
Reveal detail incrementally
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
UserInControl {
|
|
43
|
+
Propose actions and await user decision
|
|
44
|
+
"Want me to...?" as proposal pattern
|
|
45
|
+
Never assume consent
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
DebuggingTruths {
|
|
49
|
+
The bug is always logical -- computers do exactly what code tells them
|
|
50
|
+
Most bugs are simpler than they first appear
|
|
51
|
+
If you cannot explain what you found, you have not found it yet
|
|
52
|
+
Intermittent bugs have deterministic causes not yet identified
|
|
53
|
+
Transparency builds trust
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
BugTypeInvestigation {
|
|
58
|
+
Evaluate the bug description. First match determines initial investigation focus.
|
|
59
|
+
|
|
60
|
+
| Bug Type | What to Investigate | Reporting Pattern |
|
|
61
|
+
|----------|---------------------|-------------------|
|
|
62
|
+
| Error message / stack trace | Error propagation, exception handling, error origin | "The error originates at X because Y" |
|
|
63
|
+
| Logic error / wrong output | Data flow, boundary conditions, conditional branches | "The condition on line X doesn't handle case Y" |
|
|
64
|
+
| Integration failure | API contracts, versions, request/response shapes | "The API expects X but we're sending Y" |
|
|
65
|
+
| Timing / async issue | Race conditions, await handling, event ordering | "There's a race between A and B" |
|
|
66
|
+
| Intermittent / flaky | Variable conditions, state leaks, concurrency | "This fails when [condition] because [reason]" |
|
|
67
|
+
| Performance degradation | Resource leaks, algorithm complexity, blocking ops | "The bottleneck is at X causing Y" |
|
|
68
|
+
| Environment-specific | Configuration, dependency versions, platform diffs | "The config differs: prod has X, local has Y" |
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
InvestigationPerspectives {
|
|
72
|
+
For complex bugs, investigate from multiple angles to test competing hypotheses
|
|
73
|
+
|
|
74
|
+
| Perspective | Intent | What to Investigate |
|
|
75
|
+
|-------------|--------|---------------------|
|
|
76
|
+
| Error Trace | Follow the error path | Stack traces, error messages, exception handling, error propagation |
|
|
77
|
+
| Code Path | Trace execution flow | Conditional branches, data transformations, control flow, early returns |
|
|
78
|
+
| Dependencies | Check external factors | External services, database queries, API calls, network issues |
|
|
79
|
+
| State | Inspect runtime values | Variable values, object states, race conditions, timing issues |
|
|
80
|
+
| Environment | Compare contexts | Configuration, versions, deployment differences, env variables |
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
InvestigationTechniques {
|
|
84
|
+
| Technique | Commands / Approach |
|
|
85
|
+
|-----------|---------------------|
|
|
86
|
+
| Log and Error Analysis | Check application logs, parse stack traces, correlate timestamps |
|
|
87
|
+
| Code Investigation | `git log -p <file>`, `git bisect`, trace execution paths |
|
|
88
|
+
| Runtime Debugging | Strategic logging, debugger breakpoints, inspect variable state |
|
|
89
|
+
| Environment Checks | Verify config consistency, check dependency versions, compare environments |
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
InvestigationTaskTemplate {
|
|
93
|
+
For each perspective, describe the investigation intent:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
Investigate [PERSPECTIVE] for bug:
|
|
97
|
+
|
|
98
|
+
CONTEXT:
|
|
99
|
+
- Bug: [Error description, symptoms]
|
|
100
|
+
- Reproduction: [Steps to reproduce]
|
|
101
|
+
- Environment: [Where it occurs]
|
|
102
|
+
|
|
103
|
+
FOCUS: [What this perspective investigates -- from perspectives table]
|
|
104
|
+
|
|
105
|
+
OUTPUT: Findings formatted as:
|
|
106
|
+
area: [Investigation Area]
|
|
107
|
+
location: file:line
|
|
108
|
+
checked: [What was verified]
|
|
109
|
+
result: FOUND | CLEAR
|
|
110
|
+
detail: [Evidence discovered] OR [No issues found]
|
|
111
|
+
hypothesis: [What this suggests]
|
|
112
|
+
```
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
Workflow {
|
|
116
|
+
Phase1_UnderstandTheProblem {
|
|
117
|
+
1. Acknowledge the bug
|
|
118
|
+
2. Perform initial investigation (check git status, look for obvious errors)
|
|
119
|
+
3. Classify bug type using the Bug Type Investigation table
|
|
120
|
+
4. Present brief summary, invite user direction:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
"I see you're hitting [brief symptom summary]. Let me take a quick look..."
|
|
124
|
+
|
|
125
|
+
[Investigation results]
|
|
126
|
+
|
|
127
|
+
"Here's what I found so far: [1-2 sentence summary]
|
|
128
|
+
|
|
129
|
+
Want me to dig deeper, or can you tell me more about when this started?"
|
|
130
|
+
```
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
Phase2_NarrowItDown {
|
|
134
|
+
Form hypotheses, track internally with todowrite
|
|
135
|
+
Present theories conversationally:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
"I have a couple of theories:
|
|
139
|
+
1. [Most likely] - because I saw [evidence]
|
|
140
|
+
2. [Alternative] - though this seems less likely
|
|
141
|
+
|
|
142
|
+
Want me to dig into the first one?"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Let user guide next investigation direction
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
Phase3_FindTheRootCause {
|
|
149
|
+
Trace execution, gather specific evidence
|
|
150
|
+
Present finding with specific code reference (file:line):
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
"Found it. In [file:line], [describe what's wrong].
|
|
154
|
+
|
|
155
|
+
[Show only relevant code, not walls of text]
|
|
156
|
+
|
|
157
|
+
The problem: [one sentence explanation]
|
|
158
|
+
|
|
159
|
+
Should I fix this, or do you want to discuss the approach first?"
|
|
160
|
+
```
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
Phase4_FixAndVerify {
|
|
164
|
+
1. Propose minimal fix, get user approval:
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
"Here's what I'd change:
|
|
168
|
+
|
|
169
|
+
[Show the proposed fix -- just the relevant diff]
|
|
170
|
+
|
|
171
|
+
This fixes it by [brief explanation].
|
|
172
|
+
|
|
173
|
+
Want me to apply this?"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
2. After approval: Apply change, run tests
|
|
177
|
+
3. Report actual results honestly:
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
"Applied the fix. Tests are passing now.
|
|
181
|
+
|
|
182
|
+
Can you verify on your end?"
|
|
183
|
+
```
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
Phase5_WrapUp {
|
|
187
|
+
Quick closure by default: "All done! Anything else?"
|
|
188
|
+
Detailed summary only if user asks
|
|
189
|
+
Offer follow-ups without pushing:
|
|
190
|
+
- "Should I add a test case for this?"
|
|
191
|
+
- "Want me to check if this pattern exists elsewhere?"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
WhenStuck {
|
|
196
|
+
Be honest:
|
|
197
|
+
```
|
|
198
|
+
"I've looked at [what you checked] but haven't pinpointed it yet.
|
|
199
|
+
|
|
200
|
+
A few options:
|
|
201
|
+
- I could check [alternative area]
|
|
202
|
+
- You could tell me more about [specific question]
|
|
203
|
+
- We could take a different angle
|
|
204
|
+
|
|
205
|
+
What sounds most useful?"
|
|
206
|
+
```
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
AdversarialInvestigation {
|
|
210
|
+
For complex bugs with multiple competing hypotheses:
|
|
211
|
+
|
|
212
|
+
1. Map evidence: for each hypothesis, list supporting and refuting evidence
|
|
213
|
+
2. Score: hypotheses with more supporting evidence and fewer successful challenges rank higher
|
|
214
|
+
3. Identify the survivor: the hypothesis that withstood the most scrutiny
|
|
215
|
+
4. Build evidence chain: symptom -> evidence -> root cause
|
|
216
|
+
|
|
217
|
+
Present conversationally: winning hypothesis with evidence, runner-up, ruled-out theories, the smoking gun
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
HypothesisTracking {
|
|
221
|
+
Use todowrite internally to track:
|
|
222
|
+
- Hypotheses formed with supporting evidence
|
|
223
|
+
- What was checked and what was found
|
|
224
|
+
- What was ruled out and why
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
FixProtocol {
|
|
228
|
+
1. Propose fix with explanation
|
|
229
|
+
2. Get user approval
|
|
230
|
+
3. Apply minimal change
|
|
231
|
+
4. Run tests
|
|
232
|
+
5. Report honest results
|
|
233
|
+
6. Ask user to verify
|
|
234
|
+
}
|
|
235
|
+
}
|