omgkit 1.0.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/LICENSE +21 -0
- package/README.md +252 -0
- package/bin/omgkit.js +122 -0
- package/lib/.gitkeep +0 -0
- package/lib/cli.js +513 -0
- package/lib/index.js +35 -0
- package/package.json +52 -0
- package/plugin/.claude-plugin/.gitkeep +0 -0
- package/plugin/.claude-plugin/plugin.json +11 -0
- package/plugin/agents/.gitkeep +0 -0
- package/plugin/agents/api-designer.md +66 -0
- package/plugin/agents/architect.md +81 -0
- package/plugin/agents/brainstormer.md +60 -0
- package/plugin/agents/cicd-manager.md +50 -0
- package/plugin/agents/code-reviewer.md +45 -0
- package/plugin/agents/copywriter.md +48 -0
- package/plugin/agents/database-admin.md +49 -0
- package/plugin/agents/debugger.md +55 -0
- package/plugin/agents/docs-manager.md +52 -0
- package/plugin/agents/fullstack-developer.md +67 -0
- package/plugin/agents/git-manager.md +48 -0
- package/plugin/agents/journal-writer.md +51 -0
- package/plugin/agents/oracle.md +91 -0
- package/plugin/agents/pipeline-architect.md +52 -0
- package/plugin/agents/planner.md +60 -0
- package/plugin/agents/project-manager.md +43 -0
- package/plugin/agents/researcher.md +37 -0
- package/plugin/agents/scout.md +37 -0
- package/plugin/agents/security-auditor.md +53 -0
- package/plugin/agents/sprint-master.md +84 -0
- package/plugin/agents/tester.md +50 -0
- package/plugin/agents/ui-ux-designer.md +61 -0
- package/plugin/agents/vulnerability-scanner.md +53 -0
- package/plugin/commands/context/.gitkeep +0 -0
- package/plugin/commands/context/checkpoint.md +20 -0
- package/plugin/commands/context/index.md +17 -0
- package/plugin/commands/context/load.md +16 -0
- package/plugin/commands/context/mode.md +20 -0
- package/plugin/commands/context/spawn-collect.md +14 -0
- package/plugin/commands/context/spawn.md +20 -0
- package/plugin/commands/design/.gitkeep +0 -0
- package/plugin/commands/design/cro.md +27 -0
- package/plugin/commands/design/enhance.md +16 -0
- package/plugin/commands/design/fast.md +17 -0
- package/plugin/commands/design/good.md +23 -0
- package/plugin/commands/design/screenshot.md +21 -0
- package/plugin/commands/dev/.gitkeep +0 -0
- package/plugin/commands/dev/feature.md +25 -0
- package/plugin/commands/dev/fix-ci.md +23 -0
- package/plugin/commands/dev/fix-fast.md +19 -0
- package/plugin/commands/dev/fix-hard.md +25 -0
- package/plugin/commands/dev/fix-logs.md +21 -0
- package/plugin/commands/dev/fix-test.md +23 -0
- package/plugin/commands/dev/fix.md +22 -0
- package/plugin/commands/dev/review.md +31 -0
- package/plugin/commands/dev/tdd.md +29 -0
- package/plugin/commands/dev/test.md +25 -0
- package/plugin/commands/git/.gitkeep +0 -0
- package/plugin/commands/git/cm.md +13 -0
- package/plugin/commands/git/commit.md +31 -0
- package/plugin/commands/git/cp.md +14 -0
- package/plugin/commands/git/deploy.md +21 -0
- package/plugin/commands/git/pr.md +20 -0
- package/plugin/commands/git/ship.md +29 -0
- package/plugin/commands/omega/.gitkeep +0 -0
- package/plugin/commands/omega/1000x.md +41 -0
- package/plugin/commands/omega/100x.md +39 -0
- package/plugin/commands/omega/10x.md +47 -0
- package/plugin/commands/omega/dimensions.md +26 -0
- package/plugin/commands/omega/principles.md +43 -0
- package/plugin/commands/planning/.gitkeep +0 -0
- package/plugin/commands/planning/ask.md +21 -0
- package/plugin/commands/planning/brainstorm.md +33 -0
- package/plugin/commands/planning/doc.md +28 -0
- package/plugin/commands/planning/execute-plan.md +28 -0
- package/plugin/commands/planning/plan-detailed.md +32 -0
- package/plugin/commands/planning/plan-parallel.md +35 -0
- package/plugin/commands/planning/plan.md +39 -0
- package/plugin/commands/planning/research.md +39 -0
- package/plugin/commands/quality/.gitkeep +0 -0
- package/plugin/commands/quality/api-gen.md +25 -0
- package/plugin/commands/quality/lint.md +15 -0
- package/plugin/commands/quality/optimize.md +23 -0
- package/plugin/commands/quality/refactor.md +22 -0
- package/plugin/commands/quality/security-scan.md +28 -0
- package/plugin/commands/sprint/.gitkeep +0 -0
- package/plugin/commands/sprint/backlog-add.md +21 -0
- package/plugin/commands/sprint/backlog-prioritize.md +18 -0
- package/plugin/commands/sprint/backlog-show.md +25 -0
- package/plugin/commands/sprint/init.md +27 -0
- package/plugin/commands/sprint/sprint-current.md +22 -0
- package/plugin/commands/sprint/sprint-end.md +33 -0
- package/plugin/commands/sprint/sprint-new.md +31 -0
- package/plugin/commands/sprint/sprint-start.md +17 -0
- package/plugin/commands/sprint/team-ask.md +21 -0
- package/plugin/commands/sprint/team-run.md +29 -0
- package/plugin/commands/sprint/team-status.md +23 -0
- package/plugin/commands/sprint/vision-set.md +21 -0
- package/plugin/commands/sprint/vision-show.md +15 -0
- package/plugin/mcp/.gitkeep +0 -0
- package/plugin/mcp/.mcp.json +20 -0
- package/plugin/mcp/README.md +68 -0
- package/plugin/modes/.gitkeep +0 -0
- package/plugin/modes/autonomous.md +48 -0
- package/plugin/modes/brainstorm.md +33 -0
- package/plugin/modes/deep-research.md +41 -0
- package/plugin/modes/default.md +25 -0
- package/plugin/modes/implementation.md +35 -0
- package/plugin/modes/omega.md +38 -0
- package/plugin/modes/orchestration.md +41 -0
- package/plugin/modes/review.md +44 -0
- package/plugin/modes/token-efficient.md +37 -0
- package/plugin/skills/databases/.gitkeep +0 -0
- package/plugin/skills/databases/mongodb/SKILL.md +43 -0
- package/plugin/skills/databases/postgresql/SKILL.md +43 -0
- package/plugin/skills/databases/prisma/SKILL.md +55 -0
- package/plugin/skills/databases/redis/SKILL.md +41 -0
- package/plugin/skills/devops/.gitkeep +0 -0
- package/plugin/skills/devops/aws/SKILL.md +51 -0
- package/plugin/skills/devops/docker/SKILL.md +54 -0
- package/plugin/skills/devops/github-actions/SKILL.md +63 -0
- package/plugin/skills/devops/kubernetes/SKILL.md +64 -0
- package/plugin/skills/frameworks/.gitkeep +0 -0
- package/plugin/skills/frameworks/django/SKILL.md +47 -0
- package/plugin/skills/frameworks/express/SKILL.md +55 -0
- package/plugin/skills/frameworks/fastapi/SKILL.md +58 -0
- package/plugin/skills/frameworks/laravel/SKILL.md +65 -0
- package/plugin/skills/frameworks/nestjs/SKILL.md +67 -0
- package/plugin/skills/frameworks/nextjs/SKILL.md +77 -0
- package/plugin/skills/frameworks/rails/SKILL.md +56 -0
- package/plugin/skills/frameworks/react/SKILL.md +61 -0
- package/plugin/skills/frameworks/spring/SKILL.md +70 -0
- package/plugin/skills/frameworks/vue/SKILL.md +62 -0
- package/plugin/skills/frontend/.gitkeep +0 -0
- package/plugin/skills/frontend/accessibility/SKILL.md +52 -0
- package/plugin/skills/frontend/frontend-design/SKILL.md +47 -0
- package/plugin/skills/frontend/responsive/SKILL.md +46 -0
- package/plugin/skills/frontend/shadcn-ui/SKILL.md +58 -0
- package/plugin/skills/frontend/tailwindcss/SKILL.md +52 -0
- package/plugin/skills/frontend/threejs/SKILL.md +59 -0
- package/plugin/skills/languages/.gitkeep +0 -0
- package/plugin/skills/languages/javascript/SKILL.md +62 -0
- package/plugin/skills/languages/python/SKILL.md +63 -0
- package/plugin/skills/languages/typescript/SKILL.md +66 -0
- package/plugin/skills/methodology/.gitkeep +0 -0
- package/plugin/skills/methodology/brainstorming/SKILL.md +34 -0
- package/plugin/skills/methodology/defense-in-depth/SKILL.md +51 -0
- package/plugin/skills/methodology/dispatching-parallel-agents/SKILL.md +43 -0
- package/plugin/skills/methodology/executing-plans/SKILL.md +34 -0
- package/plugin/skills/methodology/finishing-development-branch/SKILL.md +41 -0
- package/plugin/skills/methodology/receiving-code-review/SKILL.md +41 -0
- package/plugin/skills/methodology/requesting-code-review/SKILL.md +38 -0
- package/plugin/skills/methodology/root-cause-tracing/SKILL.md +53 -0
- package/plugin/skills/methodology/systematic-debugging/SKILL.md +50 -0
- package/plugin/skills/methodology/test-driven-development/SKILL.md +39 -0
- package/plugin/skills/methodology/testing-anti-patterns/SKILL.md +50 -0
- package/plugin/skills/methodology/token-optimization/SKILL.md +51 -0
- package/plugin/skills/methodology/verification-before-completion/SKILL.md +32 -0
- package/plugin/skills/methodology/writing-plans/SKILL.md +34 -0
- package/plugin/skills/omega/.gitkeep +0 -0
- package/plugin/skills/omega/omega-architecture/SKILL.md +59 -0
- package/plugin/skills/omega/omega-coding/SKILL.md +61 -0
- package/plugin/skills/omega/omega-sprint/SKILL.md +64 -0
- package/plugin/skills/omega/omega-testing/SKILL.md +71 -0
- package/plugin/skills/omega/omega-thinking/SKILL.md +54 -0
- package/plugin/skills/security/.gitkeep +0 -0
- package/plugin/skills/security/better-auth/SKILL.md +53 -0
- package/plugin/skills/security/oauth/SKILL.md +50 -0
- package/plugin/skills/security/owasp/SKILL.md +57 -0
- package/plugin/skills/testing/.gitkeep +0 -0
- package/plugin/skills/testing/playwright/SKILL.md +60 -0
- package/plugin/skills/testing/pytest/SKILL.md +58 -0
- package/plugin/skills/testing/vitest/SKILL.md +64 -0
- package/templates/.gitkeep +0 -0
- package/templates/OMEGA.md +80 -0
- package/templates/backlog.yaml +25 -0
- package/templates/config.yaml +44 -0
- package/templates/settings.json +20 -0
- package/templates/vision.yaml +30 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docker
|
|
3
|
+
description: Docker containerization. Use for Dockerfiles, docker-compose, container patterns.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Docker Skill
|
|
7
|
+
|
|
8
|
+
## Multi-stage Build
|
|
9
|
+
```dockerfile
|
|
10
|
+
FROM node:20-alpine AS builder
|
|
11
|
+
WORKDIR /app
|
|
12
|
+
COPY package*.json ./
|
|
13
|
+
RUN npm ci
|
|
14
|
+
COPY . .
|
|
15
|
+
RUN npm run build
|
|
16
|
+
|
|
17
|
+
FROM node:20-alpine
|
|
18
|
+
WORKDIR /app
|
|
19
|
+
COPY --from=builder /app/dist ./dist
|
|
20
|
+
COPY --from=builder /app/node_modules ./node_modules
|
|
21
|
+
EXPOSE 3000
|
|
22
|
+
CMD ["node", "dist/index.js"]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Docker Compose
|
|
26
|
+
```yaml
|
|
27
|
+
version: '3.8'
|
|
28
|
+
services:
|
|
29
|
+
app:
|
|
30
|
+
build: .
|
|
31
|
+
ports:
|
|
32
|
+
- "3000:3000"
|
|
33
|
+
environment:
|
|
34
|
+
- DATABASE_URL=postgres://db:5432/app
|
|
35
|
+
depends_on:
|
|
36
|
+
- db
|
|
37
|
+
|
|
38
|
+
db:
|
|
39
|
+
image: postgres:15-alpine
|
|
40
|
+
environment:
|
|
41
|
+
- POSTGRES_DB=app
|
|
42
|
+
volumes:
|
|
43
|
+
- pgdata:/var/lib/postgresql/data
|
|
44
|
+
|
|
45
|
+
volumes:
|
|
46
|
+
pgdata:
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Best Practices
|
|
50
|
+
- Use specific base image tags
|
|
51
|
+
- Multi-stage builds
|
|
52
|
+
- .dockerignore file
|
|
53
|
+
- Non-root user
|
|
54
|
+
- Health checks
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: github-actions
|
|
3
|
+
description: GitHub Actions CI/CD. Use for workflows, automation, deployments.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GitHub Actions Skill
|
|
7
|
+
|
|
8
|
+
## CI Workflow
|
|
9
|
+
```yaml
|
|
10
|
+
name: CI
|
|
11
|
+
|
|
12
|
+
on:
|
|
13
|
+
push:
|
|
14
|
+
branches: [main]
|
|
15
|
+
pull_request:
|
|
16
|
+
branches: [main]
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
test:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: '20'
|
|
28
|
+
cache: 'npm'
|
|
29
|
+
|
|
30
|
+
- run: npm ci
|
|
31
|
+
- run: npm run lint
|
|
32
|
+
- run: npm test
|
|
33
|
+
- run: npm run build
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Deploy Workflow
|
|
37
|
+
```yaml
|
|
38
|
+
deploy:
|
|
39
|
+
needs: test
|
|
40
|
+
if: github.ref == 'refs/heads/main'
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v4
|
|
45
|
+
- run: npm ci && npm run build
|
|
46
|
+
- uses: some/deploy-action@v1
|
|
47
|
+
with:
|
|
48
|
+
token: ${{ secrets.DEPLOY_TOKEN }}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Matrix Build
|
|
52
|
+
```yaml
|
|
53
|
+
strategy:
|
|
54
|
+
matrix:
|
|
55
|
+
node: [18, 20, 22]
|
|
56
|
+
os: [ubuntu-latest, macos-latest]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Best Practices
|
|
60
|
+
- Cache dependencies
|
|
61
|
+
- Use matrix for multiple versions
|
|
62
|
+
- Use secrets for sensitive data
|
|
63
|
+
- Add status badges
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kubernetes
|
|
3
|
+
description: Kubernetes orchestration. Use for K8s manifests, deployments, services.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Kubernetes Skill
|
|
7
|
+
|
|
8
|
+
## Deployment
|
|
9
|
+
```yaml
|
|
10
|
+
apiVersion: apps/v1
|
|
11
|
+
kind: Deployment
|
|
12
|
+
metadata:
|
|
13
|
+
name: app
|
|
14
|
+
spec:
|
|
15
|
+
replicas: 3
|
|
16
|
+
selector:
|
|
17
|
+
matchLabels:
|
|
18
|
+
app: myapp
|
|
19
|
+
template:
|
|
20
|
+
metadata:
|
|
21
|
+
labels:
|
|
22
|
+
app: myapp
|
|
23
|
+
spec:
|
|
24
|
+
containers:
|
|
25
|
+
- name: app
|
|
26
|
+
image: myapp:latest
|
|
27
|
+
ports:
|
|
28
|
+
- containerPort: 3000
|
|
29
|
+
resources:
|
|
30
|
+
limits:
|
|
31
|
+
memory: "256Mi"
|
|
32
|
+
cpu: "500m"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Service
|
|
36
|
+
```yaml
|
|
37
|
+
apiVersion: v1
|
|
38
|
+
kind: Service
|
|
39
|
+
metadata:
|
|
40
|
+
name: app-service
|
|
41
|
+
spec:
|
|
42
|
+
selector:
|
|
43
|
+
app: myapp
|
|
44
|
+
ports:
|
|
45
|
+
- port: 80
|
|
46
|
+
targetPort: 3000
|
|
47
|
+
type: LoadBalancer
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## ConfigMap
|
|
51
|
+
```yaml
|
|
52
|
+
apiVersion: v1
|
|
53
|
+
kind: ConfigMap
|
|
54
|
+
metadata:
|
|
55
|
+
name: app-config
|
|
56
|
+
data:
|
|
57
|
+
API_URL: "https://api.example.com"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Best Practices
|
|
61
|
+
- Use namespaces
|
|
62
|
+
- Set resource limits
|
|
63
|
+
- Use health probes
|
|
64
|
+
- Use ConfigMaps/Secrets
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: django
|
|
3
|
+
description: Django development. Use for Django projects, ORM, admin, templates.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Django Skill
|
|
7
|
+
|
|
8
|
+
## Patterns
|
|
9
|
+
|
|
10
|
+
### Model
|
|
11
|
+
```python
|
|
12
|
+
from django.db import models
|
|
13
|
+
|
|
14
|
+
class User(models.Model):
|
|
15
|
+
email = models.EmailField(unique=True)
|
|
16
|
+
created_at = models.DateTimeField(auto_now_add=True)
|
|
17
|
+
|
|
18
|
+
class Meta:
|
|
19
|
+
ordering = ['-created_at']
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### View
|
|
23
|
+
```python
|
|
24
|
+
from django.views import View
|
|
25
|
+
from django.http import JsonResponse
|
|
26
|
+
|
|
27
|
+
class UserView(View):
|
|
28
|
+
def get(self, request, id):
|
|
29
|
+
user = User.objects.get(id=id)
|
|
30
|
+
return JsonResponse({'email': user.email})
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Serializer (DRF)
|
|
34
|
+
```python
|
|
35
|
+
from rest_framework import serializers
|
|
36
|
+
|
|
37
|
+
class UserSerializer(serializers.ModelSerializer):
|
|
38
|
+
class Meta:
|
|
39
|
+
model = User
|
|
40
|
+
fields = ['id', 'email', 'created_at']
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Best Practices
|
|
44
|
+
- Use class-based views
|
|
45
|
+
- Use Django REST Framework
|
|
46
|
+
- Use migrations
|
|
47
|
+
- Use signals sparingly
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: express
|
|
3
|
+
description: Express.js development. Use for Express APIs, middleware, routing.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Express.js Skill
|
|
7
|
+
|
|
8
|
+
## Patterns
|
|
9
|
+
|
|
10
|
+
### Basic Setup
|
|
11
|
+
```javascript
|
|
12
|
+
import express from 'express';
|
|
13
|
+
|
|
14
|
+
const app = express();
|
|
15
|
+
app.use(express.json());
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Routes
|
|
19
|
+
```javascript
|
|
20
|
+
app.get('/users', async (req, res) => {
|
|
21
|
+
const users = await db.users.findMany();
|
|
22
|
+
res.json(users);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
app.post('/users', async (req, res) => {
|
|
26
|
+
const user = await db.users.create(req.body);
|
|
27
|
+
res.status(201).json(user);
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Middleware
|
|
32
|
+
```javascript
|
|
33
|
+
function authMiddleware(req, res, next) {
|
|
34
|
+
const token = req.headers.authorization;
|
|
35
|
+
if (!token) return res.status(401).json({ error: 'Unauthorized' });
|
|
36
|
+
req.user = verifyToken(token);
|
|
37
|
+
next();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
app.use('/api', authMiddleware);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Error Handler
|
|
44
|
+
```javascript
|
|
45
|
+
app.use((err, req, res, next) => {
|
|
46
|
+
console.error(err);
|
|
47
|
+
res.status(500).json({ error: 'Internal Server Error' });
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Best Practices
|
|
52
|
+
- Use async/await with try/catch
|
|
53
|
+
- Use middleware for cross-cutting concerns
|
|
54
|
+
- Validate input
|
|
55
|
+
- Use proper status codes
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fastapi
|
|
3
|
+
description: FastAPI development. Use for FastAPI projects, async APIs, Pydantic models.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FastAPI Skill
|
|
7
|
+
|
|
8
|
+
## Setup
|
|
9
|
+
```python
|
|
10
|
+
from fastapi import FastAPI, HTTPException, Depends
|
|
11
|
+
from pydantic import BaseModel
|
|
12
|
+
|
|
13
|
+
app = FastAPI()
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Patterns
|
|
17
|
+
|
|
18
|
+
### Route with Pydantic
|
|
19
|
+
```python
|
|
20
|
+
class UserCreate(BaseModel):
|
|
21
|
+
email: str
|
|
22
|
+
password: str
|
|
23
|
+
|
|
24
|
+
class User(BaseModel):
|
|
25
|
+
id: str
|
|
26
|
+
email: str
|
|
27
|
+
|
|
28
|
+
@app.post("/users", response_model=User)
|
|
29
|
+
async def create_user(user: UserCreate):
|
|
30
|
+
return await db.create_user(user)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Dependency Injection
|
|
34
|
+
```python
|
|
35
|
+
async def get_db():
|
|
36
|
+
db = Database()
|
|
37
|
+
try:
|
|
38
|
+
yield db
|
|
39
|
+
finally:
|
|
40
|
+
await db.close()
|
|
41
|
+
|
|
42
|
+
@app.get("/users/{id}")
|
|
43
|
+
async def get_user(id: str, db: Database = Depends(get_db)):
|
|
44
|
+
return await db.get_user(id)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Error Handling
|
|
48
|
+
```python
|
|
49
|
+
@app.exception_handler(ValueError)
|
|
50
|
+
async def value_error_handler(request, exc):
|
|
51
|
+
return JSONResponse(status_code=400, content={"error": str(exc)})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Best Practices
|
|
55
|
+
- Use Pydantic for validation
|
|
56
|
+
- Use async/await
|
|
57
|
+
- Use dependency injection
|
|
58
|
+
- Document with OpenAPI
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: laravel
|
|
3
|
+
description: Laravel PHP development. Use for Laravel projects, Eloquent, Blade.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Laravel Skill
|
|
7
|
+
|
|
8
|
+
## Patterns
|
|
9
|
+
|
|
10
|
+
### Model
|
|
11
|
+
```php
|
|
12
|
+
class User extends Model
|
|
13
|
+
{
|
|
14
|
+
protected $fillable = ['email', 'password'];
|
|
15
|
+
protected $hidden = ['password'];
|
|
16
|
+
|
|
17
|
+
public function posts()
|
|
18
|
+
{
|
|
19
|
+
return $this->hasMany(Post::class);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Controller
|
|
25
|
+
```php
|
|
26
|
+
class UserController extends Controller
|
|
27
|
+
{
|
|
28
|
+
public function index()
|
|
29
|
+
{
|
|
30
|
+
return User::all();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public function store(Request $request)
|
|
34
|
+
{
|
|
35
|
+
$validated = $request->validate([
|
|
36
|
+
'email' => 'required|email|unique:users',
|
|
37
|
+
'password' => 'required|min:8',
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
$user = User::create($validated);
|
|
41
|
+
return response()->json($user, 201);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Routes
|
|
47
|
+
```php
|
|
48
|
+
Route::apiResource('users', UserController::class);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Migration
|
|
52
|
+
```php
|
|
53
|
+
Schema::create('users', function (Blueprint $table) {
|
|
54
|
+
$table->id();
|
|
55
|
+
$table->string('email')->unique();
|
|
56
|
+
$table->string('password');
|
|
57
|
+
$table->timestamps();
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Best Practices
|
|
62
|
+
- Use Eloquent relationships
|
|
63
|
+
- Use Form Requests
|
|
64
|
+
- Use Resources for API responses
|
|
65
|
+
- Use Jobs for async
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nestjs
|
|
3
|
+
description: NestJS development. Use for NestJS projects, modules, dependency injection.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# NestJS Skill
|
|
7
|
+
|
|
8
|
+
## Patterns
|
|
9
|
+
|
|
10
|
+
### Module
|
|
11
|
+
```typescript
|
|
12
|
+
@Module({
|
|
13
|
+
imports: [DatabaseModule],
|
|
14
|
+
controllers: [UsersController],
|
|
15
|
+
providers: [UsersService],
|
|
16
|
+
exports: [UsersService],
|
|
17
|
+
})
|
|
18
|
+
export class UsersModule {}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Controller
|
|
22
|
+
```typescript
|
|
23
|
+
@Controller('users')
|
|
24
|
+
export class UsersController {
|
|
25
|
+
constructor(private usersService: UsersService) {}
|
|
26
|
+
|
|
27
|
+
@Get()
|
|
28
|
+
findAll() {
|
|
29
|
+
return this.usersService.findAll();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Post()
|
|
33
|
+
create(@Body() dto: CreateUserDto) {
|
|
34
|
+
return this.usersService.create(dto);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Service
|
|
40
|
+
```typescript
|
|
41
|
+
@Injectable()
|
|
42
|
+
export class UsersService {
|
|
43
|
+
constructor(private db: DatabaseService) {}
|
|
44
|
+
|
|
45
|
+
async findAll() {
|
|
46
|
+
return this.db.users.findMany();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### DTO
|
|
52
|
+
```typescript
|
|
53
|
+
export class CreateUserDto {
|
|
54
|
+
@IsEmail()
|
|
55
|
+
email: string;
|
|
56
|
+
|
|
57
|
+
@IsString()
|
|
58
|
+
@MinLength(8)
|
|
59
|
+
password: string;
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Best Practices
|
|
64
|
+
- Use modules for organization
|
|
65
|
+
- Use DTOs for validation
|
|
66
|
+
- Use dependency injection
|
|
67
|
+
- Use guards for auth
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nextjs
|
|
3
|
+
description: Next.js development. Use for Next.js projects, App Router, Server Components, Server Actions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Next.js Skill
|
|
7
|
+
|
|
8
|
+
## App Router
|
|
9
|
+
|
|
10
|
+
### Server Component (default)
|
|
11
|
+
```tsx
|
|
12
|
+
// app/users/page.tsx
|
|
13
|
+
async function UsersPage() {
|
|
14
|
+
const users = await fetch('/api/users').then(r => r.json());
|
|
15
|
+
return <UserList users={users} />;
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Client Component
|
|
20
|
+
```tsx
|
|
21
|
+
'use client';
|
|
22
|
+
|
|
23
|
+
import { useState } from 'react';
|
|
24
|
+
|
|
25
|
+
export function Counter() {
|
|
26
|
+
const [count, setCount] = useState(0);
|
|
27
|
+
return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Server Action
|
|
32
|
+
```tsx
|
|
33
|
+
'use server';
|
|
34
|
+
|
|
35
|
+
import { revalidatePath } from 'next/cache';
|
|
36
|
+
|
|
37
|
+
export async function createUser(formData: FormData) {
|
|
38
|
+
await db.users.create({
|
|
39
|
+
email: formData.get('email'),
|
|
40
|
+
});
|
|
41
|
+
revalidatePath('/users');
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Route Handler
|
|
46
|
+
```tsx
|
|
47
|
+
// app/api/users/route.ts
|
|
48
|
+
export async function GET() {
|
|
49
|
+
const users = await db.users.findMany();
|
|
50
|
+
return Response.json(users);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function POST(request: Request) {
|
|
54
|
+
const body = await request.json();
|
|
55
|
+
const user = await db.users.create(body);
|
|
56
|
+
return Response.json(user, { status: 201 });
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## File Structure
|
|
61
|
+
```
|
|
62
|
+
app/
|
|
63
|
+
├── layout.tsx
|
|
64
|
+
├── page.tsx
|
|
65
|
+
├── users/
|
|
66
|
+
│ ├── page.tsx
|
|
67
|
+
│ └── [id]/page.tsx
|
|
68
|
+
└── api/
|
|
69
|
+
└── users/route.ts
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Best Practices
|
|
73
|
+
- Default to Server Components
|
|
74
|
+
- Use 'use client' only when needed
|
|
75
|
+
- Use Server Actions for mutations
|
|
76
|
+
- Use loading.tsx for loading states
|
|
77
|
+
- Use error.tsx for error handling
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rails
|
|
3
|
+
description: Ruby on Rails development. Use for Rails projects, MVC, ActiveRecord.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Ruby on Rails Skill
|
|
7
|
+
|
|
8
|
+
## Patterns
|
|
9
|
+
|
|
10
|
+
### Model
|
|
11
|
+
```ruby
|
|
12
|
+
class User < ApplicationRecord
|
|
13
|
+
validates :email, presence: true, uniqueness: true
|
|
14
|
+
has_many :posts
|
|
15
|
+
|
|
16
|
+
scope :active, -> { where(active: true) }
|
|
17
|
+
end
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Controller
|
|
21
|
+
```ruby
|
|
22
|
+
class UsersController < ApplicationController
|
|
23
|
+
def index
|
|
24
|
+
@users = User.all
|
|
25
|
+
render json: @users
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def create
|
|
29
|
+
@user = User.new(user_params)
|
|
30
|
+
if @user.save
|
|
31
|
+
render json: @user, status: :created
|
|
32
|
+
else
|
|
33
|
+
render json: @user.errors, status: :unprocessable_entity
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def user_params
|
|
40
|
+
params.require(:user).permit(:email, :password)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Routes
|
|
46
|
+
```ruby
|
|
47
|
+
Rails.application.routes.draw do
|
|
48
|
+
resources :users, only: [:index, :create, :show]
|
|
49
|
+
end
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Best Practices
|
|
53
|
+
- Use strong params
|
|
54
|
+
- Use scopes for queries
|
|
55
|
+
- Use concerns for shared code
|
|
56
|
+
- Use background jobs for async
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react
|
|
3
|
+
description: React development. Use for React components, hooks, state management.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# React Skill
|
|
7
|
+
|
|
8
|
+
## Patterns
|
|
9
|
+
|
|
10
|
+
### Functional Component
|
|
11
|
+
```tsx
|
|
12
|
+
interface ButtonProps {
|
|
13
|
+
onClick: () => void;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function Button({ onClick, children }: ButtonProps) {
|
|
18
|
+
return <button onClick={onClick}>{children}</button>;
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Hooks
|
|
23
|
+
```tsx
|
|
24
|
+
// useState
|
|
25
|
+
const [count, setCount] = useState(0);
|
|
26
|
+
|
|
27
|
+
// useEffect
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
fetchData();
|
|
30
|
+
return () => cleanup();
|
|
31
|
+
}, [dependency]);
|
|
32
|
+
|
|
33
|
+
// useCallback
|
|
34
|
+
const handleClick = useCallback(() => {
|
|
35
|
+
doSomething(value);
|
|
36
|
+
}, [value]);
|
|
37
|
+
|
|
38
|
+
// useMemo
|
|
39
|
+
const computed = useMemo(() => expensiveCalc(data), [data]);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Custom Hook
|
|
43
|
+
```tsx
|
|
44
|
+
function useUser(id: string) {
|
|
45
|
+
const [user, setUser] = useState<User | null>(null);
|
|
46
|
+
const [loading, setLoading] = useState(true);
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
fetchUser(id).then(setUser).finally(() => setLoading(false));
|
|
50
|
+
}, [id]);
|
|
51
|
+
|
|
52
|
+
return { user, loading };
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Best Practices
|
|
57
|
+
- Use functional components
|
|
58
|
+
- Keep components small
|
|
59
|
+
- Lift state up when needed
|
|
60
|
+
- Use custom hooks for logic
|
|
61
|
+
- Memoize expensive operations
|