create-merlin-brain 3.22.0 → 4.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/README.md +38 -4
- package/bin/merlin-ask.cjs +111 -0
- package/bin/merlin-cli.cjs +22 -0
- package/bin/runtime-adapters.cjs +709 -28
- package/dist/server/api/client.d.ts +2 -0
- package/dist/server/api/client.d.ts.map +1 -1
- package/dist/server/api/client.js +4 -0
- package/dist/server/api/client.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +56 -4
- package/dist/server/server.js.map +1 -1
- package/dist/server/tools/auto-mode.d.ts +9 -0
- package/dist/server/tools/auto-mode.d.ts.map +1 -0
- package/dist/server/tools/auto-mode.js +231 -0
- package/dist/server/tools/auto-mode.js.map +1 -0
- package/dist/server/tools/computer-use.d.ts +8 -0
- package/dist/server/tools/computer-use.d.ts.map +1 -0
- package/dist/server/tools/computer-use.js +355 -0
- package/dist/server/tools/computer-use.js.map +1 -0
- package/dist/server/tools/dream.d.ts +9 -0
- package/dist/server/tools/dream.d.ts.map +1 -0
- package/dist/server/tools/dream.js +246 -0
- package/dist/server/tools/dream.js.map +1 -0
- package/dist/server/tools/help.d.ts +3 -0
- package/dist/server/tools/help.d.ts.map +1 -0
- package/dist/server/tools/help.js +110 -0
- package/dist/server/tools/help.js.map +1 -0
- package/dist/server/tools/hud.d.ts +13 -0
- package/dist/server/tools/hud.d.ts.map +1 -0
- package/dist/server/tools/hud.js +295 -0
- package/dist/server/tools/hud.js.map +1 -0
- package/dist/server/tools/index.d.ts +5 -0
- package/dist/server/tools/index.d.ts.map +1 -1
- package/dist/server/tools/index.js +5 -0
- package/dist/server/tools/index.js.map +1 -1
- package/dist/server/tools/provider-ask.d.ts +10 -0
- package/dist/server/tools/provider-ask.d.ts.map +1 -0
- package/dist/server/tools/provider-ask.js +234 -0
- package/dist/server/tools/provider-ask.js.map +1 -0
- package/dist/server/tools/rate-limit.d.ts +8 -0
- package/dist/server/tools/rate-limit.d.ts.map +1 -0
- package/dist/server/tools/rate-limit.js +184 -0
- package/dist/server/tools/rate-limit.js.map +1 -0
- package/dist/server/tools/skills.d.ts +16 -0
- package/dist/server/tools/skills.d.ts.map +1 -0
- package/dist/server/tools/skills.js +326 -0
- package/dist/server/tools/skills.js.map +1 -0
- package/dist/server/tools/team-workers.d.ts +7 -0
- package/dist/server/tools/team-workers.d.ts.map +1 -0
- package/dist/server/tools/team-workers.js +271 -0
- package/dist/server/tools/team-workers.js.map +1 -0
- package/dist/server/utils/merlin-manifest.d.ts +6 -1
- package/dist/server/utils/merlin-manifest.d.ts.map +1 -1
- package/dist/server/utils/merlin-manifest.js +34 -1
- package/dist/server/utils/merlin-manifest.js.map +1 -1
- package/files/CLAUDE.md +22 -0
- package/files/hooks/rate-limit-watch.sh +120 -0
- package/files/hooks/statusline.sh +148 -0
- package/files/merlin/skills/SKILLS-INDEX.md +82 -0
- package/files/merlin/skills/automation/payments.md +14 -0
- package/files/merlin/skills/automation/webhooks.md +14 -0
- package/files/merlin/skills/coding/accessibility.md +14 -0
- package/files/merlin/skills/coding/api-design.md +14 -0
- package/files/merlin/skills/coding/debug-mode.md +14 -0
- package/files/merlin/skills/coding/focus-mode.md +14 -0
- package/files/merlin/skills/coding/loop.md +14 -0
- package/files/merlin/skills/coding/performance.md +14 -0
- package/files/merlin/skills/coding/react-patterns.md +51 -0
- package/files/merlin/skills/coding/security-hardening.md +56 -0
- package/files/merlin/skills/coding/verify.md +14 -0
- package/files/merlin/skills/communication/dispatcher.md +40 -0
- package/files/merlin/skills/communication/email-gmail.md +31 -0
- package/files/merlin/skills/communication/telegram.md +50 -0
- package/files/merlin/skills/communication/whatsapp.md +47 -0
- package/files/merlin/skills/data/google-sheets.md +14 -0
- package/files/merlin/skills/design/animation.md +14 -0
- package/files/merlin/skills/devops/docker-containers.md +14 -0
- package/files/merlin/skills/research/brainstorm.md +14 -0
- package/files/merlin/skills/testing/tdd-workflow.md +58 -0
- package/package.json +4 -2
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# Merlin Hook: Notification — HUD Statusline
|
|
4
|
+
#
|
|
5
|
+
# Outputs a single-line statusline for Claude Code's status bar with live
|
|
6
|
+
# Merlin session metrics. Reads only local state files — no network calls.
|
|
7
|
+
#
|
|
8
|
+
# Output JSON:
|
|
9
|
+
# {"hookSpecificOutput":{"hookEventName":"Notification","statusLine":"..."}}
|
|
10
|
+
#
|
|
11
|
+
# Metrics included:
|
|
12
|
+
# - Merlin version (from ~/.claude/merlin/VERSION)
|
|
13
|
+
# - Active agents (from ~/.merlin/state/agents.json)
|
|
14
|
+
# - Task progress (from ~/.merlin/state/tasks.json)
|
|
15
|
+
# - Session cost (from ~/.merlin/state/session-cost.json)
|
|
16
|
+
# - Git branch (git rev-parse, fast)
|
|
17
|
+
# - Context age (from ~/.merlin/state/last-context.json)
|
|
18
|
+
# - Rate limit (from ~/.merlin/state/rate-limit.json)
|
|
19
|
+
#
|
|
20
|
+
# Always exits 0 — purely advisory.
|
|
21
|
+
#
|
|
22
|
+
set -euo pipefail
|
|
23
|
+
trap 'echo "{}"; exit 0' ERR
|
|
24
|
+
|
|
25
|
+
STATE_DIR="${HOME}/.merlin/state"
|
|
26
|
+
MERLIN_DIR="${HOME}/.claude/merlin"
|
|
27
|
+
|
|
28
|
+
# ── Version ────────────────────────────────────────────────────────────────
|
|
29
|
+
VERSION_FILE="${MERLIN_DIR}/VERSION"
|
|
30
|
+
if [ -f "${VERSION_FILE}" ]; then
|
|
31
|
+
MERLIN_VERSION=$(cat "${VERSION_FILE}" 2>/dev/null | tr -d '[:space:]' || echo "--")
|
|
32
|
+
else
|
|
33
|
+
MERLIN_VERSION="--"
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# ── Active agents ──────────────────────────────────────────────────────────
|
|
37
|
+
AGENTS_FILE="${STATE_DIR}/agents.json"
|
|
38
|
+
if [ -f "${AGENTS_FILE}" ]; then
|
|
39
|
+
if command -v jq >/dev/null 2>&1; then
|
|
40
|
+
AGENT_COUNT=$(jq '.active // 0' "${AGENTS_FILE}" 2>/dev/null || echo "0")
|
|
41
|
+
else
|
|
42
|
+
AGENT_COUNT=$(grep -o '"active":[0-9]*' "${AGENTS_FILE}" 2>/dev/null | grep -o '[0-9]*$' || echo "0")
|
|
43
|
+
fi
|
|
44
|
+
else
|
|
45
|
+
AGENT_COUNT="0"
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
# ── Task progress ──────────────────────────────────────────────────────────
|
|
49
|
+
TASKS_FILE="${STATE_DIR}/tasks.json"
|
|
50
|
+
if [ -f "${TASKS_FILE}" ]; then
|
|
51
|
+
if command -v jq >/dev/null 2>&1; then
|
|
52
|
+
TASKS_DONE=$(jq '.done // 0' "${TASKS_FILE}" 2>/dev/null || echo "0")
|
|
53
|
+
TASKS_TOTAL=$(jq '.total // 0' "${TASKS_FILE}" 2>/dev/null || echo "0")
|
|
54
|
+
else
|
|
55
|
+
TASKS_DONE=$(grep -o '"done":[0-9]*' "${TASKS_FILE}" 2>/dev/null | grep -o '[0-9]*$' || echo "0")
|
|
56
|
+
TASKS_TOTAL=$(grep -o '"total":[0-9]*' "${TASKS_FILE}" 2>/dev/null | grep -o '[0-9]*$' || echo "0")
|
|
57
|
+
fi
|
|
58
|
+
if [ "${TASKS_TOTAL}" -gt 0 ] 2>/dev/null; then
|
|
59
|
+
TASKS_DISPLAY="${TASKS_DONE}/${TASKS_TOTAL} tasks"
|
|
60
|
+
else
|
|
61
|
+
TASKS_DISPLAY="--"
|
|
62
|
+
fi
|
|
63
|
+
else
|
|
64
|
+
TASKS_DISPLAY="--"
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
# ── Session cost ───────────────────────────────────────────────────────────
|
|
68
|
+
COST_FILE="${STATE_DIR}/session-cost.json"
|
|
69
|
+
if [ -f "${COST_FILE}" ]; then
|
|
70
|
+
if command -v jq >/dev/null 2>&1; then
|
|
71
|
+
COST_RAW=$(jq -r '.total // ""' "${COST_FILE}" 2>/dev/null || echo "")
|
|
72
|
+
else
|
|
73
|
+
COST_RAW=$(grep -o '"total":"[^"]*"' "${COST_FILE}" 2>/dev/null | cut -d'"' -f4 || echo "")
|
|
74
|
+
# Also try numeric total
|
|
75
|
+
if [ -z "${COST_RAW}" ]; then
|
|
76
|
+
COST_RAW=$(grep -o '"total":[0-9.]*' "${COST_FILE}" 2>/dev/null | grep -o '[0-9.]*$' || echo "")
|
|
77
|
+
fi
|
|
78
|
+
fi
|
|
79
|
+
if [ -n "${COST_RAW}" ] && [ "${COST_RAW}" != "null" ]; then
|
|
80
|
+
COST_DISPLAY="\$${COST_RAW}"
|
|
81
|
+
else
|
|
82
|
+
COST_DISPLAY="--"
|
|
83
|
+
fi
|
|
84
|
+
else
|
|
85
|
+
COST_DISPLAY="--"
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
# ── Git branch ─────────────────────────────────────────────────────────────
|
|
89
|
+
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "--")
|
|
90
|
+
|
|
91
|
+
# ── Context freshness ──────────────────────────────────────────────────────
|
|
92
|
+
CTX_FILE="${STATE_DIR}/last-context.json"
|
|
93
|
+
if [ -f "${CTX_FILE}" ]; then
|
|
94
|
+
if command -v jq >/dev/null 2>&1; then
|
|
95
|
+
LAST_TS=$(jq -r '.timestamp // ""' "${CTX_FILE}" 2>/dev/null || echo "")
|
|
96
|
+
else
|
|
97
|
+
LAST_TS=$(grep -o '"timestamp":[0-9]*' "${CTX_FILE}" 2>/dev/null | grep -o '[0-9]*$' || echo "")
|
|
98
|
+
fi
|
|
99
|
+
if [ -n "${LAST_TS}" ] && [ "${LAST_TS}" != "null" ] && [ "${LAST_TS}" != "" ]; then
|
|
100
|
+
NOW=$(date +%s)
|
|
101
|
+
ELAPSED=$(( NOW - LAST_TS ))
|
|
102
|
+
if [ "${ELAPSED}" -lt 60 ]; then
|
|
103
|
+
CTX_DISPLAY="${ELAPSED}s"
|
|
104
|
+
elif [ "${ELAPSED}" -lt 3600 ]; then
|
|
105
|
+
CTX_DISPLAY="$(( ELAPSED / 60 ))m"
|
|
106
|
+
else
|
|
107
|
+
CTX_DISPLAY="$(( ELAPSED / 3600 ))h"
|
|
108
|
+
fi
|
|
109
|
+
else
|
|
110
|
+
CTX_DISPLAY="--"
|
|
111
|
+
fi
|
|
112
|
+
else
|
|
113
|
+
CTX_DISPLAY="--"
|
|
114
|
+
fi
|
|
115
|
+
|
|
116
|
+
# ── Rate limit status ──────────────────────────────────────────────────────
|
|
117
|
+
RATE_FILE="${STATE_DIR}/rate-limit.json"
|
|
118
|
+
if [ -f "${RATE_FILE}" ]; then
|
|
119
|
+
if command -v jq >/dev/null 2>&1; then
|
|
120
|
+
RATE_STATUS=$(jq -r '.status // "OK"' "${RATE_FILE}" 2>/dev/null || echo "OK")
|
|
121
|
+
else
|
|
122
|
+
RATE_STATUS=$(grep -o '"status":"[^"]*"' "${RATE_FILE}" 2>/dev/null | cut -d'"' -f4 || echo "OK")
|
|
123
|
+
fi
|
|
124
|
+
# Normalize to OK / WARN / BLOCKED
|
|
125
|
+
case "${RATE_STATUS}" in
|
|
126
|
+
OK|ok) RATE_DISPLAY="OK" ;;
|
|
127
|
+
WARN|warn) RATE_DISPLAY="WARN" ;;
|
|
128
|
+
BLOCKED|blocked) RATE_DISPLAY="BLOCKED" ;;
|
|
129
|
+
*) RATE_DISPLAY="OK" ;;
|
|
130
|
+
esac
|
|
131
|
+
else
|
|
132
|
+
RATE_DISPLAY="OK"
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
# ── Compose statusline ─────────────────────────────────────────────────────
|
|
136
|
+
STATUSLINE="v${MERLIN_VERSION} | ${AGENT_COUNT} agents | ${TASKS_DISPLAY} | ${COST_DISPLAY} | ${GIT_BRANCH} | ctx:${CTX_DISPLAY} | rate:${RATE_DISPLAY}"
|
|
137
|
+
|
|
138
|
+
# ── Output ─────────────────────────────────────────────────────────────────
|
|
139
|
+
if command -v jq >/dev/null 2>&1; then
|
|
140
|
+
jq -n --arg sl "${STATUSLINE}" \
|
|
141
|
+
'{"hookSpecificOutput":{"hookEventName":"Notification","statusLine":$sl}}'
|
|
142
|
+
else
|
|
143
|
+
# Escape double-quotes in statusline for safe inline embedding
|
|
144
|
+
SAFE="${STATUSLINE//\"/\\\"}"
|
|
145
|
+
printf '{"hookSpecificOutput":{"hookEventName":"Notification","statusLine":"%s"}}\n' "${SAFE}"
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
exit 0
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Merlin Skills Index
|
|
2
|
+
|
|
3
|
+
When planning or executing a task, search this index to find relevant skills to load.
|
|
4
|
+
Load a skill by reading its full .md file from the matching path. Only load 1-3 skills per task — pick the most relevant ones.
|
|
5
|
+
|
|
6
|
+
Skills are prompt injections that enhance your capabilities for specific domains. They don't change what tools you have — they change how you think about the problem.
|
|
7
|
+
|
|
8
|
+
## How to Use
|
|
9
|
+
|
|
10
|
+
1. Read this index to find skills matching the current task
|
|
11
|
+
2. Load the skill .md file (e.g., `~/.claude/merlin/skills/coding/react-patterns.md`)
|
|
12
|
+
3. Follow the instructions in the skill while executing the task
|
|
13
|
+
4. After the task: if the skill helped, note it. If it was wrong or outdated, improve it.
|
|
14
|
+
|
|
15
|
+
## Coding > Frontend
|
|
16
|
+
- `coding/react-patterns` — React component patterns, hooks, performance, server components — [react, nextjs, remix, vite]
|
|
17
|
+
- `coding/tailwind-systems` — Design systems with Tailwind CSS, utility patterns, responsive — [tailwind, css, design-system]
|
|
18
|
+
- `coding/css-3d` — Advanced CSS 3D transforms, perspective, immersive effects — [css, 3d, animation]
|
|
19
|
+
- `coding/accessibility` — WCAG compliance, screen readers, keyboard nav, ARIA — [a11y, wcag, accessibility]
|
|
20
|
+
- `coding/performance` — Core Web Vitals, bundle optimization, lazy loading, caching — [performance, lighthouse, web-vitals]
|
|
21
|
+
- `coding/api-design` — RESTful conventions, versioning, OpenAPI specs, pagination — [api, rest, openapi, express]
|
|
22
|
+
|
|
23
|
+
## Coding > Security
|
|
24
|
+
- `coding/security-hardening` — OWASP top 10, input validation, auth patterns, XSS/CSRF — [security, owasp, auth, validation]
|
|
25
|
+
|
|
26
|
+
## Testing
|
|
27
|
+
- `testing/tdd-workflow` — Red-green-refactor, write tests first, Jest/Vitest/pytest — [tdd, testing, jest, vitest]
|
|
28
|
+
- `testing/e2e-playwright` — End-to-end browser testing with Playwright — [playwright, e2e, testing, browser]
|
|
29
|
+
|
|
30
|
+
## DevOps
|
|
31
|
+
- `devops/docker-containers` — Dockerfiles, multi-stage builds, docker-compose, minimal images — [docker, containers, devops]
|
|
32
|
+
- `devops/ci-cd` — GitHub Actions, CI pipelines, automated testing and deployment — [ci, cd, github-actions, deployment]
|
|
33
|
+
|
|
34
|
+
## Design
|
|
35
|
+
- `design/animation` — Smooth animations with Framer Motion, GSAP, CSS transitions — [animation, framer-motion, gsap, motion]
|
|
36
|
+
|
|
37
|
+
## Research
|
|
38
|
+
- `research/brainstorm` — Explore 3-5 approaches before committing, present pros/cons — [brainstorm, ideation, exploration]
|
|
39
|
+
- `research/challenge` — Devil's advocate review, poke holes, identify weaknesses — [challenge, review, critique]
|
|
40
|
+
- `research/deep-research` — Study problem domain before proposing, find best practices — [research, analysis, study]
|
|
41
|
+
- `research/step-by-step` — Break task into numbered steps, get approval before building — [planning, steps, breakdown]
|
|
42
|
+
|
|
43
|
+
## Execution
|
|
44
|
+
- `coding/focus-mode` — GSD mode: minimal questions, maximum speed, make decisions — [focus, gsd, speed, autonomous]
|
|
45
|
+
- `coding/loop` — Test-fix loop: run tests, fix failures, repeat until green — [loop, testing, iteration]
|
|
46
|
+
- `coding/verify` — Validate results: run code, check output, confirm requirements met — [verify, validation, qa]
|
|
47
|
+
- `coding/debug-mode` — Systematic debugging: reproduce, hypothesize, test, fix — [debug, troubleshoot, investigate]
|
|
48
|
+
|
|
49
|
+
## Communication (Non-Coding)
|
|
50
|
+
- `communication/whatsapp` — Two-way WhatsApp via Business API — direct, no middleware — [whatsapp, messaging, business-api]
|
|
51
|
+
- `communication/telegram` — Telegram bot via Bot API — direct HTTP calls — [telegram, bot, bot-api]
|
|
52
|
+
- `communication/dispatcher` — Central hub: receives from all channels, dispatches to specialists — [dispatcher, hub, routing]
|
|
53
|
+
- `communication/email-gmail` — Gmail read/send/draft/search via API — [email, gmail, mailbox]
|
|
54
|
+
- `communication/discord` — Discord bot: channels, roles, embeds, slash commands — [discord, bot]
|
|
55
|
+
- `communication/slack` — Slack integration: channels, DMs, Block Kit, threads — [slack, messaging, workspace]
|
|
56
|
+
- `communication/email` — Email automation: HTML emails, campaigns, auto-respond — [email, sendgrid, resend, smtp]
|
|
57
|
+
- `communication/sms-voice` — Twilio SMS and voice: notifications, IVR, 2FA — [twilio, sms, voice, phone]
|
|
58
|
+
|
|
59
|
+
## Automation (Non-Coding)
|
|
60
|
+
- `automation/webhooks` — Receive/send webhooks, parse payloads, validate signatures — [webhooks, http, events]
|
|
61
|
+
- `automation/zapier-make` — Connect 5000+ apps via Zapier/Make automation — [zapier, make, automation, integrations]
|
|
62
|
+
- `automation/scheduled-tasks` — Cron jobs, recurring automations, periodic reports — [cron, scheduling, automation]
|
|
63
|
+
- `automation/monitoring` — Health checks, uptime monitoring, auto-alerts — [monitoring, heartbeat, uptime]
|
|
64
|
+
- `automation/payments` — Stripe: checkout, subscriptions, invoices, webhooks — [stripe, payments, billing]
|
|
65
|
+
|
|
66
|
+
## Data (Non-Coding)
|
|
67
|
+
- `data/google-sheets` — Read/write Google Sheets, formulas, batch operations — [sheets, google, spreadsheet]
|
|
68
|
+
- `data/airtable` — Airtable CRUD, filters, linked records, attachments — [airtable, database, no-code]
|
|
69
|
+
- `data/notion` — Notion pages, databases, content sync, knowledge base — [notion, wiki, knowledge-base]
|
|
70
|
+
- `data/analytics` — Analytics platforms, dashboards, KPIs, reports — [analytics, mixpanel, amplitude, reporting]
|
|
71
|
+
|
|
72
|
+
## Marketing (Non-Coding)
|
|
73
|
+
- `marketing/social-media` — Post to Twitter/X, LinkedIn, Instagram, schedule content — [social, twitter, linkedin, instagram]
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Evolution
|
|
78
|
+
|
|
79
|
+
Skills evolve. When you improve a skill after using it:
|
|
80
|
+
1. Update the skill .md file with your improvement
|
|
81
|
+
2. Increment the `version` in the frontmatter
|
|
82
|
+
3. Add a line to `evolution` in the frontmatter describing what changed
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: payments
|
|
3
|
+
name: Stripe Payments
|
|
4
|
+
domain: non-coding
|
|
5
|
+
category: automation
|
|
6
|
+
tags: [stripe, payments, billing, subscriptions, checkout]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
# Stripe Payments
|
|
14
|
+
Interact with Stripe for payment processing. Create Checkout Sessions for one-time payments. Manage Subscriptions with billing cycles. Handle webhooks for payment events (payment_intent.succeeded, invoice.paid, customer.subscription.updated). Process refunds. Generate invoices. Always use Stripe's official SDK, never raw API calls with card numbers.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: webhooks
|
|
3
|
+
name: Webhooks
|
|
4
|
+
domain: non-coding
|
|
5
|
+
category: automation
|
|
6
|
+
tags: [webhooks, http, events, callbacks, integrations]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
# Webhooks
|
|
14
|
+
Set up webhook endpoints to receive events from external services (GitHub, Stripe, Shopify, etc.) and send outgoing webhooks to trigger actions in other systems. Parse payloads, validate signatures (HMAC-SHA256), handle retries with idempotency keys, and route events to appropriate handlers. Always verify webhook authenticity before processing.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: accessibility
|
|
3
|
+
name: Accessibility (a11y)
|
|
4
|
+
domain: coding
|
|
5
|
+
category: frontend
|
|
6
|
+
tags: [a11y, wcag, accessibility, screen-reader, keyboard]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
# Accessibility (a11y)
|
|
14
|
+
Ensure all UI elements are accessible. Add ARIA labels to interactive elements without visible text. Support full keyboard navigation (Tab, Enter, Escape, Arrow keys). Maintain color contrast ratios (WCAG AA: 4.5:1 for text, 3:1 for large text). Use semantic HTML (button not div, nav not div, heading hierarchy). Test with screen reader patterns. Every image needs alt text. Focus management on route changes and modal open/close.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: api-design
|
|
3
|
+
name: REST API Design
|
|
4
|
+
domain: coding
|
|
5
|
+
category: backend
|
|
6
|
+
tags: [api, rest, openapi, express, fastify, pagination]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
# REST API Design
|
|
14
|
+
Design RESTful APIs following best practices: proper HTTP verbs (GET=read, POST=create, PUT=replace, PATCH=update, DELETE=remove), meaningful status codes (200, 201, 204, 400, 401, 403, 404, 409, 500), cursor-based pagination for lists, consistent error response shape `{ error: string, code: string }`, API versioning via URL prefix (/v1/), and OpenAPI/Swagger documentation for every endpoint.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: debug-mode
|
|
3
|
+
name: Debug Mode
|
|
4
|
+
domain: coding
|
|
5
|
+
category: execution
|
|
6
|
+
tags: [debug, troubleshoot, investigate, hypothesis]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
# Debug Mode
|
|
14
|
+
Use systematic debugging: 1) Reproduce the issue with a minimal test case, 2) Form a hypothesis about the root cause, 3) Test the hypothesis with targeted investigation, 4) Fix or form new hypothesis. Show your reasoning at each step. Never shotgun-debug (changing random things hoping something works).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: focus-mode
|
|
3
|
+
name: Focus Mode (GSD)
|
|
4
|
+
domain: coding
|
|
5
|
+
category: execution
|
|
6
|
+
tags: [focus, gsd, speed, autonomous, minimal-questions]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
# Focus Mode (GSD)
|
|
14
|
+
Work in Get Stuff Done mode. Make reasonable decisions without asking. Build quickly and show results. Only ask questions when truly blocked. Prefer action over deliberation. If two approaches seem equally valid, pick the simpler one and move on.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: loop
|
|
3
|
+
name: Test-Fix Loop
|
|
4
|
+
domain: coding
|
|
5
|
+
category: execution
|
|
6
|
+
tags: [loop, testing, iteration, fix]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
# Test-Fix Loop
|
|
14
|
+
After implementing, run tests. If tests fail, fix the issues and re-run. Repeat until all tests pass. Show the test results at each iteration. Maximum 5 iterations — if still failing after 5, stop and explain what's wrong.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: performance
|
|
3
|
+
name: Performance Optimization
|
|
4
|
+
domain: coding
|
|
5
|
+
category: frontend
|
|
6
|
+
tags: [performance, lighthouse, web-vitals, bundle, lazy-loading]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
# Performance Optimization
|
|
14
|
+
Optimize for performance. Use code splitting and dynamic imports for route-level chunks. Lazy load below-fold images and heavy components. Set proper Cache-Control headers for static assets. Minimize main thread blocking (defer non-critical JS). Target Core Web Vitals: LCP < 2.5s, FID < 100ms, CLS < 0.1. Use `next/image` or equivalent for automatic image optimization.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: react-patterns
|
|
3
|
+
name: React Patterns
|
|
4
|
+
domain: coding
|
|
5
|
+
category: frontend
|
|
6
|
+
tags: [react, nextjs, remix, vite, hooks, components, server-components]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# React Patterns
|
|
15
|
+
|
|
16
|
+
You are an expert in modern React patterns. Apply these when building or reviewing React code.
|
|
17
|
+
|
|
18
|
+
## Component Architecture
|
|
19
|
+
- Prefer function components with hooks over class components
|
|
20
|
+
- Co-locate related code: component + hook + types + styles in the same directory
|
|
21
|
+
- Extract custom hooks when logic is reused across 2+ components
|
|
22
|
+
- Use `React.memo()` only when profiling shows re-render cost (not preemptively)
|
|
23
|
+
|
|
24
|
+
## Hooks
|
|
25
|
+
- `useState` for simple local state; `useReducer` when state transitions are complex
|
|
26
|
+
- `useCallback` and `useMemo` only when passing to memoized children or expensive computations
|
|
27
|
+
- Custom hooks should start with `use` and return a typed object (not a tuple for >2 values)
|
|
28
|
+
- `useEffect` cleanup: always return cleanup functions for subscriptions, timers, event listeners
|
|
29
|
+
|
|
30
|
+
## Server Components (Next.js 13+)
|
|
31
|
+
- Default to Server Components — only add `'use client'` when you need interactivity, hooks, or browser APIs
|
|
32
|
+
- Data fetching belongs in Server Components (no useEffect for initial data)
|
|
33
|
+
- Pass serializable props from Server → Client components (no functions, no classes)
|
|
34
|
+
|
|
35
|
+
## Performance
|
|
36
|
+
- Lazy load heavy components: `const Heavy = dynamic(() => import('./Heavy'), { ssr: false })`
|
|
37
|
+
- Use `Suspense` boundaries around async components
|
|
38
|
+
- Virtualize long lists (react-window, @tanstack/virtual)
|
|
39
|
+
- Image optimization: next/image with explicit width/height, priority for above-fold
|
|
40
|
+
|
|
41
|
+
## Error Handling
|
|
42
|
+
- Wrap route segments with Error Boundaries
|
|
43
|
+
- Use `error.tsx` convention in Next.js App Router
|
|
44
|
+
- Show meaningful fallback UI, not blank screens
|
|
45
|
+
- Log errors to a service (Sentry, LogRocket) in production
|
|
46
|
+
|
|
47
|
+
## State Management
|
|
48
|
+
- Local state first (useState/useReducer) — don't reach for global state prematurely
|
|
49
|
+
- URL state for shareable UI state (search params, filters)
|
|
50
|
+
- Server state via TanStack Query or SWR (not Redux for API data)
|
|
51
|
+
- Global client state only for truly app-wide concerns (auth, theme, locale)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: security-hardening
|
|
3
|
+
name: Security Hardening
|
|
4
|
+
domain: coding
|
|
5
|
+
category: security
|
|
6
|
+
tags: [security, owasp, auth, validation, xss, csrf, injection]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Security Hardening
|
|
15
|
+
|
|
16
|
+
Apply security best practices to every piece of code you write or review.
|
|
17
|
+
|
|
18
|
+
## Input Validation
|
|
19
|
+
- Validate ALL user input at the boundary (API route handler, form submission)
|
|
20
|
+
- Use Zod, Joi, or equivalent schema validation — never trust `typeof` alone
|
|
21
|
+
- Whitelist allowed values rather than blacklisting dangerous ones
|
|
22
|
+
- Validate types, lengths, ranges, formats before processing
|
|
23
|
+
|
|
24
|
+
## Injection Prevention
|
|
25
|
+
- SQL: Use parameterized queries / prepared statements. NEVER string-concatenate user input into SQL
|
|
26
|
+
- NoSQL: Validate query operators. Reject `$gt`, `$regex` etc. from user input
|
|
27
|
+
- Command injection: Use `execFile` (not `exec`). Never pass user input to shell commands
|
|
28
|
+
- Template injection: Sanitize before rendering in templates
|
|
29
|
+
|
|
30
|
+
## Authentication
|
|
31
|
+
- Hash passwords with bcrypt/argon2 (cost factor >= 12)
|
|
32
|
+
- Use constant-time comparison for secrets (`crypto.timingSafeEqual`)
|
|
33
|
+
- JWTs: short expiry (15min access, 7d refresh), validate `iss`, `aud`, `exp`
|
|
34
|
+
- Session IDs: cryptographically random, >= 128 bits entropy
|
|
35
|
+
|
|
36
|
+
## Authorization
|
|
37
|
+
- Check permissions on EVERY protected endpoint (not just the frontend)
|
|
38
|
+
- Verify resource ownership: `WHERE user_id = $authenticatedUser AND id = $resourceId`
|
|
39
|
+
- Use middleware for role checks, not inline if-statements
|
|
40
|
+
- Principle of least privilege: default deny, explicitly grant
|
|
41
|
+
|
|
42
|
+
## XSS Prevention
|
|
43
|
+
- React/Vue auto-escape by default — but `dangerouslySetInnerHTML` / `v-html` bypasses it
|
|
44
|
+
- Sanitize HTML with DOMPurify before rendering user content
|
|
45
|
+
- Set `Content-Security-Policy` headers (no inline scripts)
|
|
46
|
+
- HttpOnly + Secure + SameSite cookies for session tokens
|
|
47
|
+
|
|
48
|
+
## CSRF Protection
|
|
49
|
+
- SameSite=Lax cookies (minimum) or SameSite=Strict
|
|
50
|
+
- CSRF tokens for state-changing operations if using cookies
|
|
51
|
+
- Verify `Origin` / `Referer` headers on sensitive endpoints
|
|
52
|
+
|
|
53
|
+
## Error Handling
|
|
54
|
+
- Never expose stack traces, SQL errors, or internal paths to the client
|
|
55
|
+
- Use generic error messages: "Something went wrong" (log the real error server-side)
|
|
56
|
+
- Return consistent error shapes: `{ error: string, code: string }`
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: verify
|
|
3
|
+
name: Verify Results
|
|
4
|
+
domain: coding
|
|
5
|
+
category: execution
|
|
6
|
+
tags: [verify, validation, qa, check]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
# Verify Results
|
|
14
|
+
After completing the task, verify the result. Run the code, check the output, and confirm it meets the requirements. Report any issues found. Never claim "done" without actually testing.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: dispatcher
|
|
3
|
+
name: Communications Dispatcher
|
|
4
|
+
domain: non-coding
|
|
5
|
+
category: communication
|
|
6
|
+
tags: [dispatcher, hub, routing, whatsapp, telegram, email, always-on]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Communications Dispatcher
|
|
15
|
+
|
|
16
|
+
You are the central communications hub. You receive messages from multiple channels (WhatsApp, Telegram, email) and either respond directly or dispatch tasks to specialist agents.
|
|
17
|
+
|
|
18
|
+
## Your Role
|
|
19
|
+
- You are ALWAYS listening. You run on a heartbeat — checking channels continuously.
|
|
20
|
+
- When a message arrives, you decide: can you handle it, or does it need a specialist?
|
|
21
|
+
- You respond in the same channel the message came from.
|
|
22
|
+
- You maintain context across channels — if someone emails you, then WhatsApps about the same topic, you connect the dots.
|
|
23
|
+
|
|
24
|
+
## Channels
|
|
25
|
+
- **WhatsApp**: Two-way messaging via OpenClaw. You receive and send messages.
|
|
26
|
+
- **Telegram**: Bot integration. Respond to commands and conversations.
|
|
27
|
+
- **Email**: Read from connected Gmail mailboxes. Draft and send replies.
|
|
28
|
+
|
|
29
|
+
## Dispatch Rules
|
|
30
|
+
- Simple questions, scheduling, reminders → handle yourself
|
|
31
|
+
- Code tasks → dispatch to implementation-dev or bug-doctor
|
|
32
|
+
- Content/writing → dispatch to docs-keeper
|
|
33
|
+
- Research → dispatch to researcher
|
|
34
|
+
- Security concerns → dispatch to hardening-guard
|
|
35
|
+
|
|
36
|
+
## Response Style
|
|
37
|
+
- Be concise in WhatsApp/Telegram (people expect short messages)
|
|
38
|
+
- Be more detailed in email (people expect structured responses)
|
|
39
|
+
- Always confirm when dispatching: "I'm sending this to [Agent] — I'll update you when it's done"
|
|
40
|
+
- Proactively update the user on dispatched task progress
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: email-gmail
|
|
3
|
+
name: Gmail Integration
|
|
4
|
+
domain: non-coding
|
|
5
|
+
category: communication
|
|
6
|
+
tags: [email, gmail, mailbox, inbox, send, read, draft]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Gmail Integration
|
|
15
|
+
|
|
16
|
+
You can read from and send emails through connected Gmail mailboxes.
|
|
17
|
+
|
|
18
|
+
## Capabilities
|
|
19
|
+
- Read new emails from connected inboxes
|
|
20
|
+
- Search emails by sender, subject, date, or content
|
|
21
|
+
- Draft and send replies
|
|
22
|
+
- Create new emails with rich formatting
|
|
23
|
+
- Manage labels and organize inbox
|
|
24
|
+
- Handle multiple mailboxes (personal + work)
|
|
25
|
+
|
|
26
|
+
## Rules
|
|
27
|
+
- Never auto-send without user confirmation (draft first, send on approval)
|
|
28
|
+
- Summarize long email threads before responding
|
|
29
|
+
- Detect urgency: flag emails that need immediate attention
|
|
30
|
+
- Respect "do not reply" and unsubscribe patterns
|
|
31
|
+
- Keep sent email tone professional unless user specifies otherwise
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: telegram
|
|
3
|
+
name: Telegram Direct
|
|
4
|
+
domain: non-coding
|
|
5
|
+
category: communication
|
|
6
|
+
tags: [telegram, bot, direct, bot-api, two-way]
|
|
7
|
+
version: 2
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution:
|
|
12
|
+
- "v2: Direct Telegram Bot API — no external dependencies"
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Telegram Direct Integration
|
|
16
|
+
|
|
17
|
+
Send and receive Telegram messages directly via the Bot API. No middleware — direct HTTP calls.
|
|
18
|
+
|
|
19
|
+
## Receiving Messages
|
|
20
|
+
Telegram sends updates to our webhook. Each update has: chat_id, sender info, message text, message_id, date.
|
|
21
|
+
|
|
22
|
+
## Sending Messages
|
|
23
|
+
```
|
|
24
|
+
POST https://api.telegram.org/bot{BOT_TOKEN}/sendMessage
|
|
25
|
+
Content-Type: application/json
|
|
26
|
+
|
|
27
|
+
{
|
|
28
|
+
"chat_id": 123456789,
|
|
29
|
+
"text": "Your message here",
|
|
30
|
+
"parse_mode": "Markdown"
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Key API Methods
|
|
35
|
+
- `sendMessage` — send text (supports Markdown and HTML)
|
|
36
|
+
- `sendPhoto` / `sendDocument` — send media files
|
|
37
|
+
- `editMessageText` — update a sent message (good for progress updates)
|
|
38
|
+
- `deleteMessage` — remove a message
|
|
39
|
+
- `sendChatAction` — show "typing..." indicator
|
|
40
|
+
- `getUpdates` — poll for messages (fallback if webhook fails)
|
|
41
|
+
|
|
42
|
+
## Setup
|
|
43
|
+
- Create a bot via @BotFather on Telegram → get BOT_TOKEN
|
|
44
|
+
- Set webhook: `POST https://api.telegram.org/bot{TOKEN}/setWebhook?url=https://merlin.build/api/hooks/telegram/{userId}`
|
|
45
|
+
|
|
46
|
+
## Response Rules
|
|
47
|
+
- Markdown formatting supported (bold, italic, code blocks)
|
|
48
|
+
- Messages can be longer than WhatsApp — up to 4096 chars
|
|
49
|
+
- Use "typing..." action before long responses: `sendChatAction({ chat_id, action: "typing" })`
|
|
50
|
+
- Reply to specific messages with `reply_to_message_id`
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: whatsapp
|
|
3
|
+
name: WhatsApp Direct
|
|
4
|
+
domain: non-coding
|
|
5
|
+
category: communication
|
|
6
|
+
tags: [whatsapp, messaging, business-api, direct, two-way]
|
|
7
|
+
version: 2
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution:
|
|
12
|
+
- "v2: Direct WhatsApp Business API — no external dependencies"
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# WhatsApp Direct Integration
|
|
16
|
+
|
|
17
|
+
Send and receive WhatsApp messages directly via the WhatsApp Business API. No middleware, no OpenClaw — direct API calls.
|
|
18
|
+
|
|
19
|
+
## Receiving Messages
|
|
20
|
+
Messages arrive via webhook → Merlin API → your Claude session. Each message has: sender phone, text, timestamp, message type (text/image/document).
|
|
21
|
+
|
|
22
|
+
## Sending Messages
|
|
23
|
+
```
|
|
24
|
+
POST https://graph.facebook.com/v21.0/{PHONE_NUMBER_ID}/messages
|
|
25
|
+
Authorization: Bearer {WHATSAPP_ACCESS_TOKEN}
|
|
26
|
+
Content-Type: application/json
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
"messaging_product": "whatsapp",
|
|
30
|
+
"to": "1234567890",
|
|
31
|
+
"type": "text",
|
|
32
|
+
"text": { "body": "Your message here" }
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Message Types
|
|
37
|
+
- Text: simple messages
|
|
38
|
+
- Template: pre-approved messages (required for initiating conversations)
|
|
39
|
+
- Media: images, documents, audio (send URL or upload)
|
|
40
|
+
- Interactive: buttons, lists (for structured choices)
|
|
41
|
+
|
|
42
|
+
## Response Rules
|
|
43
|
+
- Keep under 300 chars — mobile reading
|
|
44
|
+
- Use line breaks, not bullets
|
|
45
|
+
- Respond within seconds
|
|
46
|
+
- Break long content into 2-3 sequential messages
|
|
47
|
+
- Mark messages as read: POST `/{PHONE_NUMBER_ID}/messages` with `{ status: "read", message_id: "..." }`
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: google-sheets
|
|
3
|
+
name: Google Sheets
|
|
4
|
+
domain: non-coding
|
|
5
|
+
category: data
|
|
6
|
+
tags: [sheets, google, spreadsheet, data]
|
|
7
|
+
version: 1
|
|
8
|
+
source: builtin
|
|
9
|
+
successRate: 0
|
|
10
|
+
usageCount: 0
|
|
11
|
+
evolution: []
|
|
12
|
+
---
|
|
13
|
+
# Google Sheets
|
|
14
|
+
Read from and write to Google Sheets. Pull data for analysis, update cells, create new sheets, and use Sheets as a simple database. Support for batch operations (batchUpdate for multiple writes) and formula generation. Use the Google Sheets API v4 with service account credentials for server-side access.
|