clikit-plugin 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/AGENTS.md +46 -0
- package/README.md +282 -0
- package/command/commit.md +137 -0
- package/command/create.md +150 -0
- package/command/debug.md +185 -0
- package/command/design.md +82 -0
- package/command/handoff.md +95 -0
- package/command/import-plan.md +175 -0
- package/command/init.md +112 -0
- package/command/issue.md +110 -0
- package/command/plan.md +205 -0
- package/command/pr.md +174 -0
- package/command/research.md +103 -0
- package/command/resume.md +80 -0
- package/command/review-codebase.md +228 -0
- package/command/review.md +135 -0
- package/command/ship.md +109 -0
- package/command/start.md +77 -0
- package/command/status.md +123 -0
- package/command/verify.md +79 -0
- package/command/vision.md +142 -0
- package/dist/agents/index.d.ts +4 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +103 -0
- package/dist/clikit.schema.json +423 -0
- package/dist/commands/index.d.ts +4 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/config.d.ts +118 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/hooks/auto-format.d.ts +30 -0
- package/dist/hooks/auto-format.d.ts.map +1 -0
- package/dist/hooks/comment-checker.d.ts +17 -0
- package/dist/hooks/comment-checker.d.ts.map +1 -0
- package/dist/hooks/compaction.d.ts +60 -0
- package/dist/hooks/compaction.d.ts.map +1 -0
- package/dist/hooks/empty-message-sanitizer.d.ts +9 -0
- package/dist/hooks/empty-message-sanitizer.d.ts.map +1 -0
- package/dist/hooks/env-context.d.ts +43 -0
- package/dist/hooks/env-context.d.ts.map +1 -0
- package/dist/hooks/git-guard.d.ts +14 -0
- package/dist/hooks/git-guard.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +35 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/ritual-enforcer.d.ts +29 -0
- package/dist/hooks/ritual-enforcer.d.ts.map +1 -0
- package/dist/hooks/security-check.d.ts +20 -0
- package/dist/hooks/security-check.d.ts.map +1 -0
- package/dist/hooks/session-notification.d.ts +23 -0
- package/dist/hooks/session-notification.d.ts.map +1 -0
- package/dist/hooks/subagent-question-blocker.d.ts +11 -0
- package/dist/hooks/subagent-question-blocker.d.ts.map +1 -0
- package/dist/hooks/swarm-enforcer.d.ts +31 -0
- package/dist/hooks/swarm-enforcer.d.ts.map +1 -0
- package/dist/hooks/todo-enforcer.d.ts +19 -0
- package/dist/hooks/todo-enforcer.d.ts.map +1 -0
- package/dist/hooks/truncator.d.ts +28 -0
- package/dist/hooks/truncator.d.ts.map +1 -0
- package/dist/hooks/typecheck-gate.d.ts +31 -0
- package/dist/hooks/typecheck-gate.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5785 -0
- package/dist/skills/index.d.ts +9 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/tools/beads-memory-sync.d.ts +17 -0
- package/dist/tools/beads-memory-sync.d.ts.map +1 -0
- package/dist/tools/context-summary.d.ts +21 -0
- package/dist/tools/context-summary.d.ts.map +1 -0
- package/dist/tools/index.d.ts +7 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/memory.d.ts +56 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/observation.d.ts +28 -0
- package/dist/tools/observation.d.ts.map +1 -0
- package/dist/tools/quick-research.d.ts +16 -0
- package/dist/tools/quick-research.d.ts.map +1 -0
- package/dist/tools/swarm.d.ts +57 -0
- package/dist/tools/swarm.d.ts.map +1 -0
- package/dist/types.d.ts +32 -0
- package/dist/types.d.ts.map +1 -0
- package/memory/_templates/handoff.md +114 -0
- package/memory/_templates/plan.md +135 -0
- package/memory/_templates/prd.md +147 -0
- package/memory/_templates/research.md +108 -0
- package/memory/_templates/review.md +117 -0
- package/memory/_templates/spec.md +116 -0
- package/memory/beads/.gitkeep +0 -0
- package/memory/handoffs/.gitkeep +0 -0
- package/memory/plans/.gitkeep +0 -0
- package/memory/prds/.gitkeep +0 -0
- package/memory/research/.gitkeep +0 -0
- package/memory/reviews/.gitkeep +0 -0
- package/memory/specs/.gitkeep +0 -0
- package/package.json +64 -0
- package/skill/accessibility-audit/SKILL.md +115 -0
- package/skill/beads/SKILL.md +56 -0
- package/skill/beads-bridge/SKILL.md +45 -0
- package/skill/brainstorming/SKILL.md +41 -0
- package/skill/chrome-devtools/SKILL.md +36 -0
- package/skill/cloudflare/SKILL.md +96 -0
- package/skill/condition-based-waiting/SKILL.md +92 -0
- package/skill/deep-research/SKILL.md +130 -0
- package/skill/defense-in-depth/SKILL.md +89 -0
- package/skill/design-system-audit/SKILL.md +136 -0
- package/skill/development-lifecycle/SKILL.md +58 -0
- package/skill/dispatching-parallel-agents/SKILL.md +94 -0
- package/skill/executing-plans/SKILL.md +54 -0
- package/skill/figma/SKILL.md +34 -0
- package/skill/finishing-a-development-branch/SKILL.md +127 -0
- package/skill/frontend-aesthetics/SKILL.md +63 -0
- package/skill/gemini-large-context/SKILL.md +80 -0
- package/skill/mockup-to-code/SKILL.md +98 -0
- package/skill/mqdh/SKILL.md +54 -0
- package/skill/notebooklm/SKILL.md +71 -0
- package/skill/playwright/SKILL.md +37 -0
- package/skill/playwriter/SKILL.md +56 -0
- package/skill/polar/SKILL.md +39 -0
- package/skill/receiving-code-review/SKILL.md +47 -0
- package/skill/requesting-code-review/SKILL.md +47 -0
- package/skill/resend/SKILL.md +85 -0
- package/skill/ritual-workflow/SKILL.md +101 -0
- package/skill/root-cause-tracing/SKILL.md +73 -0
- package/skill/session-management/SKILL.md +53 -0
- package/skill/sharing-skills/SKILL.md +50 -0
- package/skill/source-code-research/SKILL.md +138 -0
- package/skill/subagent-driven-development/SKILL.md +69 -0
- package/skill/supabase/SKILL.md +80 -0
- package/skill/supabase-postgres-best-practices/SKILL.md +168 -0
- package/skill/swarm-coordination/SKILL.md +54 -0
- package/skill/systematic-debugging/SKILL.md +58 -0
- package/skill/test-driven-development/SKILL.md +53 -0
- package/skill/testing-anti-patterns/SKILL.md +100 -0
- package/skill/testing-skills-with-subagents/SKILL.md +102 -0
- package/skill/ui-ux-research/SKILL.md +93 -0
- package/skill/using-git-worktrees/SKILL.md +129 -0
- package/skill/v0/SKILL.md +67 -0
- package/skill/v1-run/SKILL.md +85 -0
- package/skill/vercel-react-best-practices/SKILL.md +174 -0
- package/skill/verification-before-completion/SKILL.md +55 -0
- package/skill/visual-analysis/SKILL.md +113 -0
- package/skill/writing-plans/SKILL.md +55 -0
- package/skill/writing-skills/SKILL.md +68 -0
- package/src/agents/AGENTS.md +46 -0
- package/src/agents/build.md +170 -0
- package/src/agents/explore.md +113 -0
- package/src/agents/general.md +92 -0
- package/src/agents/index.ts +64 -0
- package/src/agents/librarian.md +116 -0
- package/src/agents/looker.md +107 -0
- package/src/agents/oracle.md +138 -0
- package/src/agents/plan.md +78 -0
- package/src/agents/review.md +98 -0
- package/src/agents/scout.md +84 -0
- package/src/agents/vision.md +159 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: source-code-research
|
|
3
|
+
description: Use when API documentation is insufficient. Research library implementation details by fetching package source.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Source Code Research Skill
|
|
7
|
+
|
|
8
|
+
You are running the **source-code-research** skill. Go beyond API docs to understand internals.
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
- API docs don't explain behavior
|
|
13
|
+
- Need to understand edge cases
|
|
14
|
+
- Debugging library interactions
|
|
15
|
+
- Learning implementation patterns
|
|
16
|
+
- Verifying documented behavior
|
|
17
|
+
|
|
18
|
+
## Research Protocol
|
|
19
|
+
|
|
20
|
+
### 1. Identify Package
|
|
21
|
+
```bash
|
|
22
|
+
# Find package location
|
|
23
|
+
which <package>
|
|
24
|
+
npm list <package>
|
|
25
|
+
|
|
26
|
+
# Find source location
|
|
27
|
+
ls -la node_modules/<package>/
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 2. Locate Source
|
|
31
|
+
```
|
|
32
|
+
Check for:
|
|
33
|
+
- src/ directory
|
|
34
|
+
- lib/ directory
|
|
35
|
+
- dist/ with sourcemaps
|
|
36
|
+
- TypeScript .ts files
|
|
37
|
+
- Index entry point
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 3. Read Key Files
|
|
41
|
+
Focus on:
|
|
42
|
+
- Entry point (index.js/ts)
|
|
43
|
+
- Main export file
|
|
44
|
+
- Types/interfaces
|
|
45
|
+
- Core implementation
|
|
46
|
+
- Tests (for behavior)
|
|
47
|
+
|
|
48
|
+
### 4. Trace Execution
|
|
49
|
+
- Follow function calls
|
|
50
|
+
- Map data flow
|
|
51
|
+
- Identify decision points
|
|
52
|
+
- Note error handling
|
|
53
|
+
|
|
54
|
+
## Key Questions to Answer
|
|
55
|
+
|
|
56
|
+
| Question | Why |
|
|
57
|
+
|----------|-----|
|
|
58
|
+
| How is this implemented? | Understand behavior |
|
|
59
|
+
| What edge cases exist? | Avoid surprises |
|
|
60
|
+
| How are errors handled? | Proper error handling |
|
|
61
|
+
| What are the types? | TypeScript integration |
|
|
62
|
+
| What are the defaults? | Implicit behavior |
|
|
63
|
+
|
|
64
|
+
## Finding Patterns
|
|
65
|
+
|
|
66
|
+
### Constructor Pattern
|
|
67
|
+
```javascript
|
|
68
|
+
// Look for initialization logic
|
|
69
|
+
class Example {
|
|
70
|
+
constructor(options) {
|
|
71
|
+
this.options = { ...defaults, ...options };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Error Handling Pattern
|
|
77
|
+
```javascript
|
|
78
|
+
// Identify what throws vs returns
|
|
79
|
+
if (!valid) {
|
|
80
|
+
throw new Error('...');
|
|
81
|
+
// or
|
|
82
|
+
return { error: '...' };
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Async Pattern
|
|
87
|
+
```javascript
|
|
88
|
+
// Understand async behavior
|
|
89
|
+
async function process() {
|
|
90
|
+
// Is this parallel or sequential?
|
|
91
|
+
await Promise.all([...]);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Output Format
|
|
96
|
+
|
|
97
|
+
Save to `.opencode/memory/research/[package]-internals.md`:
|
|
98
|
+
|
|
99
|
+
```markdown
|
|
100
|
+
# [Package] Internals
|
|
101
|
+
|
|
102
|
+
## Entry Points
|
|
103
|
+
- Main: [file]
|
|
104
|
+
- Types: [file]
|
|
105
|
+
|
|
106
|
+
## Key Findings
|
|
107
|
+
|
|
108
|
+
### [Feature Name]
|
|
109
|
+
- **Location**: file:line
|
|
110
|
+
- **Behavior**: [description]
|
|
111
|
+
- **Edge Cases**: [list]
|
|
112
|
+
|
|
113
|
+
## Implementation Notes
|
|
114
|
+
[Key patterns discovered]
|
|
115
|
+
|
|
116
|
+
## Gotchas
|
|
117
|
+
[Surprising behaviors]
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Anti-Patterns
|
|
121
|
+
|
|
122
|
+
- Relying only on TypeScript definitions
|
|
123
|
+
- Not reading tests
|
|
124
|
+
- Assuming behavior from name
|
|
125
|
+
- Ignoring error paths
|
|
126
|
+
|
|
127
|
+
## Quick Reference
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Find main entry
|
|
131
|
+
cat node_modules/pkg/package.json | grep main
|
|
132
|
+
|
|
133
|
+
# Find types
|
|
134
|
+
cat node_modules/pkg/package.json | grep types
|
|
135
|
+
|
|
136
|
+
# Check for source
|
|
137
|
+
ls node_modules/pkg/src/
|
|
138
|
+
```
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: subagent-driven-development
|
|
3
|
+
description: Use when working on multi-task development cycles. Fresh subagent per task for fast iteration with code review between tasks via @review.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Subagent-Driven Development Skill
|
|
7
|
+
|
|
8
|
+
You are running the **subagent-driven-development** skill. Work autonomously for hours with quality gates between tasks.
|
|
9
|
+
|
|
10
|
+
## Core Principle
|
|
11
|
+
|
|
12
|
+
Fresh subagent per task. Each task is a clean slate with clear objectives. Code review between tasks via @review agent ensures quality accumulation.
|
|
13
|
+
|
|
14
|
+
## Workflow
|
|
15
|
+
|
|
16
|
+
### 1. Task Breakdown
|
|
17
|
+
- Split work into discrete, completable tasks
|
|
18
|
+
- Each task should be 15-30 minutes of work
|
|
19
|
+
- Tasks should have clear success criteria
|
|
20
|
+
- Order tasks by dependency
|
|
21
|
+
|
|
22
|
+
### 2. Task Execution Cycle
|
|
23
|
+
```
|
|
24
|
+
For each task:
|
|
25
|
+
1. Spawn fresh subagent for task
|
|
26
|
+
2. Subagent completes task autonomously
|
|
27
|
+
3. Run @review for code quality check
|
|
28
|
+
4. Fix issues from review
|
|
29
|
+
5. Commit or stage changes
|
|
30
|
+
6. Move to next task
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 3. Quality Gates
|
|
34
|
+
Between each task:
|
|
35
|
+
- Run @review agent on changed files
|
|
36
|
+
- Address all critical and high-priority issues
|
|
37
|
+
- Verify tests pass
|
|
38
|
+
- Confirm task completion criteria met
|
|
39
|
+
|
|
40
|
+
## Agent Autonomy
|
|
41
|
+
|
|
42
|
+
The subagent works autonomously:
|
|
43
|
+
- No mid-task questions to user
|
|
44
|
+
- Make reasonable assumptions
|
|
45
|
+
- Document decisions in code
|
|
46
|
+
- Flag blockers only when truly stuck
|
|
47
|
+
|
|
48
|
+
## Benefits
|
|
49
|
+
|
|
50
|
+
| Benefit | Why |
|
|
51
|
+
|---------|-----|
|
|
52
|
+
| Fresh context | No accumulated confusion |
|
|
53
|
+
| Fast iteration | Quick task completion |
|
|
54
|
+
| Quality accumulation | Review catches issues early |
|
|
55
|
+
| Autonomous work | Hours of productive work |
|
|
56
|
+
|
|
57
|
+
## Anti-Patterns
|
|
58
|
+
|
|
59
|
+
- Tasks too large (lose the benefit of fresh context)
|
|
60
|
+
- Skipping review between tasks
|
|
61
|
+
- Asking user for every decision
|
|
62
|
+
- No clear success criteria per task
|
|
63
|
+
|
|
64
|
+
## When to Use
|
|
65
|
+
|
|
66
|
+
- Multi-hour development sessions
|
|
67
|
+
- Features with multiple components
|
|
68
|
+
- Refactoring with clear steps
|
|
69
|
+
- Bug fix chains with review gates
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: supabase
|
|
3
|
+
description: Use when working with Supabase databases, edge functions, authentication, real-time subscriptions, or managing Supabase projects.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Supabase Skill
|
|
7
|
+
|
|
8
|
+
Comprehensive Supabase platform MCP covering database operations, edge functions, authentication, real-time features, development tools, debugging, and project management.
|
|
9
|
+
|
|
10
|
+
## Capabilities
|
|
11
|
+
|
|
12
|
+
- **Database Operations**: Query, migrate, manage PostgreSQL
|
|
13
|
+
- **Edge Functions**: Deploy, manage, debug serverless functions
|
|
14
|
+
- **Authentication**: User management, auth providers, JWT handling
|
|
15
|
+
- **Real-time**: Subscribe to database changes
|
|
16
|
+
- **Storage**: File upload, management, signed URLs
|
|
17
|
+
- **Development Tools**: Local development, type generation
|
|
18
|
+
- **Debugging**: Logs, metrics, query analysis
|
|
19
|
+
|
|
20
|
+
## When to Use
|
|
21
|
+
|
|
22
|
+
- Querying or modifying Supabase databases
|
|
23
|
+
- Deploying and managing edge functions
|
|
24
|
+
- Setting up authentication flows
|
|
25
|
+
- Generating TypeScript types from schema
|
|
26
|
+
- Debugging database queries and functions
|
|
27
|
+
- Managing Supabase projects
|
|
28
|
+
|
|
29
|
+
## Key Tools
|
|
30
|
+
|
|
31
|
+
- `query`: Execute SQL queries
|
|
32
|
+
- `migrate`: Run database migrations
|
|
33
|
+
- `deploy_function`: Deploy edge function
|
|
34
|
+
- `generate_types`: Generate TypeScript types
|
|
35
|
+
- `list_logs`: View function/database logs
|
|
36
|
+
- `manage_auth`: User operations
|
|
37
|
+
|
|
38
|
+
## Example Usage
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
// Query database
|
|
42
|
+
query({
|
|
43
|
+
sql: "SELECT * FROM users WHERE active = true LIMIT 10"
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Deploy edge function
|
|
47
|
+
deploy_function({
|
|
48
|
+
name: "send-notification",
|
|
49
|
+
entrypoint: "./functions/send-notification/index.ts"
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
// Generate types
|
|
53
|
+
generate_types({
|
|
54
|
+
output: "./src/types/supabase.ts"
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
// Auth operations
|
|
58
|
+
manage_auth({
|
|
59
|
+
action: "create_user",
|
|
60
|
+
email: "user@example.com",
|
|
61
|
+
password: "secure123"
|
|
62
|
+
})
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Development Workflow
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Local development
|
|
69
|
+
supabase start # Start local stack
|
|
70
|
+
supabase db reset # Reset with migrations
|
|
71
|
+
supabase functions serve # Local function dev
|
|
72
|
+
supabase types gen # Generate types
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Notes
|
|
76
|
+
|
|
77
|
+
- Requires Supabase project credentials
|
|
78
|
+
- Supports both local and remote projects
|
|
79
|
+
- Row Level Security policies respected
|
|
80
|
+
- Connection pooling for serverless
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: supabase-postgres-best-practices
|
|
3
|
+
description: Use when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations from Supabase.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Supabase Postgres Best Practices Skill
|
|
7
|
+
|
|
8
|
+
You are running the **supabase-postgres-best-practices** skill. Postgres optimization from Supabase.
|
|
9
|
+
|
|
10
|
+
## Core Principles
|
|
11
|
+
|
|
12
|
+
Production-hardened patterns from Supabase's managed Postgres experience.
|
|
13
|
+
|
|
14
|
+
## Query Optimization
|
|
15
|
+
|
|
16
|
+
### 1. Index Strategy
|
|
17
|
+
```sql
|
|
18
|
+
-- Index for common query patterns
|
|
19
|
+
CREATE INDEX idx_users_email ON users(email);
|
|
20
|
+
CREATE INDEX idx_posts_user_created ON posts(user_id, created_at DESC);
|
|
21
|
+
|
|
22
|
+
-- Partial index for filtered queries
|
|
23
|
+
CREATE INDEX idx_active_users ON users(email) WHERE active = true;
|
|
24
|
+
|
|
25
|
+
-- GIN for JSONB and arrays
|
|
26
|
+
CREATE INDEX idx_metadata ON items USING GIN(metadata);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. Query Patterns
|
|
30
|
+
```sql
|
|
31
|
+
-- Good: Sargable query
|
|
32
|
+
SELECT * FROM users WHERE email = 'user@example.com';
|
|
33
|
+
|
|
34
|
+
-- Avoid: Function on column prevents index usage
|
|
35
|
+
SELECT * FROM users WHERE LOWER(email) = 'user@example.com';
|
|
36
|
+
|
|
37
|
+
-- Fix: Use functional index or normalize data
|
|
38
|
+
CREATE INDEX idx_users_email_lower ON users(LOWER(email));
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. EXPLAIN ANALYZE
|
|
42
|
+
```sql
|
|
43
|
+
-- Always analyze slow queries
|
|
44
|
+
EXPLAIN ANALYZE SELECT * FROM posts WHERE user_id = 123;
|
|
45
|
+
|
|
46
|
+
-- Look for:
|
|
47
|
+
-- - Seq Scan (should be Index Scan)
|
|
48
|
+
-- - High cost values
|
|
49
|
+
-- - Large row estimates vs actual
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Schema Design
|
|
53
|
+
|
|
54
|
+
### 1. Appropriate Types
|
|
55
|
+
```sql
|
|
56
|
+
-- Use appropriate types
|
|
57
|
+
CREATE TABLE events (
|
|
58
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
59
|
+
created_at TIMESTAMPTZ DEFAULT NOW(), -- Not TIMESTAMP
|
|
60
|
+
status TEXT, -- Not VARCHAR(n)
|
|
61
|
+
metadata JSONB DEFAULT '{}' -- Not JSON
|
|
62
|
+
);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2. Foreign Keys
|
|
66
|
+
```sql
|
|
67
|
+
-- Always index foreign keys
|
|
68
|
+
CREATE TABLE posts (
|
|
69
|
+
id UUID PRIMARY KEY,
|
|
70
|
+
user_id UUID REFERENCES users(id)
|
|
71
|
+
);
|
|
72
|
+
CREATE INDEX idx_posts_user_id ON posts(user_id);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 3. Partitioning
|
|
76
|
+
```sql
|
|
77
|
+
-- Partition large tables by time
|
|
78
|
+
CREATE TABLE events (
|
|
79
|
+
id UUID,
|
|
80
|
+
created_at TIMESTAMPTZ
|
|
81
|
+
) PARTITION BY RANGE (created_at);
|
|
82
|
+
|
|
83
|
+
CREATE TABLE events_2024_01 PARTITION OF events
|
|
84
|
+
FOR VALUES FROM ('2024-01-01') TO ('2024-02-01');
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Connection Management
|
|
88
|
+
|
|
89
|
+
### 1. Connection Pooling
|
|
90
|
+
```javascript
|
|
91
|
+
// Use Supavisor or PgBouncer
|
|
92
|
+
// Transaction mode for serverless
|
|
93
|
+
const pool = new Pool({
|
|
94
|
+
connectionString: process.env.DATABASE_URL,
|
|
95
|
+
max: 10, // Limit connections
|
|
96
|
+
idleTimeoutMillis: 30000,
|
|
97
|
+
connectionTimeoutMillis: 2000
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 2. Prepared Statements
|
|
102
|
+
```sql
|
|
103
|
+
-- Use prepared statements for repeated queries
|
|
104
|
+
PREPARE get_user(UUID) AS
|
|
105
|
+
SELECT * FROM users WHERE id = $1;
|
|
106
|
+
|
|
107
|
+
EXECUTE get_user('uuid-here');
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Performance Checklist
|
|
111
|
+
|
|
112
|
+
| Check | Why |
|
|
113
|
+
|-------|-----|
|
|
114
|
+
| Index foreign keys | Join performance |
|
|
115
|
+
| Use TIMESTAMPTZ | Timezone handling |
|
|
116
|
+
| Use JSONB not JSON | Binary format, indexing |
|
|
117
|
+
| Analyze slow queries | EXPLAIN ANALYZE |
|
|
118
|
+
| Limit connections | Prevent exhaustion |
|
|
119
|
+
|
|
120
|
+
## Common Anti-Patterns
|
|
121
|
+
|
|
122
|
+
| Anti-Pattern | Fix |
|
|
123
|
+
|--------------|-----|
|
|
124
|
+
| SELECT * | Select only needed columns |
|
|
125
|
+
| N+1 queries | Use JOINs or batch fetch |
|
|
126
|
+
| Missing indexes | Add appropriate indexes |
|
|
127
|
+
| VARCHAR(n) | Use TEXT with CHECK constraint |
|
|
128
|
+
| TIMESTAMP | Use TIMESTAMPTZ |
|
|
129
|
+
| Unindexed JSON queries | Use GIN index |
|
|
130
|
+
|
|
131
|
+
## RLS (Row Level Security)
|
|
132
|
+
|
|
133
|
+
```sql
|
|
134
|
+
-- Enable RLS
|
|
135
|
+
ALTER TABLE posts ENABLE ROW LEVEL SECURITY;
|
|
136
|
+
|
|
137
|
+
-- Policy for user's own posts
|
|
138
|
+
CREATE POLICY "Users can manage own posts"
|
|
139
|
+
ON posts FOR ALL
|
|
140
|
+
USING (auth.uid() = user_id)
|
|
141
|
+
WITH CHECK (auth.uid() = user_id);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Monitoring Queries
|
|
145
|
+
|
|
146
|
+
```sql
|
|
147
|
+
-- Find slow queries
|
|
148
|
+
SELECT query, mean_exec_time, calls
|
|
149
|
+
FROM pg_stat_statements
|
|
150
|
+
ORDER BY mean_exec_time DESC
|
|
151
|
+
LIMIT 10;
|
|
152
|
+
|
|
153
|
+
-- Check table bloat
|
|
154
|
+
SELECT schemaname, tablename,
|
|
155
|
+
pg_size_pretty(pg_total_relation_size(schemaname||'.'||tablename)) as size
|
|
156
|
+
FROM pg_tables
|
|
157
|
+
ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Quick Reference
|
|
161
|
+
|
|
162
|
+
| Scenario | Solution |
|
|
163
|
+
|----------|----------|
|
|
164
|
+
| Slow reads | Add index, check EXPLAIN |
|
|
165
|
+
| Slow writes | Reduce indexes, batch inserts |
|
|
166
|
+
| Connection limits | Use pooling |
|
|
167
|
+
| Large tables | Partition by time |
|
|
168
|
+
| JSON queries | GIN index on JSONB |
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: swarm-coordination
|
|
3
|
+
description: Use for implementing plans with multiple independent tasks in parallel using Kimi K2.5 PARL patterns.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Swarm Coordination Skill
|
|
7
|
+
|
|
8
|
+
You are running the **swarm-coordination** skill. Parallel multi-task execution.
|
|
9
|
+
|
|
10
|
+
## PARL Pattern (Parallel Agent Runtime Loop)
|
|
11
|
+
|
|
12
|
+
Kimi K2.5 patterns for coordinating multiple agents:
|
|
13
|
+
|
|
14
|
+
| Phase | Action |
|
|
15
|
+
|-------|--------|
|
|
16
|
+
| Plan | Decompose into independent tasks |
|
|
17
|
+
| Assign | Route tasks to available agents |
|
|
18
|
+
| Run | Execute tasks in parallel |
|
|
19
|
+
| Learn | Aggregate results, iterate |
|
|
20
|
+
|
|
21
|
+
## Task Classification
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
Independent → Parallel execution
|
|
25
|
+
Dependent → Sequential with dependency tracking
|
|
26
|
+
Blocked → Wait for blocker completion
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Anti-Serial-Collapse Detection
|
|
30
|
+
|
|
31
|
+
Warning signs of serial execution:
|
|
32
|
+
- All tasks waiting on one agent
|
|
33
|
+
- Sequential claims despite no dependencies
|
|
34
|
+
- Long queue with no parallelism
|
|
35
|
+
|
|
36
|
+
Mitigations:
|
|
37
|
+
- Rebalance task assignments
|
|
38
|
+
- Split blocking tasks
|
|
39
|
+
- Add more agents to bottleneck role
|
|
40
|
+
|
|
41
|
+
## Graceful Shutdown
|
|
42
|
+
|
|
43
|
+
1. Complete in-progress tasks
|
|
44
|
+
2. Checkpoint state to Beads
|
|
45
|
+
3. Release all file reservations
|
|
46
|
+
4. Sync to git
|
|
47
|
+
5. Broadcast session end
|
|
48
|
+
|
|
49
|
+
## Best Practices
|
|
50
|
+
|
|
51
|
+
- Claim only ready (unblocked) tasks
|
|
52
|
+
- Reserve files early, release promptly
|
|
53
|
+
- Use `beads-village_broadcast` for coordination
|
|
54
|
+
- Check `beads-village_discover` for active agents
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: systematic-debugging
|
|
3
|
+
description: Use when encountering a bug. Enforces evidence-based 4-phase debugging process.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Systematic Debugging Skill
|
|
7
|
+
|
|
8
|
+
You are running the **systematic-debugging** skill. No guessing. No random changes.
|
|
9
|
+
|
|
10
|
+
## 4-Phase Process
|
|
11
|
+
|
|
12
|
+
### Phase 1: Reproduce
|
|
13
|
+
- Create a minimal reproduction case
|
|
14
|
+
- Document exact steps to trigger
|
|
15
|
+
- Verify it's reproducible (not intermittent)
|
|
16
|
+
|
|
17
|
+
### Phase 2: Isolate
|
|
18
|
+
- Binary search: Comment out half the code
|
|
19
|
+
- Which half contains the bug?
|
|
20
|
+
- Repeat until isolated to smallest possible unit
|
|
21
|
+
|
|
22
|
+
### Phase 3: Identify
|
|
23
|
+
- Read the isolated code carefully
|
|
24
|
+
- Trace variable values
|
|
25
|
+
- Add instrumentation (console.log, debugger)
|
|
26
|
+
- Understand WHY it fails, not just WHERE
|
|
27
|
+
|
|
28
|
+
### Phase 4: Verify
|
|
29
|
+
- Fix the root cause
|
|
30
|
+
- Run tests to confirm fix
|
|
31
|
+
- Check for similar issues elsewhere
|
|
32
|
+
- Add regression test
|
|
33
|
+
|
|
34
|
+
## Rules
|
|
35
|
+
|
|
36
|
+
| Rule | Why |
|
|
37
|
+
|------|-----|
|
|
38
|
+
| No random changes | Masks symptoms, doesn't fix cause |
|
|
39
|
+
| After 3+ failed fixes | Question architectural assumptions |
|
|
40
|
+
| Always reproduce first | Can't fix what you can't trigger |
|
|
41
|
+
| Add regression test | Prevent recurrence |
|
|
42
|
+
|
|
43
|
+
## Instrumentation
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
// Stack trace
|
|
47
|
+
console.error('Debug:', new Error().stack);
|
|
48
|
+
|
|
49
|
+
// Variable dump
|
|
50
|
+
console.error('Context:', JSON.stringify({ var1, var2 }, null, 2));
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Red Flags
|
|
54
|
+
|
|
55
|
+
- Changing code without understanding why
|
|
56
|
+
- "Let me try this" without hypothesis
|
|
57
|
+
- Fixing symptoms instead of root cause
|
|
58
|
+
- No reproduction steps
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-driven-development
|
|
3
|
+
description: Use when implementing any feature. Enforces strict RED-GREEN-REFACTOR cycle.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Test-Driven Development Skill
|
|
7
|
+
|
|
8
|
+
You are running the **test-driven-development** skill. No code without tests. No exceptions.
|
|
9
|
+
|
|
10
|
+
## RED-GREEN-REFACTOR
|
|
11
|
+
|
|
12
|
+
### Phase 1: RED
|
|
13
|
+
1. Write a failing test
|
|
14
|
+
2. Run the test — it MUST fail
|
|
15
|
+
3. If it passes, the test is wrong — delete and rewrite
|
|
16
|
+
|
|
17
|
+
### Phase 2: GREEN
|
|
18
|
+
1. Write the MINIMUM code to make the test pass
|
|
19
|
+
2. Run the test — it MUST pass
|
|
20
|
+
3. If it fails, fix the code (not the test)
|
|
21
|
+
|
|
22
|
+
### Phase 3: REFACTOR
|
|
23
|
+
1. Clean up code while keeping tests green
|
|
24
|
+
2. Run tests after each change
|
|
25
|
+
3. Commit when satisfied
|
|
26
|
+
|
|
27
|
+
## Rules
|
|
28
|
+
|
|
29
|
+
| Rule | Enforcement |
|
|
30
|
+
|------|-------------|
|
|
31
|
+
| Write code before test? | DELETE the code. Don't keep as reference. |
|
|
32
|
+
| Test passes unexpectedly? | DELETE the test. It's testing nothing. |
|
|
33
|
+
| Skip RED phase? | Not allowed. Always start with failing test. |
|
|
34
|
+
| "Just this once"? | No. No exceptions. |
|
|
35
|
+
|
|
36
|
+
## Workflow
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
1. Think → What should this do?
|
|
40
|
+
2. RED → Write failing test
|
|
41
|
+
3. Run → Watch it fail
|
|
42
|
+
4. GREEN → Write minimal code
|
|
43
|
+
5. Run → Watch it pass
|
|
44
|
+
6. REFACTOR → Clean up
|
|
45
|
+
7. Commit
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Red Flags
|
|
49
|
+
|
|
50
|
+
- Writing implementation before test
|
|
51
|
+
- Keeping "reference code" while writing test
|
|
52
|
+
- Skipping "watch it fail" step
|
|
53
|
+
- Test that can never fail
|