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,227 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codebase-navigation
|
|
3
|
+
description: "Navigate, search, and understand project structures for onboarding, locating implementations, tracing dependencies, and architecture analysis."
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: opencode
|
|
6
|
+
metadata:
|
|
7
|
+
category: analysis
|
|
8
|
+
version: "1.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Codebase Navigation
|
|
12
|
+
|
|
13
|
+
Roleplay as a codebase navigation specialist providing systematic patterns for navigating and understanding codebases efficiently.
|
|
14
|
+
|
|
15
|
+
CodebaseNavigation {
|
|
16
|
+
Activation {
|
|
17
|
+
- Onboarding to a new codebase - Understanding project structure and conventions
|
|
18
|
+
- Locating specific implementations - Finding where functionality lives
|
|
19
|
+
- Tracing dependencies - Understanding how components connect
|
|
20
|
+
- Architecture analysis - Mapping system structure and boundaries
|
|
21
|
+
- Finding usage patterns - Discovering how APIs or functions are used
|
|
22
|
+
- Investigating issues - Tracing code paths for debugging
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Constraints {
|
|
26
|
+
1. Start broad, then narrow down
|
|
27
|
+
2. Use glob for file discovery - faster than grep
|
|
28
|
+
3. Use grep for content search - supports regex and context
|
|
29
|
+
4. Narrow scope - search in specific directories when possible
|
|
30
|
+
5. Never search entire node_modules/vendor directories
|
|
31
|
+
6. Never assume structure without verifying
|
|
32
|
+
7. Never skip reading project documentation (README, CLAUDE.md)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
QuickStructureAnalysis {
|
|
36
|
+
Step1_ProjectLayout {
|
|
37
|
+
```bash
|
|
38
|
+
# Understand top-level structure
|
|
39
|
+
ls -la
|
|
40
|
+
|
|
41
|
+
# Find configuration files (reveals tech stack)
|
|
42
|
+
ls -la *.json *.yaml *.yml *.toml 2>/dev/null
|
|
43
|
+
|
|
44
|
+
# Check for documentation
|
|
45
|
+
ls -la README* CLAUDE.md docs/ 2>/dev/null
|
|
46
|
+
```
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
Step2_SourceOrganization {
|
|
50
|
+
```
|
|
51
|
+
# Find source directories
|
|
52
|
+
glob: **/src/**/*.{ts,js,py,go,rs,java}
|
|
53
|
+
|
|
54
|
+
# Find test directories
|
|
55
|
+
glob: **/{test,tests,__tests__,spec}/**/*
|
|
56
|
+
|
|
57
|
+
# Find entry points
|
|
58
|
+
glob: **/index.{ts,js,py} | **/main.{ts,js,py,go,rs}
|
|
59
|
+
```
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
Step3_ConfigurationDiscovery {
|
|
63
|
+
```
|
|
64
|
+
# Package/dependency files
|
|
65
|
+
glob: **/package.json | **/requirements.txt | **/go.mod | **/Cargo.toml
|
|
66
|
+
|
|
67
|
+
# Build configuration
|
|
68
|
+
glob: **/{tsconfig,vite.config,webpack.config,jest.config}.*
|
|
69
|
+
|
|
70
|
+
# Environment/deployment
|
|
71
|
+
glob: **/{.env*,docker-compose*,Dockerfile}
|
|
72
|
+
```
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
DeepSearchStrategies {
|
|
77
|
+
FindingImplementations {
|
|
78
|
+
When locating where something is implemented:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
# Find function/class definitions
|
|
82
|
+
grep: (function|class|interface|type)\s+TargetName
|
|
83
|
+
|
|
84
|
+
# Find exports
|
|
85
|
+
grep: export\s+(default\s+)?(function|class|const)\s+TargetName
|
|
86
|
+
|
|
87
|
+
# Find specific patterns (adjust for language)
|
|
88
|
+
grep: def target_name # Python
|
|
89
|
+
grep: func TargetName # Go
|
|
90
|
+
grep: fn target_name # Rust
|
|
91
|
+
```
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
TracingUsage {
|
|
95
|
+
When finding where something is used:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
# Find imports of a module
|
|
99
|
+
grep: import.*from\s+['"].*target-module
|
|
100
|
+
|
|
101
|
+
# Find function calls
|
|
102
|
+
grep: targetFunction\(
|
|
103
|
+
|
|
104
|
+
# Find references (broad search)
|
|
105
|
+
grep: TargetName
|
|
106
|
+
```
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
ArchitectureMapping {
|
|
110
|
+
When understanding system structure:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
# Find all route definitions
|
|
114
|
+
grep: (app\.(get|post|put|delete)|router\.)
|
|
115
|
+
|
|
116
|
+
# Find database models/schemas
|
|
117
|
+
grep: (Schema|Model|Entity|Table)\s*\(
|
|
118
|
+
glob: **/{models,entities,schemas}/**/*
|
|
119
|
+
|
|
120
|
+
# Find service boundaries
|
|
121
|
+
glob: **/{services,controllers,handlers}/**/*
|
|
122
|
+
grep: (class|interface)\s+\w+Service
|
|
123
|
+
```
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
ExplorationPatternsByGoal {
|
|
128
|
+
UnderstandEntryPoints {
|
|
129
|
+
```
|
|
130
|
+
# Web application routes
|
|
131
|
+
grep: (Route|path|endpoint)
|
|
132
|
+
glob: **/routes/**/* | **/*router*
|
|
133
|
+
|
|
134
|
+
# CLI commands
|
|
135
|
+
grep: (command|program\.)
|
|
136
|
+
glob: **/cli/**/* | **/commands/**/*
|
|
137
|
+
|
|
138
|
+
# Event handlers
|
|
139
|
+
grep: (on|handle|subscribe)\s*\(
|
|
140
|
+
```
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
FindConfiguration {
|
|
144
|
+
```
|
|
145
|
+
# Environment variables
|
|
146
|
+
grep: (process\.env|os\.environ|env\.)
|
|
147
|
+
|
|
148
|
+
# Feature flags
|
|
149
|
+
grep: (feature|flag|toggle)
|
|
150
|
+
|
|
151
|
+
# Constants/config objects
|
|
152
|
+
grep: (const|let)\s+(CONFIG|config|settings)
|
|
153
|
+
glob: **/{config,constants}/**/*
|
|
154
|
+
```
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
UnderstandDataFlow {
|
|
158
|
+
```
|
|
159
|
+
# Database queries
|
|
160
|
+
grep: (SELECT|INSERT|UPDATE|DELETE|find|create|update)
|
|
161
|
+
grep: (prisma|sequelize|typeorm|mongoose)\.
|
|
162
|
+
|
|
163
|
+
# API calls
|
|
164
|
+
grep: (fetch|axios|http\.|request\()
|
|
165
|
+
|
|
166
|
+
# State management
|
|
167
|
+
grep: (useState|useReducer|createStore|createSlice)
|
|
168
|
+
```
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
BestPractices {
|
|
173
|
+
SearchEfficiently {
|
|
174
|
+
1. Start with glob for file discovery - faster than grep for locating files
|
|
175
|
+
2. Use grep for content search - supports regex and context
|
|
176
|
+
3. Narrow scope - search in specific directories when possible
|
|
177
|
+
4. Check output modes - use `files_with_matches` for discovery, `content` for analysis
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
BuildMentalModels {
|
|
181
|
+
1. Map the layers - presentation, business logic, data access
|
|
182
|
+
2. Identify patterns - repository, service, controller, etc.
|
|
183
|
+
3. Note conventions - naming, file organization, code style
|
|
184
|
+
4. Document boundaries - where modules connect and separate
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
AvoidCommonPitfalls {
|
|
188
|
+
- Do not search entire node_modules/vendor directories
|
|
189
|
+
- Do not assume structure without verifying
|
|
190
|
+
- Do not skip reading project documentation (README, CLAUDE.md)
|
|
191
|
+
- Do not grep for common words without filtering (use glob filters)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
OutputFormat {
|
|
196
|
+
After exploration, summarize findings:
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
## Codebase Overview
|
|
200
|
+
|
|
201
|
+
**Tech Stack:** [Languages, frameworks, tools]
|
|
202
|
+
**Architecture:** [Monolith, microservices, modular, etc.]
|
|
203
|
+
**Entry Points:** [Main files, routes, handlers]
|
|
204
|
+
|
|
205
|
+
## Key Directories
|
|
206
|
+
|
|
207
|
+
- `src/` - [Purpose]
|
|
208
|
+
- `lib/` - [Purpose]
|
|
209
|
+
- `tests/` - [Purpose]
|
|
210
|
+
|
|
211
|
+
## Conventions Observed
|
|
212
|
+
|
|
213
|
+
- Naming: [Pattern]
|
|
214
|
+
- File organization: [Pattern]
|
|
215
|
+
- Testing: [Pattern]
|
|
216
|
+
|
|
217
|
+
## Dependencies
|
|
218
|
+
|
|
219
|
+
- [Key dependency]: [Purpose]
|
|
220
|
+
- [Key dependency]: [Purpose]
|
|
221
|
+
```
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
## References
|
|
226
|
+
|
|
227
|
+
- [Exploration Patterns Examples](examples/exploration-patterns.md) - Detailed practical examples
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# Exploration Patterns Examples
|
|
2
|
+
|
|
3
|
+
Practical examples demonstrating codebase exploration strategies for common scenarios.
|
|
4
|
+
|
|
5
|
+
## Example 1: Onboarding to a New Project
|
|
6
|
+
|
|
7
|
+
### Context
|
|
8
|
+
|
|
9
|
+
You have been assigned to work on an unfamiliar codebase. You need to understand its structure, tech stack, and conventions before making changes.
|
|
10
|
+
|
|
11
|
+
### Pattern
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Step 1: Read existing documentation first
|
|
15
|
+
read: README.md
|
|
16
|
+
read: CLAUDE.md (if exists)
|
|
17
|
+
|
|
18
|
+
# Step 2: Identify tech stack from config files
|
|
19
|
+
glob: package.json | requirements.txt | go.mod | Cargo.toml
|
|
20
|
+
|
|
21
|
+
# Step 3: Map source structure
|
|
22
|
+
glob: **/src/**/*.{ts,js,py,go}
|
|
23
|
+
|
|
24
|
+
# Step 4: Find entry points
|
|
25
|
+
glob: **/index.{ts,js} | **/main.{ts,js,py,go}
|
|
26
|
+
|
|
27
|
+
# Step 5: Locate tests to understand expected behaviors
|
|
28
|
+
glob: **/*.test.{ts,js} | **/*.spec.{ts,js} | **/test_*.py
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Explanation
|
|
32
|
+
|
|
33
|
+
1. **Documentation first** - README and CLAUDE.md often contain project-specific conventions and commands
|
|
34
|
+
2. **Config files reveal stack** - package.json shows Node.js, go.mod shows Go, etc.
|
|
35
|
+
3. **Source mapping** - understand directory organization
|
|
36
|
+
4. **Entry points** - find where execution begins
|
|
37
|
+
5. **Tests as documentation** - tests reveal expected behaviors and usage patterns
|
|
38
|
+
|
|
39
|
+
### Variations
|
|
40
|
+
|
|
41
|
+
- For monorepos: Start with `glob: **/package.json` to find all packages
|
|
42
|
+
- For microservices: Look for `glob: **/Dockerfile` to identify service boundaries
|
|
43
|
+
- For legacy code: Check `glob: **/*.sql` for database schema clues
|
|
44
|
+
|
|
45
|
+
### Anti-Patterns
|
|
46
|
+
|
|
47
|
+
- Skipping documentation and assuming structure
|
|
48
|
+
- Searching entire repo including node_modules/vendor
|
|
49
|
+
- Making changes before understanding conventions
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Example 2: Finding Where a Feature is Implemented
|
|
54
|
+
|
|
55
|
+
### Context
|
|
56
|
+
|
|
57
|
+
You need to modify user authentication but do not know where the code lives.
|
|
58
|
+
|
|
59
|
+
### Pattern
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
# Step 1: Search for obvious terms
|
|
63
|
+
grep: (auth|login|authenticate)
|
|
64
|
+
glob: **/*.{ts,js,py}
|
|
65
|
+
output_mode: files_with_matches
|
|
66
|
+
|
|
67
|
+
# Step 2: Find route definitions
|
|
68
|
+
grep: (login|signin|auth).*route
|
|
69
|
+
glob: **/routes/**/*
|
|
70
|
+
|
|
71
|
+
# Step 3: Locate service/handler
|
|
72
|
+
grep: (AuthService|AuthHandler|authenticate)
|
|
73
|
+
output_mode: content
|
|
74
|
+
-C: 3
|
|
75
|
+
|
|
76
|
+
# Step 4: Trace imports to find related files
|
|
77
|
+
grep: import.*from.*auth
|
|
78
|
+
output_mode: files_with_matches
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Explanation
|
|
82
|
+
|
|
83
|
+
1. **Broad search first** - Find all files mentioning authentication
|
|
84
|
+
2. **Route definitions** - Locate API entry points
|
|
85
|
+
3. **Service layer** - Find business logic implementations
|
|
86
|
+
4. **Import tracing** - Discover related modules and dependencies
|
|
87
|
+
|
|
88
|
+
### Variations
|
|
89
|
+
|
|
90
|
+
- For frontend: `grep: (useAuth|AuthContext|AuthProvider)`
|
|
91
|
+
- For database: `grep: (users|sessions).*table|schema`
|
|
92
|
+
- For middleware: `grep: (middleware|interceptor).*auth`
|
|
93
|
+
|
|
94
|
+
### Anti-Patterns
|
|
95
|
+
|
|
96
|
+
- Searching for single common word like "user" (too many results)
|
|
97
|
+
- Not narrowing scope after initial discovery
|
|
98
|
+
- Ignoring test files (they often show usage patterns)
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Example 3: Understanding Data Flow
|
|
103
|
+
|
|
104
|
+
### Context
|
|
105
|
+
|
|
106
|
+
You need to understand how data moves from API request to database and back.
|
|
107
|
+
|
|
108
|
+
### Pattern
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
# Step 1: Find API routes/handlers
|
|
112
|
+
grep: (app\.(get|post)|router\.(get|post)|@(Get|Post))
|
|
113
|
+
glob: **/routes/**/* | **/controllers/**/*
|
|
114
|
+
output_mode: content
|
|
115
|
+
-C: 5
|
|
116
|
+
|
|
117
|
+
# Step 2: Find service layer calls
|
|
118
|
+
grep: (Service|Repository)\.(create|find|update|delete)
|
|
119
|
+
output_mode: content
|
|
120
|
+
-C: 3
|
|
121
|
+
|
|
122
|
+
# Step 3: Find database operations
|
|
123
|
+
grep: (prisma|sequelize|mongoose|typeorm)\.\w+\.(find|create|update)
|
|
124
|
+
output_mode: content
|
|
125
|
+
|
|
126
|
+
# Step 4: Find data transformations
|
|
127
|
+
grep: (map|transform|serialize|dto)
|
|
128
|
+
glob: **/{dto,mapper,transformer}/**/*
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Explanation
|
|
132
|
+
|
|
133
|
+
1. **Start at API boundary** - Where requests enter the system
|
|
134
|
+
2. **Follow to services** - Business logic layer
|
|
135
|
+
3. **Track to database** - Data persistence layer
|
|
136
|
+
4. **Find transformations** - How data changes between layers
|
|
137
|
+
|
|
138
|
+
### Variations
|
|
139
|
+
|
|
140
|
+
- For event-driven: `grep: (emit|publish|subscribe|on\()`
|
|
141
|
+
- For GraphQL: `grep: (Query|Mutation|Resolver)`
|
|
142
|
+
- For message queues: `grep: (queue|broker|consume|produce)`
|
|
143
|
+
|
|
144
|
+
### Anti-Patterns
|
|
145
|
+
|
|
146
|
+
- Starting from database and working up (harder to follow)
|
|
147
|
+
- Ignoring middleware transformations
|
|
148
|
+
- Missing async/await patterns that indicate I/O boundaries
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Example 4: Mapping Architecture Boundaries
|
|
153
|
+
|
|
154
|
+
### Context
|
|
155
|
+
|
|
156
|
+
You need to understand the high-level architecture to plan a refactoring effort.
|
|
157
|
+
|
|
158
|
+
### Pattern
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
# Step 1: Find module/package boundaries
|
|
162
|
+
glob: **/package.json | **/go.mod | **/__init__.py
|
|
163
|
+
(for monorepos: shows internal packages)
|
|
164
|
+
|
|
165
|
+
# Step 2: Identify layers
|
|
166
|
+
glob: **/{controllers,handlers,routes}/**/*
|
|
167
|
+
glob: **/{services,usecases,domain}/**/*
|
|
168
|
+
glob: **/{repositories,dal,data}/**/*
|
|
169
|
+
|
|
170
|
+
# Step 3: Find external integrations
|
|
171
|
+
grep: (axios|fetch|http\.|request\()
|
|
172
|
+
output_mode: files_with_matches
|
|
173
|
+
glob: **/{clients,integrations,adapters}/**/*
|
|
174
|
+
|
|
175
|
+
# Step 4: Map cross-cutting concerns
|
|
176
|
+
glob: **/{middleware,interceptors,guards}/**/*
|
|
177
|
+
grep: (logger|cache|metric|trace)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Explanation
|
|
181
|
+
|
|
182
|
+
1. **Package boundaries** - Physical separation of concerns
|
|
183
|
+
2. **Architectural layers** - Presentation, business, data
|
|
184
|
+
3. **External boundaries** - Where system meets outside world
|
|
185
|
+
4. **Cross-cutting** - Shared functionality across layers
|
|
186
|
+
|
|
187
|
+
### Variations
|
|
188
|
+
|
|
189
|
+
- For microservices: Look for `glob: **/Dockerfile` and service definitions
|
|
190
|
+
- For modular monolith: Check for internal API contracts
|
|
191
|
+
- For plugin architecture: `grep: (plugin|extension|addon)`
|
|
192
|
+
|
|
193
|
+
### Anti-Patterns
|
|
194
|
+
|
|
195
|
+
- Assuming standard layer names (every project is different)
|
|
196
|
+
- Missing hidden dependencies through global state
|
|
197
|
+
- Not checking for circular dependencies
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Example 5: Investigating a Bug
|
|
202
|
+
|
|
203
|
+
### Context
|
|
204
|
+
|
|
205
|
+
Users report an error message: "Invalid token format". You need to find where this error originates.
|
|
206
|
+
|
|
207
|
+
### Pattern
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
# Step 1: Search for exact error message
|
|
211
|
+
grep: Invalid token format
|
|
212
|
+
output_mode: content
|
|
213
|
+
-C: 10
|
|
214
|
+
|
|
215
|
+
# Step 2: Find related error handling
|
|
216
|
+
grep: (throw|raise|Error).*token
|
|
217
|
+
output_mode: content
|
|
218
|
+
-C: 5
|
|
219
|
+
|
|
220
|
+
# Step 3: Trace the code path
|
|
221
|
+
# (after finding file, search for function callers)
|
|
222
|
+
grep: validateToken|parseToken
|
|
223
|
+
output_mode: files_with_matches
|
|
224
|
+
|
|
225
|
+
# Step 4: Check test files for expected behavior
|
|
226
|
+
grep: Invalid token
|
|
227
|
+
glob: **/*.test.{ts,js} | **/test_*.py
|
|
228
|
+
output_mode: content
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Explanation
|
|
232
|
+
|
|
233
|
+
1. **Exact match first** - Find the error source directly
|
|
234
|
+
2. **Related errors** - Understand error handling context
|
|
235
|
+
3. **Caller analysis** - Who invokes this code
|
|
236
|
+
4. **Test context** - What is the expected behavior
|
|
237
|
+
|
|
238
|
+
### Variations
|
|
239
|
+
|
|
240
|
+
- For stack traces: Search for function names in the trace
|
|
241
|
+
- For database errors: Check migration files and schema definitions
|
|
242
|
+
- For runtime errors: Look for environment variable usage
|
|
243
|
+
|
|
244
|
+
### Anti-Patterns
|
|
245
|
+
|
|
246
|
+
- Guessing the source without searching
|
|
247
|
+
- Not checking test files for expected behavior
|
|
248
|
+
- Fixing symptom without understanding root cause
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Quick Reference: Search Strategy by Goal
|
|
253
|
+
|
|
254
|
+
| Goal | Primary Tool | Pattern |
|
|
255
|
+
|------|--------------|---------|
|
|
256
|
+
| Find file by name | glob | `**/target-name*` |
|
|
257
|
+
| Find file by content | grep | `pattern` with `files_with_matches` |
|
|
258
|
+
| Understand function | grep | Function name with `-C: 10` for context |
|
|
259
|
+
| Find all usages | grep | Call pattern with `files_with_matches` |
|
|
260
|
+
| Map directory structure | glob | `**/src/**/*` |
|
|
261
|
+
| Find configuration | glob | `**/*.{json,yaml,toml,env}` |
|
|
262
|
+
| Trace dependencies | grep | Import/require patterns |
|
|
263
|
+
| Find tests | glob | `**/*.test.* | **/*.spec.* | **/test_*` |
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: coding-conventions
|
|
3
|
+
description: "Apply consistent security, performance, and accessibility standards across all recommendations and code reviews."
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: opencode
|
|
6
|
+
metadata:
|
|
7
|
+
category: analysis
|
|
8
|
+
version: "1.0"
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Coding Conventions
|
|
12
|
+
|
|
13
|
+
Roleplay as a cross-cutting standards enforcer providing consistent security, performance, and quality standards across all agent recommendations.
|
|
14
|
+
|
|
15
|
+
CodingConventions {
|
|
16
|
+
Activation {
|
|
17
|
+
- Reviewing code for security vulnerabilities
|
|
18
|
+
- Validating performance characteristics of implementations
|
|
19
|
+
- Ensuring accessibility compliance in UI components
|
|
20
|
+
- Designing error handling strategies
|
|
21
|
+
- Auditing existing systems for quality gaps
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Constraints {
|
|
25
|
+
1. Apply security checks before performance optimization
|
|
26
|
+
2. Make accessibility a default, not an afterthought
|
|
27
|
+
3. Use checklists during code review, not just at the end
|
|
28
|
+
4. Document exceptions to standards with rationale
|
|
29
|
+
5. Automate checks where possible (linting, testing)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
CoreDomains {
|
|
33
|
+
Security {
|
|
34
|
+
Covers common vulnerability prevention aligned with OWASP Top 10.
|
|
35
|
+
Apply these checks to any code that handles user input, authentication,
|
|
36
|
+
data storage, or external communications.
|
|
37
|
+
|
|
38
|
+
See: [security-checklist.md](checklists/security-checklist.md)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
Performance {
|
|
42
|
+
Covers optimization patterns for frontend, backend, and database operations.
|
|
43
|
+
Apply these checks when performance is a concern or during code review.
|
|
44
|
+
|
|
45
|
+
See: [performance-checklist.md](checklists/performance-checklist.md)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Accessibility {
|
|
49
|
+
Covers WCAG 2.1 Level AA compliance.
|
|
50
|
+
Apply these checks to all user-facing components to ensure inclusive design.
|
|
51
|
+
|
|
52
|
+
See: [accessibility-checklist.md](checklists/accessibility-checklist.md)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ErrorHandlingPatterns {
|
|
57
|
+
All agents should recommend these error handling approaches.
|
|
58
|
+
|
|
59
|
+
ErrorClassification {
|
|
60
|
+
Distinguish between operational and programmer errors:
|
|
61
|
+
|
|
62
|
+
| Type | Examples | Response |
|
|
63
|
+
|------|----------|----------|
|
|
64
|
+
| **Operational** | Network failures, invalid input, timeouts, rate limits | Handle gracefully, log appropriately, provide user feedback, implement recovery |
|
|
65
|
+
| **Programmer** | Type errors, null access, failed assertions | Fail fast, log full context, alert developers - do NOT attempt recovery |
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Pattern1_FailFastAtBoundaries {
|
|
69
|
+
Validate inputs at system boundaries and fail immediately with clear error messages.
|
|
70
|
+
Do not allow invalid data to propagate through the system.
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
// At API boundary
|
|
74
|
+
function handleRequest(input) {
|
|
75
|
+
const validation = validateInput(input);
|
|
76
|
+
if (!validation.valid) {
|
|
77
|
+
throw new ValidationError(validation.errors);
|
|
78
|
+
}
|
|
79
|
+
// Process validated input
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
Pattern2_SpecificErrorTypes {
|
|
85
|
+
Create domain-specific error types that carry context about what failed and why.
|
|
86
|
+
Generic errors lose valuable debugging information.
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
class PaymentDeclinedError extends Error {
|
|
90
|
+
constructor(reason, transactionId) {
|
|
91
|
+
super(`Payment declined: ${reason}`);
|
|
92
|
+
this.reason = reason;
|
|
93
|
+
this.transactionId = transactionId;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
Pattern3_UserSafeMessages {
|
|
100
|
+
Never expose internal error details to users.
|
|
101
|
+
Log full context internally, present sanitized messages externally.
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
try {
|
|
105
|
+
await processPayment(order);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
logger.error('Payment failed', {
|
|
108
|
+
error,
|
|
109
|
+
orderId: order.id,
|
|
110
|
+
userId: user.id
|
|
111
|
+
});
|
|
112
|
+
throw new UserFacingError('Payment could not be processed. Please try again.');
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
Pattern4_GracefulDegradation {
|
|
118
|
+
When non-critical operations fail, degrade gracefully rather than failing entirely.
|
|
119
|
+
Define what is critical vs. optional.
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
async function loadDashboard() {
|
|
123
|
+
const [userData, analytics, recommendations] = await Promise.allSettled([
|
|
124
|
+
fetchUserData(), // Critical - fail if missing
|
|
125
|
+
fetchAnalytics(), // Optional - show placeholder
|
|
126
|
+
fetchRecommendations() // Optional - hide section
|
|
127
|
+
]);
|
|
128
|
+
|
|
129
|
+
if (userData.status === 'rejected') {
|
|
130
|
+
throw new Error('Cannot load dashboard');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
user: userData.value,
|
|
135
|
+
analytics: analytics.value ?? null,
|
|
136
|
+
recommendations: recommendations.value ?? []
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
Pattern5_RetryWithBackoff {
|
|
143
|
+
For transient failures (network, rate limits), implement exponential backoff
|
|
144
|
+
with maximum attempts.
|
|
145
|
+
|
|
146
|
+
```javascript
|
|
147
|
+
async function fetchWithRetry(url, maxAttempts = 3) {
|
|
148
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
149
|
+
try {
|
|
150
|
+
return await fetch(url);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
if (attempt === maxAttempts) throw error;
|
|
153
|
+
await sleep(Math.pow(2, attempt) * 100); // 200ms, 400ms, 800ms
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
LoggingLevels {
|
|
161
|
+
| Level | Use For |
|
|
162
|
+
|-------|---------|
|
|
163
|
+
| ERROR | Operational errors requiring attention |
|
|
164
|
+
| WARN | Recoverable issues, degraded performance |
|
|
165
|
+
| INFO | Significant state changes, request lifecycle |
|
|
166
|
+
| DEBUG | Detailed flow for troubleshooting |
|
|
167
|
+
|
|
168
|
+
Log: Correlation IDs, user context (sanitized), operation attempted, error type, duration.
|
|
169
|
+
Never log: Passwords, tokens, secrets, credit card numbers, PII.
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
## References
|
|
175
|
+
|
|
176
|
+
- [security-checklist.md](checklists/security-checklist.md) - OWASP-aligned security checks
|
|
177
|
+
- [performance-checklist.md](checklists/performance-checklist.md) - Performance optimization checklist
|
|
178
|
+
- [accessibility-checklist.md](checklists/accessibility-checklist.md) - WCAG 2.1 AA compliance checklist
|