@plazmodium/odin 0.3.3-beta → 0.3.5-beta
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 +25 -10
- package/builtin/ODIN.md +1067 -0
- package/builtin/agent-definitions/README.md +170 -0
- package/builtin/agent-definitions/_shared-context.md +377 -0
- package/builtin/agent-definitions/architect.md +627 -0
- package/builtin/agent-definitions/builder.md +713 -0
- package/builtin/agent-definitions/discovery.md +293 -0
- package/builtin/agent-definitions/documenter.md +238 -0
- package/builtin/agent-definitions/guardian.md +1049 -0
- package/builtin/agent-definitions/integrator.md +189 -0
- package/builtin/agent-definitions/planning.md +236 -0
- package/builtin/agent-definitions/product.md +405 -0
- package/builtin/agent-definitions/release.md +205 -0
- package/builtin/agent-definitions/reviewer.md +447 -0
- package/builtin/agent-definitions/watcher.md +402 -0
- package/builtin/skills/api/graphql/SKILL.md +548 -0
- package/builtin/skills/api/grpc/SKILL.md +554 -0
- package/builtin/skills/api/rest-api/SKILL.md +469 -0
- package/builtin/skills/api/trpc/SKILL.md +503 -0
- package/builtin/skills/architecture/clean-architecture/SKILL.md +141 -0
- package/builtin/skills/architecture/domain-driven-design/SKILL.md +129 -0
- package/builtin/skills/architecture/event-driven/SKILL.md +145 -0
- package/builtin/skills/architecture/microservices/SKILL.md +143 -0
- package/builtin/skills/architecture/tla-precheck/SKILL.md +171 -0
- package/builtin/skills/backend/golang-gin/SKILL.md +141 -0
- package/builtin/skills/backend/nodejs-express/SKILL.md +277 -0
- package/builtin/skills/backend/nodejs-fastify/SKILL.md +152 -0
- package/builtin/skills/backend/python-django/SKILL.md +128 -0
- package/builtin/skills/backend/python-fastapi/SKILL.md +140 -0
- package/builtin/skills/database/mongodb/SKILL.md +132 -0
- package/builtin/skills/database/postgresql/SKILL.md +120 -0
- package/builtin/skills/database/prisma-orm/SKILL.md +366 -0
- package/builtin/skills/database/redis/SKILL.md +140 -0
- package/builtin/skills/database/supabase/SKILL.md +416 -0
- package/builtin/skills/devops/aws/SKILL.md +382 -0
- package/builtin/skills/devops/docker/SKILL.md +359 -0
- package/builtin/skills/devops/github-actions/SKILL.md +435 -0
- package/builtin/skills/devops/kubernetes/SKILL.md +459 -0
- package/builtin/skills/devops/terraform/SKILL.md +453 -0
- package/builtin/skills/frontend/alpine-dev/SKILL.md +27 -0
- package/builtin/skills/frontend/angular-dev/SKILL.md +28 -0
- package/builtin/skills/frontend/astro-dev/SKILL.md +28 -0
- package/builtin/skills/frontend/htmx-dev/SKILL.md +28 -0
- package/builtin/skills/frontend/nextjs-dev/SKILL.md +470 -0
- package/builtin/skills/frontend/react-patterns/SKILL.md +166 -0
- package/builtin/skills/frontend/svelte-dev/SKILL.md +28 -0
- package/builtin/skills/frontend/tailwindcss/SKILL.md +131 -0
- package/builtin/skills/frontend/vuejs-dev/SKILL.md +28 -0
- package/builtin/skills/generic-dev/SKILL.md +307 -0
- package/builtin/skills/testing/cypress/SKILL.md +372 -0
- package/builtin/skills/testing/jest/SKILL.md +176 -0
- package/builtin/skills/testing/playwright/SKILL.md +341 -0
- package/builtin/skills/testing/unit-tests-eval-sdd/SKILL.md +73 -0
- package/builtin/skills/testing/unit-tests-sdd/SKILL.md +83 -0
- package/builtin/skills/testing/vitest/SKILL.md +249 -0
- package/dist/adapters/skills/filesystem.d.ts +1 -0
- package/dist/adapters/skills/filesystem.d.ts.map +1 -1
- package/dist/adapters/skills/filesystem.js +6 -18
- package/dist/adapters/skills/filesystem.js.map +1 -1
- package/dist/adapters/skills/types.d.ts +1 -0
- package/dist/adapters/skills/types.d.ts.map +1 -1
- package/dist/adapters/workflow-state/in-memory.d.ts +10 -2
- package/dist/adapters/workflow-state/in-memory.d.ts.map +1 -1
- package/dist/adapters/workflow-state/in-memory.js +98 -5
- package/dist/adapters/workflow-state/in-memory.js.map +1 -1
- package/dist/adapters/workflow-state/supabase.d.ts +8 -2
- package/dist/adapters/workflow-state/supabase.d.ts.map +1 -1
- package/dist/adapters/workflow-state/supabase.js +204 -0
- package/dist/adapters/workflow-state/supabase.js.map +1 -1
- package/dist/adapters/workflow-state/types.d.ts +15 -1
- package/dist/adapters/workflow-state/types.d.ts.map +1 -1
- package/dist/builtin-assets.d.ts +8 -0
- package/dist/builtin-assets.d.ts.map +1 -0
- package/dist/builtin-assets.js +90 -0
- package/dist/builtin-assets.js.map +1 -0
- package/dist/domain/skill-draft-validation.d.ts +18 -0
- package/dist/domain/skill-draft-validation.d.ts.map +1 -0
- package/dist/domain/skill-draft-validation.js +100 -0
- package/dist/domain/skill-draft-validation.js.map +1 -0
- package/dist/domain/skill-proposals.d.ts +11 -0
- package/dist/domain/skill-proposals.d.ts.map +1 -0
- package/dist/domain/skill-proposals.js +103 -0
- package/dist/domain/skill-proposals.js.map +1 -0
- package/dist/init.js +69 -11
- package/dist/init.js.map +1 -1
- package/dist/schemas.d.ts +39 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +30 -1
- package/dist/schemas.js.map +1 -1
- package/dist/server.js +38 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/apply-migrations.d.ts +10 -0
- package/dist/tools/apply-migrations.d.ts.map +1 -1
- package/dist/tools/apply-migrations.js +10 -26
- package/dist/tools/apply-migrations.js.map +1 -1
- package/dist/tools/capture-learning.d.ts.map +1 -1
- package/dist/tools/capture-learning.js +14 -1
- package/dist/tools/capture-learning.js.map +1 -1
- package/dist/tools/get-skill-proposal-queue.d.ts +5 -0
- package/dist/tools/get-skill-proposal-queue.d.ts.map +1 -0
- package/dist/tools/get-skill-proposal-queue.js +21 -0
- package/dist/tools/get-skill-proposal-queue.js.map +1 -0
- package/dist/tools/get-skill-proposals.d.ts +4 -0
- package/dist/tools/get-skill-proposals.d.ts.map +1 -0
- package/dist/tools/get-skill-proposals.js +11 -0
- package/dist/tools/get-skill-proposals.js.map +1 -0
- package/dist/tools/prepare-phase-context.d.ts.map +1 -1
- package/dist/tools/prepare-phase-context.js +5 -0
- package/dist/tools/prepare-phase-context.js.map +1 -1
- package/dist/tools/publish-skill-proposal.d.ts +5 -0
- package/dist/tools/publish-skill-proposal.d.ts.map +1 -0
- package/dist/tools/publish-skill-proposal.js +57 -0
- package/dist/tools/publish-skill-proposal.js.map +1 -0
- package/dist/tools/record-skill-proposal-decision.d.ts +4 -0
- package/dist/tools/record-skill-proposal-decision.d.ts.map +1 -0
- package/dist/tools/record-skill-proposal-decision.js +22 -0
- package/dist/tools/record-skill-proposal-decision.js.map +1 -0
- package/dist/tools/record-skill-proposal-draft.d.ts +5 -0
- package/dist/tools/record-skill-proposal-draft.d.ts.map +1 -0
- package/dist/tools/record-skill-proposal-draft.js +65 -0
- package/dist/tools/record-skill-proposal-draft.js.map +1 -0
- package/dist/tools/sync-skill-proposal-candidates.d.ts +5 -0
- package/dist/tools/sync-skill-proposal-candidates.d.ts.map +1 -0
- package/dist/tools/sync-skill-proposal-candidates.js +20 -0
- package/dist/tools/sync-skill-proposal-candidates.js.map +1 -0
- package/dist/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/migrations/009_skill_proposal_candidates.sql +124 -0
- package/migrations/010_skill_proposals.sql +36 -0
- package/migrations/README.md +6 -0
- package/package.json +5 -3
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tailwindcss
|
|
3
|
+
description: Utility-first CSS framework for building custom designs without writing CSS
|
|
4
|
+
category: frontend
|
|
5
|
+
version: "3.x"
|
|
6
|
+
compatible_with:
|
|
7
|
+
- nextjs-dev
|
|
8
|
+
- svelte-dev
|
|
9
|
+
- vuejs-dev
|
|
10
|
+
- astro-dev
|
|
11
|
+
- react-patterns
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Tailwind CSS
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
|
|
18
|
+
Tailwind CSS is a utility-first CSS framework that provides low-level utility classes to build custom designs directly in markup. Instead of writing custom CSS, compose utilities to create any design.
|
|
19
|
+
|
|
20
|
+
## Project Structure
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
src/
|
|
24
|
+
├── styles/
|
|
25
|
+
│ └── globals.css # @tailwind directives + custom utilities
|
|
26
|
+
├── tailwind.config.ts # Theme customization
|
|
27
|
+
├── postcss.config.js # PostCSS with Tailwind plugin
|
|
28
|
+
└── components/
|
|
29
|
+
└── Button.tsx # Components using utility classes
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Core Patterns
|
|
33
|
+
|
|
34
|
+
### Configuration
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
// tailwind.config.ts
|
|
38
|
+
import type { Config } from 'tailwindcss';
|
|
39
|
+
|
|
40
|
+
const config: Config = {
|
|
41
|
+
content: ['./src/**/*.{js,ts,jsx,tsx,mdx}'],
|
|
42
|
+
theme: {
|
|
43
|
+
extend: {
|
|
44
|
+
colors: {
|
|
45
|
+
brand: {
|
|
46
|
+
50: '#f0f9ff',
|
|
47
|
+
500: '#3b82f6',
|
|
48
|
+
900: '#1e3a5f',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
plugins: [],
|
|
54
|
+
};
|
|
55
|
+
export default config;
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Base Styles
|
|
59
|
+
|
|
60
|
+
```css
|
|
61
|
+
/* globals.css */
|
|
62
|
+
@tailwind base;
|
|
63
|
+
@tailwind components;
|
|
64
|
+
@tailwind utilities;
|
|
65
|
+
|
|
66
|
+
@layer components {
|
|
67
|
+
.btn-primary {
|
|
68
|
+
@apply px-4 py-2 bg-brand-500 text-white rounded-lg
|
|
69
|
+
hover:bg-brand-900 transition-colors
|
|
70
|
+
focus:outline-none focus:ring-2 focus:ring-brand-500;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Responsive Design
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
<!-- Mobile-first: sm → md → lg → xl → 2xl -->
|
|
79
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
80
|
+
<div class="p-4 bg-white rounded-lg shadow">Card</div>
|
|
81
|
+
</div>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Dark Mode
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<!-- Class-based dark mode (darkMode: 'class' in config) -->
|
|
88
|
+
<div class="bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100">
|
|
89
|
+
<p class="text-gray-600 dark:text-gray-400">Content</p>
|
|
90
|
+
</div>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Component Patterns
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
// Compose variants with template literals or clsx
|
|
97
|
+
import { clsx } from 'clsx';
|
|
98
|
+
|
|
99
|
+
function Button({ variant = 'primary', size = 'md', children }: ButtonProps) {
|
|
100
|
+
return (
|
|
101
|
+
<button
|
|
102
|
+
className={clsx(
|
|
103
|
+
'rounded-lg font-medium transition-colors focus:outline-none focus:ring-2',
|
|
104
|
+
variant === 'primary' && 'bg-blue-600 text-white hover:bg-blue-700',
|
|
105
|
+
variant === 'secondary' && 'bg-gray-200 text-gray-800 hover:bg-gray-300',
|
|
106
|
+
size === 'sm' && 'px-3 py-1.5 text-sm',
|
|
107
|
+
size === 'md' && 'px-4 py-2 text-base',
|
|
108
|
+
)}
|
|
109
|
+
>
|
|
110
|
+
{children}
|
|
111
|
+
</button>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Best Practices
|
|
117
|
+
|
|
118
|
+
1. **Use `@apply` sparingly** — only for highly reused component classes
|
|
119
|
+
2. **Mobile-first** — start with base styles, add breakpoint prefixes for larger screens
|
|
120
|
+
3. **Extract components** — when class lists exceed ~5 utilities, extract to a component
|
|
121
|
+
4. **Use design tokens** — extend theme in config rather than using arbitrary values
|
|
122
|
+
5. **Purge unused CSS** — ensure `content` paths cover all template files
|
|
123
|
+
6. **Group related utilities** — keep layout, spacing, colors, and states grouped logically
|
|
124
|
+
7. **Prefer semantic color names** — `brand-500` over `blue-500` in your theme
|
|
125
|
+
|
|
126
|
+
## Gotchas
|
|
127
|
+
|
|
128
|
+
- **Arbitrary values** (`w-[137px]`) bypass the design system — use sparingly
|
|
129
|
+
- **Specificity issues** with `@apply` inside `@layer` — order matters
|
|
130
|
+
- **PurgeCSS false positives** — dynamically constructed class names (`bg-${color}-500`) won't be detected; use safelist or full class names
|
|
131
|
+
- **Peer/group modifiers** require correct DOM nesting (`group` on parent, `group-hover:` on child)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vuejs-dev
|
|
3
|
+
description: Supports Vue.js development, covering components, reactivity, directives, state management with Pinia or Vuex, and routing with Vue Router. Use for queries on building interactive UIs with Vue's composition or options API.
|
|
4
|
+
category: frontend
|
|
5
|
+
compatible_with:
|
|
6
|
+
- tailwindcss
|
|
7
|
+
- vitest
|
|
8
|
+
- cypress
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Vue.js Development Assistance
|
|
12
|
+
|
|
13
|
+
## Instructions
|
|
14
|
+
1. **Parse the query**: Identify needs like component creation, event handling, computed properties, or integration with other libraries.
|
|
15
|
+
2. **Apply Vue principles**: Emphasize reactivity, single-file components, and progressive enhancement.
|
|
16
|
+
3. **Structure answers**:
|
|
17
|
+
- Code generation: Deliver .vue file snippets with script, template, and style sections.
|
|
18
|
+
- Explanations: Break down concepts like refs, reactivity, and lifecycle hooks.
|
|
19
|
+
- Troubleshooting: Address issues like prop drilling or performance bottlenecks.
|
|
20
|
+
4. **Tool usage**: Employ code_execution for validating Vue code in a JavaScript environment.
|
|
21
|
+
5. **Engage users**: Use analogies for complex topics and link to Vue docs.
|
|
22
|
+
|
|
23
|
+
## Best Practices
|
|
24
|
+
- Favor Composition API for larger apps.
|
|
25
|
+
- Use TypeScript with Vue for better scalability.
|
|
26
|
+
- Avoid mutating props directly.
|
|
27
|
+
|
|
28
|
+
For detailed and up-to-date knowledge and examples on the latest Vue.js, use Tessl.io respective tile in tessl/npm-vue
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: generic-dev
|
|
3
|
+
description: Universal software development best practices - the fallback skill when no specific tech stack skills are available
|
|
4
|
+
category: foundation
|
|
5
|
+
version: "1.0"
|
|
6
|
+
compatible_with:
|
|
7
|
+
- all
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Generic Software Development
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
This skill provides universal software development principles that apply across all languages, frameworks, and platforms. Use this as a fallback when specific tech stack skills are not available, or as a foundation that complements specialized skills.
|
|
15
|
+
|
|
16
|
+
## When This Skill Applies
|
|
17
|
+
|
|
18
|
+
- No specific framework/language skills match the project's tech stack
|
|
19
|
+
- Building from scratch without established patterns
|
|
20
|
+
- Working with unfamiliar or legacy codebases
|
|
21
|
+
- General architectural decisions before tech stack selection
|
|
22
|
+
|
|
23
|
+
## Core Principles
|
|
24
|
+
|
|
25
|
+
### SOLID Principles
|
|
26
|
+
|
|
27
|
+
| Principle | Description | Application |
|
|
28
|
+
|-----------|-------------|-------------|
|
|
29
|
+
| **S**ingle Responsibility | One class/module = one reason to change | Split large files by concern |
|
|
30
|
+
| **O**pen/Closed | Open for extension, closed for modification | Use interfaces and composition |
|
|
31
|
+
| **L**iskov Substitution | Subtypes must be substitutable for base types | Don't break contracts in subclasses |
|
|
32
|
+
| **I**nterface Segregation | Many specific interfaces > one general interface | Split large interfaces |
|
|
33
|
+
| **D**ependency Inversion | Depend on abstractions, not concretions | Inject dependencies, use interfaces |
|
|
34
|
+
|
|
35
|
+
### DRY, KISS, YAGNI
|
|
36
|
+
|
|
37
|
+
- **DRY** (Don't Repeat Yourself): Extract repeated logic into functions/modules
|
|
38
|
+
- **KISS** (Keep It Simple): Prefer simple solutions over clever ones
|
|
39
|
+
- **YAGNI** (You Aren't Gonna Need It): Don't build features "just in case"
|
|
40
|
+
|
|
41
|
+
## Code Organization
|
|
42
|
+
|
|
43
|
+
### File Structure Patterns
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
src/
|
|
47
|
+
├── index.{ext} # Entry point
|
|
48
|
+
├── config/ # Configuration loading
|
|
49
|
+
├── types/ # Type definitions
|
|
50
|
+
├── utils/ # Pure utility functions
|
|
51
|
+
├── services/ # Business logic
|
|
52
|
+
├── repositories/ # Data access layer
|
|
53
|
+
├── controllers/ # Request handlers (if applicable)
|
|
54
|
+
├── middleware/ # Cross-cutting concerns
|
|
55
|
+
└── tests/ # Test files (or alongside source)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Naming Conventions
|
|
59
|
+
|
|
60
|
+
| Element | Convention | Example |
|
|
61
|
+
|---------|------------|---------|
|
|
62
|
+
| Files | kebab-case or snake_case | `user-service.ts`, `user_service.py` |
|
|
63
|
+
| Classes | PascalCase | `UserService`, `AuthController` |
|
|
64
|
+
| Functions | camelCase or snake_case | `getUser()`, `get_user()` |
|
|
65
|
+
| Constants | UPPER_SNAKE_CASE | `MAX_RETRIES`, `API_BASE_URL` |
|
|
66
|
+
| Private members | Prefix with `_` | `_internalState`, `_validateInput()` |
|
|
67
|
+
|
|
68
|
+
### Module Boundaries
|
|
69
|
+
|
|
70
|
+
1. **Public API**: Export only what's needed by other modules
|
|
71
|
+
2. **Internal implementation**: Keep helpers private to the module
|
|
72
|
+
3. **Dependencies**: Import from well-defined module entry points
|
|
73
|
+
|
|
74
|
+
## Error Handling
|
|
75
|
+
|
|
76
|
+
### Error Categories
|
|
77
|
+
|
|
78
|
+
| Category | HTTP Code | When to Use |
|
|
79
|
+
|----------|-----------|-------------|
|
|
80
|
+
| Validation Error | 400 | Invalid input from user |
|
|
81
|
+
| Authentication Error | 401 | Missing or invalid credentials |
|
|
82
|
+
| Authorization Error | 403 | Valid user, insufficient permissions |
|
|
83
|
+
| Not Found | 404 | Resource doesn't exist |
|
|
84
|
+
| Conflict | 409 | Resource state conflict (duplicate, etc.) |
|
|
85
|
+
| Internal Error | 500 | Unexpected server error |
|
|
86
|
+
|
|
87
|
+
### Error Handling Pattern
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
try {
|
|
91
|
+
// Operation that may fail
|
|
92
|
+
result = performOperation()
|
|
93
|
+
return success(result)
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (isExpectedError(error)) {
|
|
96
|
+
// Handle gracefully - return user-friendly message
|
|
97
|
+
return failure(userFriendlyMessage(error))
|
|
98
|
+
}
|
|
99
|
+
// Unexpected error - log and return generic message
|
|
100
|
+
log.error("Unexpected error", { error, context })
|
|
101
|
+
return failure("An unexpected error occurred")
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Error Best Practices
|
|
106
|
+
|
|
107
|
+
1. **Never expose internal details** - Stack traces, SQL queries, file paths
|
|
108
|
+
2. **Log unexpected errors** - Include context for debugging
|
|
109
|
+
3. **Fail fast** - Validate inputs at boundaries
|
|
110
|
+
4. **Use typed errors** - Create error classes/types for different failure modes
|
|
111
|
+
5. **Provide actionable messages** - Tell users what they can do to fix the issue
|
|
112
|
+
|
|
113
|
+
## Input Validation
|
|
114
|
+
|
|
115
|
+
### Validation Rules
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
// Always validate at system boundaries:
|
|
119
|
+
1. API endpoints - validate request body, query params, path params
|
|
120
|
+
2. Form submissions - validate before processing
|
|
121
|
+
3. External data - never trust data from external sources
|
|
122
|
+
4. Configuration - validate at startup
|
|
123
|
+
|
|
124
|
+
// Validation order:
|
|
125
|
+
1. Required fields present?
|
|
126
|
+
2. Correct types?
|
|
127
|
+
3. Within allowed ranges/lengths?
|
|
128
|
+
4. Matches expected format (email, URL, etc.)?
|
|
129
|
+
5. Business rule validation
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Sanitization
|
|
133
|
+
|
|
134
|
+
- **Escape output** - Prevent XSS when rendering user data
|
|
135
|
+
- **Parameterize queries** - Never concatenate user input into queries
|
|
136
|
+
- **Whitelist allowed values** - For enums, use explicit allowed lists
|
|
137
|
+
- **Trim and normalize** - Remove leading/trailing whitespace, normalize unicode
|
|
138
|
+
|
|
139
|
+
## Testing Patterns
|
|
140
|
+
|
|
141
|
+
### Test Pyramid
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
/\
|
|
145
|
+
/ \ E2E Tests (few)
|
|
146
|
+
/----\
|
|
147
|
+
/ \ Integration Tests (some)
|
|
148
|
+
/--------\
|
|
149
|
+
/ \ Unit Tests (many)
|
|
150
|
+
--------------
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Test Organization
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
// Unit test structure (Arrange-Act-Assert)
|
|
157
|
+
test("should return user when valid ID provided", () => {
|
|
158
|
+
// Arrange
|
|
159
|
+
const userId = "123"
|
|
160
|
+
const expectedUser = { id: "123", name: "Test" }
|
|
161
|
+
mockRepository.findById.returns(expectedUser)
|
|
162
|
+
|
|
163
|
+
// Act
|
|
164
|
+
const result = userService.getUser(userId)
|
|
165
|
+
|
|
166
|
+
// Assert
|
|
167
|
+
expect(result).toEqual(expectedUser)
|
|
168
|
+
})
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### What to Test
|
|
172
|
+
|
|
173
|
+
| Test Type | Focus | Examples |
|
|
174
|
+
|-----------|-------|----------|
|
|
175
|
+
| Unit | Single function/class in isolation | `calculateTotal()`, `validateEmail()` |
|
|
176
|
+
| Integration | Multiple components working together | Service + Database, API + Auth |
|
|
177
|
+
| E2E | Full user flows | Login flow, checkout process |
|
|
178
|
+
|
|
179
|
+
### Test Best Practices
|
|
180
|
+
|
|
181
|
+
1. **Test behavior, not implementation** - Tests should survive refactoring
|
|
182
|
+
2. **One assertion focus per test** - Test one thing at a time
|
|
183
|
+
3. **Use descriptive test names** - `should_returnError_when_userNotFound`
|
|
184
|
+
4. **Avoid test interdependence** - Each test should be independent
|
|
185
|
+
5. **Mock external dependencies** - Network calls, databases, time
|
|
186
|
+
|
|
187
|
+
## Security Fundamentals
|
|
188
|
+
|
|
189
|
+
### Authentication & Authorization
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
// Authentication: Who are you?
|
|
193
|
+
1. Verify credentials (password, token, certificate)
|
|
194
|
+
2. Issue session/token upon success
|
|
195
|
+
3. Include identity in subsequent requests
|
|
196
|
+
|
|
197
|
+
// Authorization: What can you do?
|
|
198
|
+
1. Check permissions before every protected action
|
|
199
|
+
2. Use principle of least privilege
|
|
200
|
+
3. Deny by default, allow explicitly
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Security Checklist
|
|
204
|
+
|
|
205
|
+
- [ ] **Secrets management**: Environment variables, never hardcoded
|
|
206
|
+
- [ ] **Input validation**: Validate and sanitize all inputs
|
|
207
|
+
- [ ] **Output encoding**: Escape output to prevent XSS
|
|
208
|
+
- [ ] **Parameterized queries**: Prevent SQL injection
|
|
209
|
+
- [ ] **Authentication required**: Protect sensitive endpoints
|
|
210
|
+
- [ ] **Authorization checked**: Verify permissions for each action
|
|
211
|
+
- [ ] **HTTPS only**: Encrypt data in transit
|
|
212
|
+
- [ ] **Sensitive data handling**: Don't log passwords, tokens, PII
|
|
213
|
+
- [ ] **Rate limiting**: Prevent abuse and brute force
|
|
214
|
+
- [ ] **Error messages**: Don't reveal internal details
|
|
215
|
+
|
|
216
|
+
## Performance Considerations
|
|
217
|
+
|
|
218
|
+
### Common Optimizations
|
|
219
|
+
|
|
220
|
+
| Issue | Solution |
|
|
221
|
+
|-------|----------|
|
|
222
|
+
| N+1 queries | Use eager loading / batch queries |
|
|
223
|
+
| Large payloads | Pagination, field selection |
|
|
224
|
+
| Slow operations | Caching, background jobs |
|
|
225
|
+
| Memory leaks | Clean up resources, limit growth |
|
|
226
|
+
|
|
227
|
+
### Performance Best Practices
|
|
228
|
+
|
|
229
|
+
1. **Measure first** - Don't optimize without profiling
|
|
230
|
+
2. **Cache appropriately** - Cache expensive, rarely-changing data
|
|
231
|
+
3. **Batch operations** - Combine multiple small operations
|
|
232
|
+
4. **Use indexes** - On frequently queried fields
|
|
233
|
+
5. **Set timeouts** - On all external calls
|
|
234
|
+
|
|
235
|
+
## Documentation
|
|
236
|
+
|
|
237
|
+
### Code Documentation
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
// Document the "why", not the "what"
|
|
241
|
+
|
|
242
|
+
// Bad: Increment counter by 1
|
|
243
|
+
counter++
|
|
244
|
+
|
|
245
|
+
// Good: Track retry attempts to enforce max retry limit
|
|
246
|
+
retryCount++
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### What to Document
|
|
250
|
+
|
|
251
|
+
1. **Public APIs** - Parameters, return values, errors
|
|
252
|
+
2. **Complex algorithms** - Explain the approach
|
|
253
|
+
3. **Non-obvious decisions** - Why this solution over alternatives
|
|
254
|
+
4. **Configuration options** - What each setting does
|
|
255
|
+
5. **Dependencies** - What's required and why
|
|
256
|
+
|
|
257
|
+
## Anti-Patterns to Avoid
|
|
258
|
+
|
|
259
|
+
### Code Smells
|
|
260
|
+
|
|
261
|
+
| Smell | Problem | Solution |
|
|
262
|
+
|-------|---------|----------|
|
|
263
|
+
| God class/file | Too many responsibilities | Split by concern |
|
|
264
|
+
| Deep nesting | Hard to read/maintain | Early returns, extract functions |
|
|
265
|
+
| Magic numbers | Unclear meaning | Named constants |
|
|
266
|
+
| Copy-paste code | DRY violation | Extract shared function |
|
|
267
|
+
| Long parameter lists | Hard to use correctly | Use objects/builders |
|
|
268
|
+
|
|
269
|
+
### Architecture Smells
|
|
270
|
+
|
|
271
|
+
- **Circular dependencies** - Modules depending on each other
|
|
272
|
+
- **Leaky abstractions** - Implementation details exposed
|
|
273
|
+
- **Shotgun surgery** - One change requires many file edits
|
|
274
|
+
- **Feature envy** - Code using another module's data excessively
|
|
275
|
+
|
|
276
|
+
## When to Escalate
|
|
277
|
+
|
|
278
|
+
**Request specific tech stack skills when**:
|
|
279
|
+
|
|
280
|
+
1. Framework-specific patterns are needed (routing, ORM, etc.)
|
|
281
|
+
2. Language idioms are unclear (Rust ownership, Go channels, etc.)
|
|
282
|
+
3. Build/deployment configuration is required
|
|
283
|
+
4. Performance optimization needs framework-specific knowledge
|
|
284
|
+
5. Security requires framework-specific hardening
|
|
285
|
+
|
|
286
|
+
**Flag in your output**:
|
|
287
|
+
```markdown
|
|
288
|
+
## Skill Escalation Needed
|
|
289
|
+
|
|
290
|
+
**Reason**: [Why generic patterns are insufficient]
|
|
291
|
+
**Recommended Skills**: [e.g., "nextjs-dev", "python-fastapi"]
|
|
292
|
+
**Blocking**: [Yes/No - can work continue without specific skills?]
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Summary
|
|
296
|
+
|
|
297
|
+
This skill provides foundational patterns that apply universally. When implementing:
|
|
298
|
+
|
|
299
|
+
1. **Structure code** using layered architecture
|
|
300
|
+
2. **Handle errors** gracefully with proper logging
|
|
301
|
+
3. **Validate inputs** at system boundaries
|
|
302
|
+
4. **Write tests** following the test pyramid
|
|
303
|
+
5. **Secure the application** using the security checklist
|
|
304
|
+
6. **Document decisions** not obvious from code
|
|
305
|
+
7. **Avoid anti-patterns** that lead to technical debt
|
|
306
|
+
|
|
307
|
+
If the task requires framework-specific patterns, request appropriate skills from the orchestrator.
|