bros-harness 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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +183 -0
- package/SECURITY.md +16 -0
- package/assets/agents.manifest.json +55 -0
- package/assets/commands.manifest.json +35 -0
- package/assets/docs.manifest.json +20 -0
- package/assets/import-report.md +25 -0
- package/assets/manifest.json +799 -0
- package/assets/opencode/agents/README.md +3 -0
- package/assets/opencode/agents/bro-build.md +256 -0
- package/assets/opencode/agents/bro-design.md +77 -0
- package/assets/opencode/agents/bro-docs.md +72 -0
- package/assets/opencode/agents/bro-explore.md +143 -0
- package/assets/opencode/agents/bro-ops.md +195 -0
- package/assets/opencode/agents/bro-shield.md +77 -0
- package/assets/opencode/agents/bro-test.md +204 -0
- package/assets/opencode/agents/bro-ui.md +135 -0
- package/assets/opencode/agents/mighty-bro.md +252 -0
- package/assets/opencode/commands/README.md +3 -0
- package/assets/opencode/commands/bros-assemble.md +32 -0
- package/assets/opencode/commands/bros-build.md +58 -0
- package/assets/opencode/commands/bros-plan.md +83 -0
- package/assets/opencode/commands/bros-review.md +38 -0
- package/assets/opencode/commands/bros-status.md +26 -0
- package/assets/opencode/docs/README.md +3 -0
- package/assets/opencode/docs/bros-builtin-skills.md +63 -0
- package/assets/opencode/docs/bros-harness.md +194 -0
- package/assets/opencode/skills/README.md +3 -0
- package/assets/opencode/skills/agent-architecture-audit/SKILL.md +256 -0
- package/assets/opencode/skills/agent-harness-construction/.openskills.json +7 -0
- package/assets/opencode/skills/agent-harness-construction/SKILL.md +73 -0
- package/assets/opencode/skills/agent-introspection-debugging/.openskills.json +7 -0
- package/assets/opencode/skills/agent-introspection-debugging/SKILL.md +153 -0
- package/assets/opencode/skills/api-design/.openskills.json +7 -0
- package/assets/opencode/skills/api-design/agents/openai.yaml +7 -0
- package/assets/opencode/skills/architecture-decision-records/.openskills.json +7 -0
- package/assets/opencode/skills/architecture-decision-records/SKILL.md +179 -0
- package/assets/opencode/skills/article-writing/.openskills.json +7 -0
- package/assets/opencode/skills/article-writing/SKILL.md +79 -0
- package/assets/opencode/skills/article-writing/agents/openai.yaml +7 -0
- package/assets/opencode/skills/automation-audit-ops/.openskills.json +7 -0
- package/assets/opencode/skills/automation-audit-ops/SKILL.md +142 -0
- package/assets/opencode/skills/backend-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/backend-patterns/SKILL.md +561 -0
- package/assets/opencode/skills/backend-patterns/agents/openai.yaml +7 -0
- package/assets/opencode/skills/benchmark/.openskills.json +7 -0
- package/assets/opencode/skills/benchmark/SKILL.md +93 -0
- package/assets/opencode/skills/bros-orchestrate/SKILL.md +455 -0
- package/assets/opencode/skills/browser-qa/.openskills.json +7 -0
- package/assets/opencode/skills/browser-qa/SKILL.md +87 -0
- package/assets/opencode/skills/canary-watch/.openskills.json +7 -0
- package/assets/opencode/skills/canary-watch/SKILL.md +107 -0
- package/assets/opencode/skills/code-review-expert/SKILL.md +155 -0
- package/assets/opencode/skills/code-review-expert/agents/agent.yaml +7 -0
- package/assets/opencode/skills/code-review-expert/references/code-quality-checklist.md +130 -0
- package/assets/opencode/skills/code-review-expert/references/removal-plan.md +52 -0
- package/assets/opencode/skills/code-review-expert/references/security-checklist.md +118 -0
- package/assets/opencode/skills/code-review-expert/references/solid-checklist.md +65 -0
- package/assets/opencode/skills/code-tour/.openskills.json +7 -0
- package/assets/opencode/skills/code-tour/SKILL.md +236 -0
- package/assets/opencode/skills/coding-standards/.openskills.json +7 -0
- package/assets/opencode/skills/coding-standards/SKILL.md +549 -0
- package/assets/opencode/skills/coding-standards/agents/openai.yaml +7 -0
- package/assets/opencode/skills/context-budget/.openskills.json +7 -0
- package/assets/opencode/skills/context-budget/SKILL.md +135 -0
- package/assets/opencode/skills/database-migrations/.openskills.json +7 -0
- package/assets/opencode/skills/database-migrations/SKILL.md +429 -0
- package/assets/opencode/skills/deployment-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/deployment-patterns/SKILL.md +427 -0
- package/assets/opencode/skills/design-system/.openskills.json +7 -0
- package/assets/opencode/skills/design-system/SKILL.md +82 -0
- package/assets/opencode/skills/docker-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/docker-patterns/SKILL.md +364 -0
- package/assets/opencode/skills/documentation-lookup/.openskills.json +7 -0
- package/assets/opencode/skills/documentation-lookup/SKILL.md +90 -0
- package/assets/opencode/skills/documentation-lookup/agents/openai.yaml +7 -0
- package/assets/opencode/skills/e2e-testing/.openskills.json +7 -0
- package/assets/opencode/skills/e2e-testing/SKILL.md +326 -0
- package/assets/opencode/skills/e2e-testing/agents/openai.yaml +7 -0
- package/assets/opencode/skills/error-handling/SKILL.md +376 -0
- package/assets/opencode/skills/frontend-design/.openskills.json +7 -0
- package/assets/opencode/skills/frontend-design/SKILL.md +145 -0
- package/assets/opencode/skills/frontend-design-direction/SKILL.md +92 -0
- package/assets/opencode/skills/frontend-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/frontend-patterns/SKILL.md +642 -0
- package/assets/opencode/skills/frontend-patterns/agents/openai.yaml +7 -0
- package/assets/opencode/skills/gateguard/.openskills.json +7 -0
- package/assets/opencode/skills/gateguard/SKILL.md +125 -0
- package/assets/opencode/skills/git-master/SKILL.md +60 -0
- package/assets/opencode/skills/golang-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/golang-patterns/SKILL.md +674 -0
- package/assets/opencode/skills/golang-testing/.openskills.json +7 -0
- package/assets/opencode/skills/golang-testing/SKILL.md +720 -0
- package/assets/opencode/skills/grafana-dashboard-design/SKILL.md +65 -0
- package/assets/opencode/skills/hexagonal-architecture/.openskills.json +7 -0
- package/assets/opencode/skills/hexagonal-architecture/SKILL.md +276 -0
- package/assets/opencode/skills/java-coding-standards/.openskills.json +7 -0
- package/assets/opencode/skills/java-coding-standards/SKILL.md +383 -0
- package/assets/opencode/skills/jpa-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/jpa-patterns/SKILL.md +151 -0
- package/assets/opencode/skills/knowledge-ops/.openskills.json +7 -0
- package/assets/opencode/skills/knowledge-ops/SKILL.md +154 -0
- package/assets/opencode/skills/make-interfaces-feel-better/SKILL.md +151 -0
- package/assets/opencode/skills/mysql-patterns/SKILL.md +412 -0
- package/assets/opencode/skills/nestjs-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/nestjs-patterns/SKILL.md +230 -0
- package/assets/opencode/skills/nextjs-turbopack/.openskills.json +7 -0
- package/assets/opencode/skills/nextjs-turbopack/SKILL.md +57 -0
- package/assets/opencode/skills/nextjs-turbopack/agents/openai.yaml +7 -0
- package/assets/opencode/skills/parallel-execution-optimizer/SKILL.md +72 -0
- package/assets/opencode/skills/postgres-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/postgres-patterns/SKILL.md +147 -0
- package/assets/opencode/skills/prisma-patterns/SKILL.md +371 -0
- package/assets/opencode/skills/product-capability/.openskills.json +7 -0
- package/assets/opencode/skills/product-capability/SKILL.md +141 -0
- package/assets/opencode/skills/product-lens/.openskills.json +7 -0
- package/assets/opencode/skills/product-lens/SKILL.md +92 -0
- package/assets/opencode/skills/production-audit/SKILL.md +206 -0
- package/assets/opencode/skills/python-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/python-patterns/SKILL.md +750 -0
- package/assets/opencode/skills/python-testing/.openskills.json +7 -0
- package/assets/opencode/skills/python-testing/SKILL.md +816 -0
- package/assets/opencode/skills/redis-patterns/SKILL.md +403 -0
- package/assets/opencode/skills/requirements-clarity/README.md +260 -0
- package/assets/opencode/skills/requirements-clarity/SKILL.md +324 -0
- package/assets/opencode/skills/rust-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/rust-patterns/SKILL.md +499 -0
- package/assets/opencode/skills/rust-testing/.openskills.json +7 -0
- package/assets/opencode/skills/rust-testing/SKILL.md +500 -0
- package/assets/opencode/skills/safety-guard/.openskills.json +7 -0
- package/assets/opencode/skills/safety-guard/SKILL.md +75 -0
- package/assets/opencode/skills/search-first/.openskills.json +7 -0
- package/assets/opencode/skills/search-first/SKILL.md +181 -0
- package/assets/opencode/skills/security-review/.openskills.json +7 -0
- package/assets/opencode/skills/security-review/agents/openai.yaml +7 -0
- package/assets/opencode/skills/security-review/cloud-infrastructure-security.md +361 -0
- package/assets/opencode/skills/security-scan/.openskills.json +7 -0
- package/assets/opencode/skills/security-scan/SKILL.md +165 -0
- package/assets/opencode/skills/springboot-patterns/.openskills.json +7 -0
- package/assets/opencode/skills/springboot-patterns/SKILL.md +314 -0
- package/assets/opencode/skills/springboot-tdd/.openskills.json +7 -0
- package/assets/opencode/skills/springboot-tdd/SKILL.md +158 -0
- package/assets/opencode/skills/springboot-verification/.openskills.json +7 -0
- package/assets/opencode/skills/springboot-verification/SKILL.md +231 -0
- package/assets/opencode/skills/strategic-compact/.openskills.json +7 -0
- package/assets/opencode/skills/strategic-compact/SKILL.md +131 -0
- package/assets/opencode/skills/strategic-compact/agents/openai.yaml +7 -0
- package/assets/opencode/skills/strategic-compact/suggest-compact.sh +54 -0
- package/assets/opencode/skills/tdd-workflow/.openskills.json +7 -0
- package/assets/opencode/skills/tdd-workflow/SKILL.md +463 -0
- package/assets/opencode/skills/tdd-workflow/agents/openai.yaml +7 -0
- package/assets/opencode/skills/verification-loop/.openskills.json +7 -0
- package/assets/opencode/skills/verification-loop/SKILL.md +126 -0
- package/assets/opencode/skills/verification-loop/agents/openai.yaml +7 -0
- package/assets/opencode/skills/vite-patterns/SKILL.md +449 -0
- package/assets/opencode/skills/web-doc-search/SKILL.md +51 -0
- package/assets/opencode/templates/README.md +3 -0
- package/assets/opencode/templates/bros/adr.md +39 -0
- package/assets/opencode/templates/bros/delivery-report.md +71 -0
- package/assets/opencode/templates/bros/explorer-evidence-packet.md +51 -0
- package/assets/opencode/templates/bros/prd.md +72 -0
- package/assets/opencode/templates/bros/security-review.md +48 -0
- package/assets/opencode/templates/bros/status-board.md +33 -0
- package/assets/opencode/templates/bros/task-packet.md +94 -0
- package/assets/opencode/templates/bros/test-strategy.md +57 -0
- package/assets/opencode/templates/bros/ui-implementation-packet.md +64 -0
- package/assets/skills.manifest.json +650 -0
- package/assets/templates.manifest.json +55 -0
- package/bin/bros.mjs +122 -0
- package/docs/compatibility.md +9 -0
- package/docs/installation.md +66 -0
- package/docs/integrations/claude.md +5 -0
- package/docs/integrations/codex.md +5 -0
- package/docs/integrations/opencode.md +39 -0
- package/docs/migration/from-local-opencode-config.md +10 -0
- package/docs/release-process.md +11 -0
- package/docs/repository-structure.md +15 -0
- package/docs/roadmap.md +20 -0
- package/docs/security.md +18 -0
- package/docs/testing.md +9 -0
- package/examples/opencode/README.md +11 -0
- package/examples/opencode/opencode.example.jsonc +4 -0
- package/package.json +43 -0
- package/scripts/validate-assets.mjs +22 -0
- package/scripts/verify-no-secrets.mjs +38 -0
- package/src/plugin.mjs +98 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nestjs-patterns
|
|
3
|
+
description: NestJS architecture patterns for modules, controllers, providers, DTO validation, guards, interceptors, config, and production-grade TypeScript backends.
|
|
4
|
+
origin: ECC
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# NestJS Development Patterns
|
|
8
|
+
|
|
9
|
+
Production-grade NestJS patterns for modular TypeScript backends.
|
|
10
|
+
|
|
11
|
+
## When to Activate
|
|
12
|
+
|
|
13
|
+
- Building NestJS APIs or services
|
|
14
|
+
- Structuring modules, controllers, and providers
|
|
15
|
+
- Adding DTO validation, guards, interceptors, or exception filters
|
|
16
|
+
- Configuring environment-aware settings and database integrations
|
|
17
|
+
- Testing NestJS units or HTTP endpoints
|
|
18
|
+
|
|
19
|
+
## Project Structure
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
src/
|
|
23
|
+
├── app.module.ts
|
|
24
|
+
├── main.ts
|
|
25
|
+
├── common/
|
|
26
|
+
│ ├── filters/
|
|
27
|
+
│ ├── guards/
|
|
28
|
+
│ ├── interceptors/
|
|
29
|
+
│ └── pipes/
|
|
30
|
+
├── config/
|
|
31
|
+
│ ├── configuration.ts
|
|
32
|
+
│ └── validation.ts
|
|
33
|
+
├── modules/
|
|
34
|
+
│ ├── auth/
|
|
35
|
+
│ │ ├── auth.controller.ts
|
|
36
|
+
│ │ ├── auth.module.ts
|
|
37
|
+
│ │ ├── auth.service.ts
|
|
38
|
+
│ │ ├── dto/
|
|
39
|
+
│ │ ├── guards/
|
|
40
|
+
│ │ └── strategies/
|
|
41
|
+
│ └── users/
|
|
42
|
+
│ ├── dto/
|
|
43
|
+
│ ├── entities/
|
|
44
|
+
│ ├── users.controller.ts
|
|
45
|
+
│ ├── users.module.ts
|
|
46
|
+
│ └── users.service.ts
|
|
47
|
+
└── prisma/ or database/
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- Keep domain code inside feature modules.
|
|
51
|
+
- Put cross-cutting filters, decorators, guards, and interceptors in `common/`.
|
|
52
|
+
- Keep DTOs close to the module that owns them.
|
|
53
|
+
|
|
54
|
+
## Bootstrap and Global Validation
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
async function bootstrap() {
|
|
58
|
+
const app = await NestFactory.create(AppModule, { bufferLogs: true });
|
|
59
|
+
|
|
60
|
+
app.useGlobalPipes(
|
|
61
|
+
new ValidationPipe({
|
|
62
|
+
whitelist: true,
|
|
63
|
+
forbidNonWhitelisted: true,
|
|
64
|
+
transform: true,
|
|
65
|
+
transformOptions: { enableImplicitConversion: true },
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));
|
|
70
|
+
app.useGlobalFilters(new HttpExceptionFilter());
|
|
71
|
+
|
|
72
|
+
await app.listen(process.env.PORT ?? 3000);
|
|
73
|
+
}
|
|
74
|
+
bootstrap();
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
- Always enable `whitelist` and `forbidNonWhitelisted` on public APIs.
|
|
78
|
+
- Prefer one global validation pipe instead of repeating validation config per route.
|
|
79
|
+
|
|
80
|
+
## Modules, Controllers, and Providers
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
@Module({
|
|
84
|
+
controllers: [UsersController],
|
|
85
|
+
providers: [UsersService],
|
|
86
|
+
exports: [UsersService],
|
|
87
|
+
})
|
|
88
|
+
export class UsersModule {}
|
|
89
|
+
|
|
90
|
+
@Controller('users')
|
|
91
|
+
export class UsersController {
|
|
92
|
+
constructor(private readonly usersService: UsersService) {}
|
|
93
|
+
|
|
94
|
+
@Get(':id')
|
|
95
|
+
getById(@Param('id', ParseUUIDPipe) id: string) {
|
|
96
|
+
return this.usersService.getById(id);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@Post()
|
|
100
|
+
create(@Body() dto: CreateUserDto) {
|
|
101
|
+
return this.usersService.create(dto);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@Injectable()
|
|
106
|
+
export class UsersService {
|
|
107
|
+
constructor(private readonly usersRepo: UsersRepository) {}
|
|
108
|
+
|
|
109
|
+
async create(dto: CreateUserDto) {
|
|
110
|
+
return this.usersRepo.create(dto);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
- Controllers should stay thin: parse HTTP input, call a provider, return response DTOs.
|
|
116
|
+
- Put business logic in injectable services, not controllers.
|
|
117
|
+
- Export only the providers other modules genuinely need.
|
|
118
|
+
|
|
119
|
+
## DTOs and Validation
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
export class CreateUserDto {
|
|
123
|
+
@IsEmail()
|
|
124
|
+
email!: string;
|
|
125
|
+
|
|
126
|
+
@IsString()
|
|
127
|
+
@Length(2, 80)
|
|
128
|
+
name!: string;
|
|
129
|
+
|
|
130
|
+
@IsOptional()
|
|
131
|
+
@IsEnum(UserRole)
|
|
132
|
+
role?: UserRole;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
- Validate every request DTO with `class-validator`.
|
|
137
|
+
- Use dedicated response DTOs or serializers instead of returning ORM entities directly.
|
|
138
|
+
- Avoid leaking internal fields such as password hashes, tokens, or audit columns.
|
|
139
|
+
|
|
140
|
+
## Auth, Guards, and Request Context
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
144
|
+
@Roles('admin')
|
|
145
|
+
@Get('admin/report')
|
|
146
|
+
getAdminReport(@Req() req: AuthenticatedRequest) {
|
|
147
|
+
return this.reportService.getForUser(req.user.id);
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- Keep auth strategies and guards module-local unless they are truly shared.
|
|
152
|
+
- Encode coarse access rules in guards, then do resource-specific authorization in services.
|
|
153
|
+
- Prefer explicit request types for authenticated request objects.
|
|
154
|
+
|
|
155
|
+
## Exception Filters and Error Shape
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
@Catch()
|
|
159
|
+
export class HttpExceptionFilter implements ExceptionFilter {
|
|
160
|
+
catch(exception: unknown, host: ArgumentsHost) {
|
|
161
|
+
const response = host.switchToHttp().getResponse<Response>();
|
|
162
|
+
const request = host.switchToHttp().getRequest<Request>();
|
|
163
|
+
|
|
164
|
+
if (exception instanceof HttpException) {
|
|
165
|
+
return response.status(exception.getStatus()).json({
|
|
166
|
+
path: request.url,
|
|
167
|
+
error: exception.getResponse(),
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return response.status(500).json({
|
|
172
|
+
path: request.url,
|
|
173
|
+
error: 'Internal server error',
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- Keep one consistent error envelope across the API.
|
|
180
|
+
- Throw framework exceptions for expected client errors; log and wrap unexpected failures centrally.
|
|
181
|
+
|
|
182
|
+
## Config and Environment Validation
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
ConfigModule.forRoot({
|
|
186
|
+
isGlobal: true,
|
|
187
|
+
load: [configuration],
|
|
188
|
+
validate: validateEnv,
|
|
189
|
+
});
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
- Validate env at boot, not lazily at first request.
|
|
193
|
+
- Keep config access behind typed helpers or config services.
|
|
194
|
+
- Split dev/staging/prod concerns in config factories instead of branching throughout feature code.
|
|
195
|
+
|
|
196
|
+
## Persistence and Transactions
|
|
197
|
+
|
|
198
|
+
- Keep repository / ORM code behind providers that speak domain language.
|
|
199
|
+
- For Prisma or TypeORM, isolate transactional workflows in services that own the unit of work.
|
|
200
|
+
- Do not let controllers coordinate multi-step writes directly.
|
|
201
|
+
|
|
202
|
+
## Testing
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
describe('UsersController', () => {
|
|
206
|
+
let app: INestApplication;
|
|
207
|
+
|
|
208
|
+
beforeAll(async () => {
|
|
209
|
+
const moduleRef = await Test.createTestingModule({
|
|
210
|
+
imports: [UsersModule],
|
|
211
|
+
}).compile();
|
|
212
|
+
|
|
213
|
+
app = moduleRef.createNestApplication();
|
|
214
|
+
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
|
|
215
|
+
await app.init();
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
- Unit test providers in isolation with mocked dependencies.
|
|
221
|
+
- Add request-level tests for guards, validation pipes, and exception filters.
|
|
222
|
+
- Reuse the same global pipes/filters in tests that you use in production.
|
|
223
|
+
|
|
224
|
+
## Production Defaults
|
|
225
|
+
|
|
226
|
+
- Enable structured logging and request correlation ids.
|
|
227
|
+
- Terminate on invalid env/config instead of booting partially.
|
|
228
|
+
- Prefer async provider initialization for DB/cache clients with explicit health checks.
|
|
229
|
+
- Keep background jobs and event consumers in their own modules, not inside HTTP controllers.
|
|
230
|
+
- Make rate limiting, auth, and audit logging explicit for public endpoints.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nextjs-turbopack
|
|
3
|
+
description: Next.js 16+ and Turbopack — incremental bundling, FS caching, dev speed, and when to use Turbopack vs webpack.
|
|
4
|
+
origin: ECC
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Next.js and Turbopack
|
|
8
|
+
|
|
9
|
+
Next.js 16+ uses Turbopack by default for local development: an incremental bundler written in Rust that significantly speeds up dev startup and hot updates.
|
|
10
|
+
|
|
11
|
+
## When to Use
|
|
12
|
+
|
|
13
|
+
- **Turbopack (default dev)**: Use for day-to-day development. Faster cold start and HMR, especially in large apps.
|
|
14
|
+
- **Webpack (legacy dev)**: Use only if you hit a Turbopack bug or rely on a webpack-only plugin in dev. Disable with `--webpack` (or `--no-turbopack` depending on your Next.js version; check the docs for your release).
|
|
15
|
+
- **Production**: Production build behavior (`next build`) may use Turbopack or webpack depending on Next.js version; check the official Next.js docs for your version.
|
|
16
|
+
|
|
17
|
+
Use when: developing or debugging Next.js 16+ apps, diagnosing slow dev startup or HMR, or optimizing production bundles.
|
|
18
|
+
|
|
19
|
+
## How It Works
|
|
20
|
+
|
|
21
|
+
- **Turbopack**: Incremental bundler for Next.js dev. Uses file-system caching so restarts are much faster (e.g. 5–14x on large projects).
|
|
22
|
+
- **Default in dev**: From Next.js 16, `next dev` runs with Turbopack unless disabled.
|
|
23
|
+
- **File-system caching**: Restarts reuse previous work; cache is typically under `.next`; no extra config needed for basic use.
|
|
24
|
+
- **Bundle Analyzer (Next.js 16.1+)**: Experimental Bundle Analyzer to inspect output and find heavy dependencies; enable via config or experimental flag (see Next.js docs for your version).
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
### Commands
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
next dev
|
|
32
|
+
next build
|
|
33
|
+
next start
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Usage
|
|
37
|
+
|
|
38
|
+
Run `next dev` for local development with Turbopack. Use the Bundle Analyzer (see Next.js docs) to optimize code-splitting and trim large dependencies. Prefer App Router and server components where possible.
|
|
39
|
+
|
|
40
|
+
## Middleware File Naming
|
|
41
|
+
|
|
42
|
+
Next.js 16 introduced `proxy.ts` as the middleware filename, replacing the older `middleware.ts` convention:
|
|
43
|
+
|
|
44
|
+
- **Next.js 16+**: use `proxy.ts` at the project root
|
|
45
|
+
- **Pre-Next.js 16**: use `middleware.ts` at the project root
|
|
46
|
+
|
|
47
|
+
The filename change is tied to the **Next.js version**, not to which bundler (Turbopack or webpack) is in use. Always check the official docs for the version you are reviewing.
|
|
48
|
+
|
|
49
|
+
**Do not flag `proxy.ts` as a misnamed or missing middleware file in Next.js 16 projects.** The file is correct and intentional. Suggesting a rename to `middleware.ts` will break middleware execution.
|
|
50
|
+
|
|
51
|
+
Reference: [Next.js proxy docs](https://nextjs.org/docs/app/getting-started/proxy)
|
|
52
|
+
|
|
53
|
+
## Best Practices
|
|
54
|
+
|
|
55
|
+
- Stay on a recent Next.js 16.x for stable Turbopack and caching behavior.
|
|
56
|
+
- If dev is slow, ensure you're on Turbopack (default) and that the cache isn't being cleared unnecessarily.
|
|
57
|
+
- For production bundle size issues, use the official Next.js bundle analysis tooling for your version.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: parallel-execution-optimizer
|
|
3
|
+
description: Use when the user wants a task done much faster through parallel work, concurrent agents, batched tool calls, isolated worktrees, or many independent verification lanes without losing correctness.
|
|
4
|
+
origin: ECC
|
|
5
|
+
tools: Read, Write, Edit, Bash, Grep, Glob
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Parallel Execution Optimizer
|
|
9
|
+
|
|
10
|
+
Use this skill when speed comes from doing independent work at the same time:
|
|
11
|
+
repo inspection, file reads, API checks, browser checks, build/test lanes,
|
|
12
|
+
deploy readbacks, or multi-worktree implementation passes.
|
|
13
|
+
|
|
14
|
+
## Core Pattern
|
|
15
|
+
|
|
16
|
+
Turn urgency into a dependency graph before acting.
|
|
17
|
+
|
|
18
|
+
1. Define the objective and done signal.
|
|
19
|
+
2. Split work into lanes.
|
|
20
|
+
3. Mark each lane as parallel, sequential, or gated.
|
|
21
|
+
4. Run independent reads/checks together.
|
|
22
|
+
5. Keep writes isolated by file, worktree, branch, service, or dataset.
|
|
23
|
+
6. Merge only after evidence shows the lanes are compatible.
|
|
24
|
+
7. End with a verification table, not a vague speed claim.
|
|
25
|
+
|
|
26
|
+
## Lane Matrix
|
|
27
|
+
|
|
28
|
+
Before a large push, write a compact matrix:
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
Lane | Can run in parallel? | Write surface | Risk | Verification
|
|
32
|
+
Repo scan | yes | none | low | rg/git status outputs
|
|
33
|
+
Backend patch | maybe | src/api | medium | unit tests
|
|
34
|
+
Frontend patch | maybe | app/components | medium | browser screenshot
|
|
35
|
+
Deploy readback | after build | remote service | high | live URL + logs
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Only run lanes in parallel when their write surfaces do not collide.
|
|
39
|
+
|
|
40
|
+
## Execution Rules
|
|
41
|
+
|
|
42
|
+
- Batch file reads, searches, status checks, and metadata queries.
|
|
43
|
+
- Use isolated worktrees for large unrelated implementation lanes.
|
|
44
|
+
- Start long-running tests, builds, backfills, and deploys in separate sessions,
|
|
45
|
+
then poll them deliberately.
|
|
46
|
+
- If a lane discovers a blocker that changes the plan, pause dependent lanes
|
|
47
|
+
and update the matrix.
|
|
48
|
+
- Never let a background process outlive the turn unless the user explicitly
|
|
49
|
+
asked for a continuing service.
|
|
50
|
+
- Do not parallelize destructive commands, migrations, writes to the same table,
|
|
51
|
+
or live customer-impacting deploys without an explicit gate.
|
|
52
|
+
|
|
53
|
+
## Output Shape
|
|
54
|
+
|
|
55
|
+
Use this when reporting:
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
Parallel execution result:
|
|
59
|
+
- Lanes run: 5
|
|
60
|
+
- Lanes completed: 4
|
|
61
|
+
- Blocked lane: deploy readback, waiting on DNS propagation
|
|
62
|
+
- Fast path found: batched repo scan + focused tests
|
|
63
|
+
- Verification: lint pass, unit pass, live smoke pass
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Failure Modes
|
|
67
|
+
|
|
68
|
+
- More concurrency that creates conflicting edits.
|
|
69
|
+
- Benchmarking the tool instead of the task.
|
|
70
|
+
- Treating "fast" as done before correctness is proven.
|
|
71
|
+
- Forgetting to poll running sessions.
|
|
72
|
+
- Hiding skipped checks behind a success summary.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: postgres-patterns
|
|
3
|
+
description: PostgreSQL database patterns for query optimization, schema design, indexing, and security. Based on Supabase best practices.
|
|
4
|
+
origin: ECC
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PostgreSQL Patterns
|
|
8
|
+
|
|
9
|
+
Quick reference for PostgreSQL best practices. For detailed guidance, use the `database-reviewer` agent.
|
|
10
|
+
|
|
11
|
+
## When to Activate
|
|
12
|
+
|
|
13
|
+
- Writing SQL queries or migrations
|
|
14
|
+
- Designing database schemas
|
|
15
|
+
- Troubleshooting slow queries
|
|
16
|
+
- Implementing Row Level Security
|
|
17
|
+
- Setting up connection pooling
|
|
18
|
+
|
|
19
|
+
## Quick Reference
|
|
20
|
+
|
|
21
|
+
### Index Cheat Sheet
|
|
22
|
+
|
|
23
|
+
| Query Pattern | Index Type | Example |
|
|
24
|
+
|--------------|------------|---------|
|
|
25
|
+
| `WHERE col = value` | B-tree (default) | `CREATE INDEX idx ON t (col)` |
|
|
26
|
+
| `WHERE col > value` | B-tree | `CREATE INDEX idx ON t (col)` |
|
|
27
|
+
| `WHERE a = x AND b > y` | Composite | `CREATE INDEX idx ON t (a, b)` |
|
|
28
|
+
| `WHERE jsonb @> '{}'` | GIN | `CREATE INDEX idx ON t USING gin (col)` |
|
|
29
|
+
| `WHERE tsv @@ query` | GIN | `CREATE INDEX idx ON t USING gin (col)` |
|
|
30
|
+
| Time-series ranges | BRIN | `CREATE INDEX idx ON t USING brin (col)` |
|
|
31
|
+
|
|
32
|
+
### Data Type Quick Reference
|
|
33
|
+
|
|
34
|
+
| Use Case | Correct Type | Avoid |
|
|
35
|
+
|----------|-------------|-------|
|
|
36
|
+
| IDs | `bigint` | `int`, random UUID |
|
|
37
|
+
| Strings | `text` | `varchar(255)` |
|
|
38
|
+
| Timestamps | `timestamptz` | `timestamp` |
|
|
39
|
+
| Money | `numeric(10,2)` | `float` |
|
|
40
|
+
| Flags | `boolean` | `varchar`, `int` |
|
|
41
|
+
|
|
42
|
+
### Common Patterns
|
|
43
|
+
|
|
44
|
+
**Composite Index Order:**
|
|
45
|
+
```sql
|
|
46
|
+
-- Equality columns first, then range columns
|
|
47
|
+
CREATE INDEX idx ON orders (status, created_at);
|
|
48
|
+
-- Works for: WHERE status = 'pending' AND created_at > '2024-01-01'
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Covering Index:**
|
|
52
|
+
```sql
|
|
53
|
+
CREATE INDEX idx ON users (email) INCLUDE (name, created_at);
|
|
54
|
+
-- Avoids table lookup for SELECT email, name, created_at
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Partial Index:**
|
|
58
|
+
```sql
|
|
59
|
+
CREATE INDEX idx ON users (email) WHERE deleted_at IS NULL;
|
|
60
|
+
-- Smaller index, only includes active users
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**RLS Policy (Optimized):**
|
|
64
|
+
```sql
|
|
65
|
+
CREATE POLICY policy ON orders
|
|
66
|
+
USING ((SELECT auth.uid()) = user_id); -- Wrap in SELECT!
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**UPSERT:**
|
|
70
|
+
```sql
|
|
71
|
+
INSERT INTO settings (user_id, key, value)
|
|
72
|
+
VALUES (123, 'theme', 'dark')
|
|
73
|
+
ON CONFLICT (user_id, key)
|
|
74
|
+
DO UPDATE SET value = EXCLUDED.value;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Cursor Pagination:**
|
|
78
|
+
```sql
|
|
79
|
+
SELECT * FROM products WHERE id > $last_id ORDER BY id LIMIT 20;
|
|
80
|
+
-- O(1) vs OFFSET which is O(n)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Queue Processing:**
|
|
84
|
+
```sql
|
|
85
|
+
UPDATE jobs SET status = 'processing'
|
|
86
|
+
WHERE id = (
|
|
87
|
+
SELECT id FROM jobs WHERE status = 'pending'
|
|
88
|
+
ORDER BY created_at LIMIT 1
|
|
89
|
+
FOR UPDATE SKIP LOCKED
|
|
90
|
+
) RETURNING *;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Anti-Pattern Detection
|
|
94
|
+
|
|
95
|
+
```sql
|
|
96
|
+
-- Find unindexed foreign keys
|
|
97
|
+
SELECT conrelid::regclass, a.attname
|
|
98
|
+
FROM pg_constraint c
|
|
99
|
+
JOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = ANY(c.conkey)
|
|
100
|
+
WHERE c.contype = 'f'
|
|
101
|
+
AND NOT EXISTS (
|
|
102
|
+
SELECT 1 FROM pg_index i
|
|
103
|
+
WHERE i.indrelid = c.conrelid AND a.attnum = ANY(i.indkey)
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
-- Find slow queries
|
|
107
|
+
SELECT query, mean_exec_time, calls
|
|
108
|
+
FROM pg_stat_statements
|
|
109
|
+
WHERE mean_exec_time > 100
|
|
110
|
+
ORDER BY mean_exec_time DESC;
|
|
111
|
+
|
|
112
|
+
-- Check table bloat
|
|
113
|
+
SELECT relname, n_dead_tup, last_vacuum
|
|
114
|
+
FROM pg_stat_user_tables
|
|
115
|
+
WHERE n_dead_tup > 1000
|
|
116
|
+
ORDER BY n_dead_tup DESC;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Configuration Template
|
|
120
|
+
|
|
121
|
+
```sql
|
|
122
|
+
-- Connection limits (adjust for RAM)
|
|
123
|
+
ALTER SYSTEM SET max_connections = 100;
|
|
124
|
+
ALTER SYSTEM SET work_mem = '8MB';
|
|
125
|
+
|
|
126
|
+
-- Timeouts
|
|
127
|
+
ALTER SYSTEM SET idle_in_transaction_session_timeout = '30s';
|
|
128
|
+
ALTER SYSTEM SET statement_timeout = '30s';
|
|
129
|
+
|
|
130
|
+
-- Monitoring
|
|
131
|
+
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
|
|
132
|
+
|
|
133
|
+
-- Security defaults
|
|
134
|
+
REVOKE ALL ON SCHEMA public FROM public;
|
|
135
|
+
|
|
136
|
+
SELECT pg_reload_conf();
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Related
|
|
140
|
+
|
|
141
|
+
- Agent: `database-reviewer` - Full database review workflow
|
|
142
|
+
- Skill: `clickhouse-io` - ClickHouse analytics patterns
|
|
143
|
+
- Skill: `backend-patterns` - API and backend patterns
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
*Based on Supabase Agent Skills (credit: Supabase team) (MIT License)*
|