ada-agent 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/LICENSE +21 -0
- package/README.md +256 -0
- package/bench/README.md +88 -0
- package/bench/swebench.mjs +242 -0
- package/bin/ada-server.mjs +6 -0
- package/bin/ada.mjs +7 -0
- package/docs/agent-loop.svg +66 -0
- package/docs/architecture.md +139 -0
- package/docs/architecture.svg +73 -0
- package/docs/connectors.md +48 -0
- package/docs/integrations.md +59 -0
- package/docs/login-flow.svg +56 -0
- package/docs/orchestration.md +45 -0
- package/package.json +64 -0
- package/skills/accessibility/SKILL.md +23 -0
- package/skills/add-logging/SKILL.md +23 -0
- package/skills/add-metrics/SKILL.md +23 -0
- package/skills/adr/SKILL.md +24 -0
- package/skills/aesthetic-direction/SKILL.md +24 -0
- package/skills/agent-loop/SKILL.md +23 -0
- package/skills/alerting/SKILL.md +23 -0
- package/skills/alpha-compositing/SKILL.md +23 -0
- package/skills/android-compose/SKILL.md +23 -0
- package/skills/angular-module/SKILL.md +23 -0
- package/skills/ansible-playbook/SKILL.md +24 -0
- package/skills/api-docs/SKILL.md +24 -0
- package/skills/app-store-prep/SKILL.md +23 -0
- package/skills/architecture-diagram/SKILL.md +21 -0
- package/skills/architecture-doc/SKILL.md +24 -0
- package/skills/audit-log/SKILL.md +23 -0
- package/skills/authz-review/SKILL.md +23 -0
- package/skills/aws-lambda/SKILL.md +24 -0
- package/skills/bash-script/SKILL.md +23 -0
- package/skills/batch/SKILL.md +23 -0
- package/skills/bisect/SKILL.md +23 -0
- package/skills/bounding-box/SKILL.md +24 -0
- package/skills/branch-cleanup/SKILL.md +23 -0
- package/skills/bundle-analyze/SKILL.md +23 -0
- package/skills/cache/SKILL.md +23 -0
- package/skills/call-graph/SKILL.md +23 -0
- package/skills/canvas-debug/SKILL.md +23 -0
- package/skills/cdn-setup/SKILL.md +23 -0
- package/skills/changelog/SKILL.md +24 -0
- package/skills/cherry-pick/SKILL.md +23 -0
- package/skills/ci-setup/SKILL.md +23 -0
- package/skills/cleanup/SKILL.md +23 -0
- package/skills/cli-tool/SKILL.md +23 -0
- package/skills/cloudformation/SKILL.md +23 -0
- package/skills/code-examples/SKILL.md +24 -0
- package/skills/code-review/SKILL.md +23 -0
- package/skills/color-palette/SKILL.md +24 -0
- package/skills/color-space/SKILL.md +24 -0
- package/skills/comment-why/SKILL.md +23 -0
- package/skills/commit/SKILL.md +26 -0
- package/skills/complexity-audit/SKILL.md +23 -0
- package/skills/component/SKILL.md +23 -0
- package/skills/component-library/SKILL.md +23 -0
- package/skills/connect-github/SKILL.md +20 -0
- package/skills/connect-mcp/SKILL.md +21 -0
- package/skills/connect-postgres/SKILL.md +20 -0
- package/skills/connect-remote/SKILL.md +23 -0
- package/skills/connect-slack/SKILL.md +20 -0
- package/skills/contract-audit/SKILL.md +25 -0
- package/skills/contributing/SKILL.md +23 -0
- package/skills/cpp-raii/SKILL.md +23 -0
- package/skills/cron-job/SKILL.md +23 -0
- package/skills/cv-preprocess/SKILL.md +24 -0
- package/skills/dark-mode/SKILL.md +24 -0
- package/skills/dashboard/SKILL.md +23 -0
- package/skills/dashboard-ui/SKILL.md +23 -0
- package/skills/data-export/SKILL.md +23 -0
- package/skills/data-validation/SKILL.md +23 -0
- package/skills/dataframe/SKILL.md +23 -0
- package/skills/db-index/SKILL.md +24 -0
- package/skills/dead-code/SKILL.md +23 -0
- package/skills/debug/SKILL.md +24 -0
- package/skills/deck-review/SKILL.md +24 -0
- package/skills/dedupe/SKILL.md +23 -0
- package/skills/dedupe-deps/SKILL.md +23 -0
- package/skills/dependency-audit/SKILL.md +23 -0
- package/skills/dependency-update/SKILL.md +23 -0
- package/skills/deploy/SKILL.md +23 -0
- package/skills/design-system/SKILL.md +24 -0
- package/skills/design-tokens/SKILL.md +24 -0
- package/skills/diagram-as-code/SKILL.md +24 -0
- package/skills/diff-explain/SKILL.md +23 -0
- package/skills/django-view/SKILL.md +23 -0
- package/skills/doc-lint/SKILL.md +24 -0
- package/skills/docker-compose/SKILL.md +23 -0
- package/skills/dockerize/SKILL.md +23 -0
- package/skills/docstrings/SKILL.md +23 -0
- package/skills/dotfiles/SKILL.md +23 -0
- package/skills/dpi-scaling/SKILL.md +23 -0
- package/skills/e2e-test/SKILL.md +23 -0
- package/skills/embeddings/SKILL.md +23 -0
- package/skills/empty-states/SKILL.md +23 -0
- package/skills/env-setup/SKILL.md +23 -0
- package/skills/erc20/SKILL.md +24 -0
- package/skills/error-tracking/SKILL.md +23 -0
- package/skills/estimate/SKILL.md +23 -0
- package/skills/etl-pipeline/SKILL.md +24 -0
- package/skills/eval-harness/SKILL.md +23 -0
- package/skills/exif-orientation/SKILL.md +23 -0
- package/skills/explain-code/SKILL.md +23 -0
- package/skills/express-middleware/SKILL.md +23 -0
- package/skills/extract-function/SKILL.md +23 -0
- package/skills/faq/SKILL.md +24 -0
- package/skills/fastapi-endpoint/SKILL.md +23 -0
- package/skills/favicon/SKILL.md +23 -0
- package/skills/feature-engineering/SKILL.md +23 -0
- package/skills/few-shot/SKILL.md +23 -0
- package/skills/find-owner/SKILL.md +23 -0
- package/skills/firmware-driver/SKILL.md +23 -0
- package/skills/fix-flaky-tests/SKILL.md +23 -0
- package/skills/flutter-widget/SKILL.md +23 -0
- package/skills/font-rendering/SKILL.md +23 -0
- package/skills/form-validation/SKILL.md +23 -0
- package/skills/format/SKILL.md +23 -0
- package/skills/game-loop/SKILL.md +23 -0
- package/skills/gas-optimize/SKILL.md +25 -0
- package/skills/gdpr-review/SKILL.md +24 -0
- package/skills/github-actions/SKILL.md +23 -0
- package/skills/glossary/SKILL.md +24 -0
- package/skills/go-idioms/SKILL.md +23 -0
- package/skills/gpu-profile/SKILL.md +23 -0
- package/skills/graphify/SKILL.md +21 -0
- package/skills/graphql-resolver/SKILL.md +23 -0
- package/skills/grpc-service/SKILL.md +23 -0
- package/skills/guardrails/SKILL.md +23 -0
- package/skills/healthcheck/SKILL.md +23 -0
- package/skills/heisenbug/SKILL.md +23 -0
- package/skills/helm-chart/SKILL.md +24 -0
- package/skills/hero-section/SKILL.md +23 -0
- package/skills/html-email/SKILL.md +24 -0
- package/skills/html-form/SKILL.md +23 -0
- package/skills/html-sanitize/SKILL.md +23 -0
- package/skills/html-table/SKILL.md +23 -0
- package/skills/html-to-pdf/SKILL.md +23 -0
- package/skills/http-client/SKILL.md +23 -0
- package/skills/i18n/SKILL.md +23 -0
- package/skills/i2c-spi/SKILL.md +23 -0
- package/skills/image-decode/SKILL.md +24 -0
- package/skills/image-memory/SKILL.md +24 -0
- package/skills/image-perf/SKILL.md +24 -0
- package/skills/image-pipeline/SKILL.md +24 -0
- package/skills/image-upload/SKILL.md +24 -0
- package/skills/infra-cost/SKILL.md +24 -0
- package/skills/input-validation/SKILL.md +23 -0
- package/skills/issue-template/SKILL.md +23 -0
- package/skills/java-streams/SKILL.md +23 -0
- package/skills/k8s-manifest/SKILL.md +23 -0
- package/skills/kotlin-coroutines/SKILL.md +23 -0
- package/skills/landing-page/SKILL.md +24 -0
- package/skills/laravel-controller/SKILL.md +23 -0
- package/skills/lazy-load/SKILL.md +23 -0
- package/skills/license-check/SKILL.md +23 -0
- package/skills/license-header/SKILL.md +23 -0
- package/skills/lint-fix/SKILL.md +23 -0
- package/skills/llm-cost/SKILL.md +23 -0
- package/skills/lockfile-fix/SKILL.md +23 -0
- package/skills/low-power/SKILL.md +23 -0
- package/skills/makefile/SKILL.md +23 -0
- package/skills/man-page/SKILL.md +24 -0
- package/skills/mcp-server/SKILL.md +23 -0
- package/skills/memory-leak/SKILL.md +23 -0
- package/skills/mermaid-diagram/SKILL.md +23 -0
- package/skills/meta-tags/SKILL.md +23 -0
- package/skills/micro-interactions/SKILL.md +23 -0
- package/skills/migration/SKILL.md +23 -0
- package/skills/migration-guide/SKILL.md +24 -0
- package/skills/mkdocs-setup/SKILL.md +24 -0
- package/skills/mobile-permissions/SKILL.md +23 -0
- package/skills/mock-api/SKILL.md +23 -0
- package/skills/modernize/SKILL.md +23 -0
- package/skills/monorepo-setup/SKILL.md +23 -0
- package/skills/motion-design/SKILL.md +23 -0
- package/skills/n-plus-one/SKILL.md +23 -0
- package/skills/naming-review/SKILL.md +23 -0
- package/skills/nextjs-route/SKILL.md +23 -0
- package/skills/nginx-config/SKILL.md +23 -0
- package/skills/ocr-debug/SKILL.md +24 -0
- package/skills/onboard/SKILL.md +23 -0
- package/skills/onboarding-map/SKILL.md +23 -0
- package/skills/open-pr/SKILL.md +24 -0
- package/skills/openapi/SKILL.md +23 -0
- package/skills/opencv-debug/SKILL.md +24 -0
- package/skills/orm-model/SKILL.md +23 -0
- package/skills/owasp-check/SKILL.md +24 -0
- package/skills/page-transitions/SKILL.md +23 -0
- package/skills/pagination/SKILL.md +23 -0
- package/skills/perf-optimize/SKILL.md +23 -0
- package/skills/perf-profile/SKILL.md +23 -0
- package/skills/physics/SKILL.md +23 -0
- package/skills/pitch-deck/SKILL.md +24 -0
- package/skills/pixel-diff/SKILL.md +23 -0
- package/skills/ponytail/SKILL.md +46 -0
- package/skills/postmortem/SKILL.md +24 -0
- package/skills/pptx-deck/SKILL.md +23 -0
- package/skills/pptx-export/SKILL.md +23 -0
- package/skills/pptx-from-markdown/SKILL.md +23 -0
- package/skills/pptx-template/SKILL.md +24 -0
- package/skills/pr-review/SKILL.md +24 -0
- package/skills/precommit/SKILL.md +23 -0
- package/skills/pricing-page/SKILL.md +23 -0
- package/skills/project-overview/SKILL.md +22 -0
- package/skills/prompt-template/SKILL.md +23 -0
- package/skills/property-test/SKILL.md +23 -0
- package/skills/protobuf/SKILL.md +23 -0
- package/skills/py-async/SKILL.md +23 -0
- package/skills/py-typing/SKILL.md +23 -0
- package/skills/query-optimize/SKILL.md +23 -0
- package/skills/rag-pipeline/SKILL.md +23 -0
- package/skills/rails-resource/SKILL.md +23 -0
- package/skills/rate-limit/SKILL.md +23 -0
- package/skills/react-hooks/SKILL.md +23 -0
- package/skills/react-native-screen/SKILL.md +23 -0
- package/skills/react-perf/SKILL.md +23 -0
- package/skills/readme/SKILL.md +24 -0
- package/skills/rebase/SKILL.md +24 -0
- package/skills/refactor/SKILL.md +23 -0
- package/skills/regression-test/SKILL.md +23 -0
- package/skills/release-notes/SKILL.md +24 -0
- package/skills/rename-symbol/SKILL.md +23 -0
- package/skills/repro/SKILL.md +23 -0
- package/skills/resolve-conflicts/SKILL.md +23 -0
- package/skills/responsive/SKILL.md +23 -0
- package/skills/rest-endpoint/SKILL.md +23 -0
- package/skills/retro/SKILL.md +23 -0
- package/skills/rtos-task/SKILL.md +23 -0
- package/skills/runbook/SKILL.md +25 -0
- package/skills/rust-borrow/SKILL.md +23 -0
- package/skills/rust-unsafe-audit/SKILL.md +23 -0
- package/skills/sanitize/SKILL.md +23 -0
- package/skills/schema-design/SKILL.md +23 -0
- package/skills/screenshot-debug/SKILL.md +22 -0
- package/skills/scroll-animation/SKILL.md +23 -0
- package/skills/secret-scan/SKILL.md +23 -0
- package/skills/security-audit/SKILL.md +23 -0
- package/skills/security-review/SKILL.md +23 -0
- package/skills/seed-data/SKILL.md +23 -0
- package/skills/self-review/SKILL.md +23 -0
- package/skills/semantic-html/SKILL.md +23 -0
- package/skills/semver-bump/SKILL.md +24 -0
- package/skills/shader/SKILL.md +23 -0
- package/skills/shader-debug/SKILL.md +23 -0
- package/skills/simplify-conditionals/SKILL.md +23 -0
- package/skills/sitemap/SKILL.md +23 -0
- package/skills/skeleton-loader/SKILL.md +23 -0
- package/skills/slide-charts/SKILL.md +24 -0
- package/skills/slide-outline/SKILL.md +23 -0
- package/skills/snapshot-update/SKILL.md +23 -0
- package/skills/solidity-contract/SKILL.md +25 -0
- package/skills/speaker-notes/SKILL.md +23 -0
- package/skills/spike/SKILL.md +23 -0
- package/skills/split-file/SKILL.md +23 -0
- package/skills/spring-controller/SKILL.md +23 -0
- package/skills/sprite-anim/SKILL.md +23 -0
- package/skills/sql-report/SKILL.md +23 -0
- package/skills/squash/SKILL.md +24 -0
- package/skills/ssl-setup/SKILL.md +23 -0
- package/skills/stacktrace/SKILL.md +23 -0
- package/skills/static-site/SKILL.md +24 -0
- package/skills/structured-logging/SKILL.md +23 -0
- package/skills/svelte-store/SKILL.md +23 -0
- package/skills/swiftui-view/SKILL.md +23 -0
- package/skills/tailwind-theme/SKILL.md +24 -0
- package/skills/tcp-server/SKILL.md +23 -0
- package/skills/tdd/SKILL.md +23 -0
- package/skills/terraform-module/SKILL.md +24 -0
- package/skills/test-coverage/SKILL.md +23 -0
- package/skills/texture-debug/SKILL.md +23 -0
- package/skills/threat-model/SKILL.md +23 -0
- package/skills/thumbnail/SKILL.md +24 -0
- package/skills/todo-scan/SKILL.md +23 -0
- package/skills/tool-definition/SKILL.md +23 -0
- package/skills/trace-flow/SKILL.md +23 -0
- package/skills/tracing/SKILL.md +23 -0
- package/skills/train-model/SKILL.md +24 -0
- package/skills/tree-shake/SKILL.md +23 -0
- package/skills/ts-generics/SKILL.md +23 -0
- package/skills/ts-strict/SKILL.md +23 -0
- package/skills/tui-app/SKILL.md +23 -0
- package/skills/tutorial/SKILL.md +24 -0
- package/skills/type-tighten/SKILL.md +23 -0
- package/skills/typography/SKILL.md +24 -0
- package/skills/ui-bug-repro/SKILL.md +23 -0
- package/skills/ui-polish/SKILL.md +24 -0
- package/skills/ui-review/SKILL.md +24 -0
- package/skills/vendor/SKILL.md +23 -0
- package/skills/visual-diff-ci/SKILL.md +24 -0
- package/skills/visual-regression/SKILL.md +23 -0
- package/skills/vue-composition/SKILL.md +23 -0
- package/skills/web-component/SKILL.md +23 -0
- package/skills/web-fonts/SKILL.md +24 -0
- package/skills/web3-frontend/SKILL.md +25 -0
- package/skills/webgl-debug/SKILL.md +23 -0
- package/skills/webhook/SKILL.md +23 -0
- package/skills/websocket/SKILL.md +23 -0
- package/skills/write-tests/SKILL.md +19 -0
- package/src/client/agent.ts +803 -0
- package/src/client/background.ts +39 -0
- package/src/client/checkpoint.ts +48 -0
- package/src/client/cli.ts +1253 -0
- package/src/client/compaction.ts +86 -0
- package/src/client/extensions.ts +83 -0
- package/src/client/hooks.ts +40 -0
- package/src/client/image.ts +26 -0
- package/src/client/lsp.ts +0 -0
- package/src/client/mcp.ts +276 -0
- package/src/client/models-dev.ts +52 -0
- package/src/client/pkg.ts +41 -0
- package/src/client/platform.ts +94 -0
- package/src/client/prompts.ts +47 -0
- package/src/client/render.ts +138 -0
- package/src/client/session.ts +107 -0
- package/src/client/settings.ts +86 -0
- package/src/client/skill-router.ts +79 -0
- package/src/client/skills.ts +199 -0
- package/src/client/snapshot.ts +56 -0
- package/src/client/telemetry.ts +24 -0
- package/src/client/todos.ts +23 -0
- package/src/client/tools.ts +756 -0
- package/src/client/tui-mode.ts +41 -0
- package/src/client/tui.ts +224 -0
- package/src/sdk/index.ts +36 -0
- package/src/selfcheck.ts +364 -0
- package/src/server/config.ts +58 -0
- package/src/server/credentials.ts +89 -0
- package/src/server/identity.ts +58 -0
- package/src/server/index.ts +113 -0
- package/src/server/oauth.ts +93 -0
- package/src/server/providers/adapter.ts +25 -0
- package/src/server/providers/anthropic.ts +189 -0
- package/src/server/providers/openai-compat.ts +76 -0
- package/src/server/providers/registry.ts +31 -0
- package/src/server/router.ts +29 -0
- package/src/server/sse.ts +20 -0
- package/src/shared/types.ts +20 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: perf-profile
|
|
3
|
+
description: Profile code to find the actual hot path before optimizing, then verify the speedup with numbers
|
|
4
|
+
category: debugging
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Perf Profile
|
|
8
|
+
|
|
9
|
+
Use when something is slow and you need to know *where* the time goes before touching code. Intuition about bottlenecks is usually wrong — measure first, optimize the proven hot path, measure again.
|
|
10
|
+
|
|
11
|
+
1. Establish a baseline: a repeatable workload and a number (wall time, p95 latency, throughput) you can compare against.
|
|
12
|
+
2. Run a profiler (CPU sampling, or a flame graph) under that workload — don't guess from reading the code.
|
|
13
|
+
3. Read the profile for the hot path: the functions with the highest self time (their own work) vs cumulative time (work below them).
|
|
14
|
+
4. Identify the dominant cost — tight CPU loop, repeated allocation, N+1 queries, blocking I/O, lock contention, or serialization.
|
|
15
|
+
5. Apply one targeted optimization (algorithmic win, caching, batching, removing redundant work) and re-profile.
|
|
16
|
+
6. Compare against the baseline number to confirm a real improvement, and check you didn't regress correctness.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Optimize self time, not cumulative time — a function high in cumulative time may just be calling the real culprit.
|
|
20
|
+
- Profile a realistic workload; microbenchmarks lie about cache, allocation, and I/O behavior.
|
|
21
|
+
- A better algorithm (O(n²)→O(n)) usually beats micro-optimizing the inner loop — check complexity first.
|
|
22
|
+
- Don't optimize anything the profile doesn't flag; premature tuning adds complexity for no measured gain.
|
|
23
|
+
- Warm up the runtime (JIT, caches) before measuring, and run enough iterations to beat noise.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: physics
|
|
3
|
+
description: Add basic collision detection and response for 2D/3D game entities
|
|
4
|
+
category: gamedev
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Physics
|
|
8
|
+
|
|
9
|
+
Reach for this to add movement, collision detection, and resolution without pulling in a full physics engine.
|
|
10
|
+
|
|
11
|
+
1. Choose collider shapes (AABB, circle/sphere, capsule) that fit your entities; prefer the simplest that works.
|
|
12
|
+
2. Integrate motion with semi-implicit Euler: `velocity += accel * dt; position += velocity * dt`.
|
|
13
|
+
3. Broad-phase first (spatial grid or sweep) to cull pairs, then narrow-phase exact overlap tests on survivors.
|
|
14
|
+
4. On overlap, compute penetration depth and a contact normal; separate by pushing along the normal.
|
|
15
|
+
5. Resolve velocity along the normal using restitution (bounce) and friction along the tangent.
|
|
16
|
+
6. Run collision after integration each fixed step; iterate resolution a few times for stacked contacts.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Run physics on the fixed timestep, not the render delta, so behavior is stable and reproducible.
|
|
20
|
+
- Use swept/continuous tests for fast objects to avoid tunneling through thin walls.
|
|
21
|
+
- Separate position correction from velocity response; resolving only velocity leaves objects sinking.
|
|
22
|
+
- Add a small slop/epsilon and skip resolving tiny penetrations to stop jitter at rest.
|
|
23
|
+
- Keep colliders convex; concave shapes need decomposition or you get caught-edge artifacts.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pitch-deck
|
|
3
|
+
description: Build a startup/investor pitch deck covering problem, solution, market, traction, and the ask.
|
|
4
|
+
category: pptx
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pitch Deck
|
|
8
|
+
|
|
9
|
+
Use when the user needs an investor or fundraising pitch deck. Follow the canonical 10-12 slide arc and keep every slide skimmable in seconds.
|
|
10
|
+
|
|
11
|
+
1. Gather the essentials: one-line value prop, target customer, business model, traction numbers, team, and the funding ask.
|
|
12
|
+
2. Order the slides: Title → Problem → Solution → Product → Market (TAM/SAM/SOM) → Business Model → Traction → Competition → Team → Ask/Use of Funds (optional: Roadmap, Vision close).
|
|
13
|
+
3. Draft one sharp headline per slide that states the takeaway, then support it with at most 3 bullets or one visual.
|
|
14
|
+
4. Make Traction and Market concrete with real numbers and charts (revenue, growth, users); route data viz through slide-charts.
|
|
15
|
+
5. State the Ask explicitly: amount raising, round type, and use of funds breakdown.
|
|
16
|
+
6. Build the file via the pptx-deck skill (python-pptx) or pptx-from-markdown, then apply a clean branded theme (pptx-template).
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Lead each slide with the conclusion; investors skim, they don't read.
|
|
20
|
+
- Numbers over adjectives — "$40k MRR, 22% MoM" beats "rapid growth".
|
|
21
|
+
- One message per slide; if a slide needs two charts to explain, split it.
|
|
22
|
+
- TAM/SAM/SOM must be bottoms-up and defensible, not a giant top-down number.
|
|
23
|
+
- Keep it to ~12 slides; push deep detail (financial model, full metrics) into an appendix.
|
|
24
|
+
- Never invent traction, customers, or financials — flag any gaps for the user to fill.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pixel-diff
|
|
3
|
+
description: Diff two images and localize exactly which pixels, regions, and channels differ between them
|
|
4
|
+
category: visual-test
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pixel Diff
|
|
8
|
+
|
|
9
|
+
Reach for this when you have two images that should match (expected vs actual, before vs after) and need to know precisely where and how much they differ.
|
|
10
|
+
|
|
11
|
+
1. Normalize first: confirm both images share dimensions, color space, and bit depth — resize/convert mismatches before diffing or every pixel "differs".
|
|
12
|
+
2. Run a per-pixel diff (`pixelmatch`, ImageMagick `compare -metric AE`, or Pillow `ImageChops.difference`) and emit a diff image that highlights changed pixels.
|
|
13
|
+
3. Read the metrics: total differing pixels, max per-pixel delta, and the bounding box of the changed region — this localizes the problem to a corner/widget.
|
|
14
|
+
4. If the whole image lights up, suspect a global cause: gamma/color-profile shift, anti-aliasing, DPR mismatch, or a 1px offset — not a content change.
|
|
15
|
+
5. Zoom the diff region and inspect channels separately (R/G/B/A); an alpha-only diff means transparency/compositing, a uniform RGB shift means color management.
|
|
16
|
+
6. Set an anti-aliasing-aware tolerance so AA fringes don't dominate the real signal.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Dimension/format mismatch is the #1 false positive — always assert equal size and color space before comparing.
|
|
20
|
+
- A diff that's a faint copy of the whole image is almost always a 1px shift or AA difference, not a content bug.
|
|
21
|
+
- Output a *highlighted* diff image, not just a number; "1.2% pixels differ" tells you nothing about where.
|
|
22
|
+
- Watch alpha: many tools diff RGB only and miss transparency bugs — diff all four channels.
|
|
23
|
+
- Use a perceptual/AA-aware threshold for screenshots; use exact (AE=0) only for synthetic, pixel-perfect images.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ponytail
|
|
3
|
+
description: Force the laziest solution that actually works — YAGNI, stdlib before deps, shortest diff.
|
|
4
|
+
category: meta
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Ponytail
|
|
8
|
+
|
|
9
|
+
Channel a lazy senior developer. Lazy means **efficient, not careless**. The best code is the code
|
|
10
|
+
never written. You've seen every over-engineered codebase and been paged at 3am for one.
|
|
11
|
+
|
|
12
|
+
## The ladder
|
|
13
|
+
|
|
14
|
+
Stop at the first rung that holds:
|
|
15
|
+
|
|
16
|
+
1. **Does this need to exist at all?** Speculative need → skip it, say so in one line. (YAGNI)
|
|
17
|
+
2. **Stdlib does it?** Use it.
|
|
18
|
+
3. **Native platform feature covers it?** `<input type="date">` over a picker lib, CSS over JS, a DB constraint over app code.
|
|
19
|
+
4. **An already-installed dependency solves it?** Use it. Never add a new dep for what a few lines do.
|
|
20
|
+
5. **Can it be one line?** One line.
|
|
21
|
+
6. **Only then:** the minimum code that works.
|
|
22
|
+
|
|
23
|
+
Two rungs work → take the higher one and move on. The first lazy solution that works is the right one.
|
|
24
|
+
|
|
25
|
+
## Rules
|
|
26
|
+
|
|
27
|
+
- No unrequested abstractions: no interface with one implementation, no factory for one product, no config for a value that never changes.
|
|
28
|
+
- No boilerplate or scaffolding "for later" — later can scaffold for itself.
|
|
29
|
+
- Deletion over addition. Boring over clever (clever is what someone decodes at 3am).
|
|
30
|
+
- Fewest files. Shortest working diff wins.
|
|
31
|
+
- Mark deliberate simplifications with a `ponytail:` comment that names the ceiling and the upgrade path — e.g. `// ponytail: global lock, per-account locks if throughput matters`.
|
|
32
|
+
|
|
33
|
+
## When NOT to be lazy
|
|
34
|
+
|
|
35
|
+
Never simplify away: input validation at trust boundaries, error handling that prevents data loss,
|
|
36
|
+
security, accessibility basics, or anything explicitly requested. If the user insists on the full
|
|
37
|
+
version, build it — don't re-argue. Hardware needs its calibration knob; the physical world needs
|
|
38
|
+
tuning a minimal model can't see.
|
|
39
|
+
|
|
40
|
+
Non-trivial logic (a branch, loop, parser, money/security path) leaves ONE runnable check behind —
|
|
41
|
+
the smallest thing that fails if the logic breaks. Trivial one-liners need no test.
|
|
42
|
+
|
|
43
|
+
## Output
|
|
44
|
+
|
|
45
|
+
Code first. Then at most three short lines: what was skipped, when to add it. If the explanation is
|
|
46
|
+
longer than the code, delete the explanation. Pattern: `[code] → skipped: [X], add when [Y].`
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: postmortem
|
|
3
|
+
description: Write a blameless incident postmortem with timeline, root cause, and preventive action items
|
|
4
|
+
category: productivity
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Postmortem
|
|
8
|
+
|
|
9
|
+
Reach for this after an incident, outage, or serious bug to produce a blameless write-up that explains what happened and prevents a recurrence — focused on the system that allowed the failure, never on who pushed the button.
|
|
10
|
+
|
|
11
|
+
1. Write a one-paragraph summary: what broke, who/what was affected, the user-visible impact, and the duration.
|
|
12
|
+
2. Build a timeline from evidence — deploy logs, alerts, chat, commits — with timestamps from first symptom through detection, mitigation, and full resolution.
|
|
13
|
+
3. Find the root cause by asking "why" past the trigger until you reach a systemic gap (missing test, absent alert, unguarded assumption), not a person.
|
|
14
|
+
4. Separate the trigger (what set it off) from the root cause (why it could happen at all) and from the impact.
|
|
15
|
+
5. Capture detection and response: how long to notice, how long to mitigate, and what made each faster or slower.
|
|
16
|
+
6. List preventive action items — each with an owner and due date — covering prevention, faster detection, and quicker mitigation.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Blameless, always: "the deploy lacked a rollback step", never "X forgot to roll back".
|
|
20
|
+
- Anchor the timeline in real timestamps and sources; reconstruct from logs, do not guess.
|
|
21
|
+
- Distinguish trigger vs root cause vs impact — conflating them produces shallow fixes.
|
|
22
|
+
- Every action item gets an owner and date; track them to closure or they were theater.
|
|
23
|
+
- Capture time-to-detect and time-to-mitigate explicitly — they are often the biggest lever for the next incident.
|
|
24
|
+
- Write it while memory is fresh; a postmortem a week late loses the detail that matters.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pptx-deck
|
|
3
|
+
description: Generate a .pptx slide deck programmatically with python-pptx from a content outline.
|
|
4
|
+
category: pptx
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PPTX Deck
|
|
8
|
+
|
|
9
|
+
Reach for this when the user wants a real, editable PowerPoint file (not HTML or PDF) built from a content outline or data.
|
|
10
|
+
|
|
11
|
+
1. Confirm the deck's purpose, audience, and approximate slide count; sketch the slide order first (see slide-outline) before writing code.
|
|
12
|
+
2. `pip install python-pptx`; start a `Presentation()` (or open a template `.pptx` to inherit its theme).
|
|
13
|
+
3. Pick layouts from `prs.slide_layouts` (0=title, 1=title+content, 5=title-only, 6=blank); add slides with `prs.slides.add_slide(layout)`.
|
|
14
|
+
4. Fill `slide.shapes.title` and body placeholders; for free placement use `add_textbox(left, top, width, height)` with `Inches(...)` from `pptx.util`.
|
|
15
|
+
5. Add images via `slide.shapes.add_picture`, and route charts/tables through the slide-charts skill rather than hand-rolling them.
|
|
16
|
+
6. Set consistent fonts/sizes/colors on `run.font` (`size=Pt(...)`, `color.rgb=RGBColor(...)`); save with `prs.save("deck.pptx")` and verify it opens.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- One idea per slide; keep body text to 3-6 short bullets, never paragraphs.
|
|
20
|
+
- Use `Inches()`/`Pt()`/`Emu()` from `pptx.util` — never raw integers for positions or sizes.
|
|
21
|
+
- Reuse a single helper for adding slides so spacing, fonts, and margins stay uniform.
|
|
22
|
+
- Default 16:9 (`prs.slide_width = Inches(13.333)`, `prs.slide_height = Inches(7.5)`) unless told otherwise.
|
|
23
|
+
- Don't fabricate logos, photos, or data; leave a labeled placeholder shape when an asset is missing.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pptx-export
|
|
3
|
+
description: Export a .pptx deck to PDF or per-slide images for sharing, printing, or web embedding.
|
|
4
|
+
category: pptx
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PPTX Export
|
|
8
|
+
|
|
9
|
+
Use when a finished deck needs a non-editable, portable format — a PDF handout, or PNG/JPG images of each slide for the web or docs.
|
|
10
|
+
|
|
11
|
+
1. Confirm the target: PDF (handout/print) or per-slide images (web, thumbnails, social), and the resolution needed.
|
|
12
|
+
2. Prefer LibreOffice headless for fidelity: `soffice --headless --convert-to pdf deck.pptx` (works cross-platform, no PowerPoint).
|
|
13
|
+
3. For images, convert to PDF first, then rasterize pages with `pdftoppm -png deck.pdf slide` or ImageMagick/`pdf2image`.
|
|
14
|
+
4. On Windows with PowerPoint installed, COM automation (`win32com.client`) can export PDF and PNG natively with best font fidelity.
|
|
15
|
+
5. For multi-up handouts, use the PDF export's notes/handout layout or print N-slides-per-page.
|
|
16
|
+
6. Open the output and spot-check fonts, chart rendering, and image quality before delivering.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- LibreOffice is the most portable converter; results can differ slightly from PowerPoint on fonts and effects — verify visually.
|
|
20
|
+
- Ensure fonts used in the deck are installed on the converting machine, or text reflows and substitutes.
|
|
21
|
+
- Choose DPI by use: ~96-150 for screen, 300 for print.
|
|
22
|
+
- Embed fonts in the source deck where possible so exports stay faithful.
|
|
23
|
+
- Keep the original `.pptx` as the source of truth; treat PDF/images as disposable artifacts.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pptx-from-markdown
|
|
3
|
+
description: Convert a markdown document into slides using Marp or reveal.js, exporting to PPTX or HTML.
|
|
4
|
+
category: pptx
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PPTX From Markdown
|
|
8
|
+
|
|
9
|
+
Use when the source is markdown (or the user prefers writing slides as text) and wants fast, version-controllable slides. Marp is the quickest path to a `.pptx`; reveal.js gives richer interactive HTML.
|
|
10
|
+
|
|
11
|
+
1. Choose the tool: Marp (`@marp-team/marp-cli`) for clean PPTX/PDF export, reveal.js for animated browser decks.
|
|
12
|
+
2. Write the markdown: separate slides with `---`, use `#`/`##` for titles and `-` bullets; one idea per slide.
|
|
13
|
+
3. Add a Marp front-matter block (`marp: true`, `theme:`, `paginate: true`) or a reveal.js config to set the look.
|
|
14
|
+
4. Use per-slide directives for layout (`<!-- _class: lead -->`, background images via ``) where needed.
|
|
15
|
+
5. Render: `marp deck.md -o deck.pptx` (or `--pdf`/`--html`), or serve reveal.js and export via its print/PDF route.
|
|
16
|
+
6. Open the output and verify slide breaks, images, and code blocks survived the conversion.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Exactly one `---` between slides; a stray rule splits or merges slides unexpectedly.
|
|
20
|
+
- Keep heading levels consistent — Marp maps them to title vs. body styling.
|
|
21
|
+
- Reference images by relative path and keep them beside the markdown so export resolves them.
|
|
22
|
+
- Marp PPTX export rasterizes some styling; if the user needs fully editable native shapes, use pptx-deck instead.
|
|
23
|
+
- Set the theme once in front-matter rather than styling slides individually.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pptx-template
|
|
3
|
+
description: Apply a branded template/theme (fonts, colors, logo, master slides) to a PowerPoint deck.
|
|
4
|
+
category: pptx
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PPTX Template
|
|
8
|
+
|
|
9
|
+
Use when a deck needs to match brand guidelines, or when a client supplies a `.potx`/`.pptx` template the content must adopt.
|
|
10
|
+
|
|
11
|
+
1. Obtain the brand inputs: a template file (`.potx`/`.pptx`), or the palette (hex codes), fonts, and logo to build one.
|
|
12
|
+
2. When a template exists, open it directly with `Presentation("template.pptx")` so new slides inherit its layouts and theme.
|
|
13
|
+
3. Map your content slides to the template's `slide_layouts` by index/name — use the layouts it defines, not generic blank slides.
|
|
14
|
+
4. With no template, define a small theme dict (primary/secondary/accent colors, title/body fonts, sizes) and apply it through one styling helper.
|
|
15
|
+
5. Place the logo and any footer/page-number consistently via the slide master or a repeated helper, not per-slide by hand.
|
|
16
|
+
6. Render a few representative slides and check contrast, font fallback, and logo placement before applying to the full deck.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Prefer inheriting an existing template file over reconstructing a theme by hand.
|
|
20
|
+
- Centralize colors and fonts in one place so a rebrand is a single edit.
|
|
21
|
+
- Ensure text/background contrast meets readability (aim for WCAG AA on body text).
|
|
22
|
+
- Embed or confirm brand fonts are installed; otherwise pick a close, available fallback and note it.
|
|
23
|
+
- Keep the logo at consistent size/position and don't distort its aspect ratio.
|
|
24
|
+
- Don't let template decoration crowd content — whitespace is part of the brand.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pr-review
|
|
3
|
+
description: Review a GitHub PR with gh, summarize the change, and suggest concrete improvements
|
|
4
|
+
category: git
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PR Review
|
|
8
|
+
|
|
9
|
+
Reach for this when asked to review a GitHub pull request: understand the intent, read the diff, and leave actionable feedback rather than a rubber stamp.
|
|
10
|
+
|
|
11
|
+
1. Fetch context: `gh pr view <num>` for title/body/checks, and `gh pr view <num> --comments` to read existing discussion so you don't repeat points.
|
|
12
|
+
2. Read the actual change: `gh pr diff <num>` (add `--patch | less` for large diffs). Note the base branch and files touched.
|
|
13
|
+
3. Check CI/state: `gh pr checks <num>` — flag failing checks before reviewing logic, since they may make the review moot.
|
|
14
|
+
4. Walk the diff hunk by hunk: trace data flow, look for missing error handling, untested edge cases, security/auth gaps, and behavior that contradicts the PR description.
|
|
15
|
+
5. Separate findings into blocking (correctness, security, breaking) vs non-blocking (style, naming, nits) so the author knows what must change.
|
|
16
|
+
6. Summarize: one-paragraph overview of what the PR does, then a bulleted list of suggestions, each anchored to `file:line`.
|
|
17
|
+
7. If asked to post, use `gh pr review <num> --comment -b "..."` or `--approve`/`--request-changes`; for line-specific notes use `gh pr comment` or the review API.
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
- Review the diff, not your assumptions — pull the branch (`gh pr checkout <num>`) if you need to run or grep the code.
|
|
21
|
+
- Quote `file:line` for every concrete suggestion; vague feedback like "improve error handling" is not actionable.
|
|
22
|
+
- Don't approve a PR with failing required checks or unresolved blocking comments.
|
|
23
|
+
- Keep tone constructive and specific; flag, don't rewrite, unless the author asked for code.
|
|
24
|
+
- Respect scope: note out-of-scope issues separately rather than blocking the PR on them.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: precommit
|
|
3
|
+
description: Set up pre-commit hooks that lint and format staged files before each commit
|
|
4
|
+
category: ci-cd
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pre-commit
|
|
8
|
+
|
|
9
|
+
Reach for this to catch lint/format issues locally before they ever reach CI, keeping commits clean.
|
|
10
|
+
|
|
11
|
+
1. Pick the mechanism that fits the stack: `pre-commit` (framework, polyglot) or a JS-native combo of `husky` + `lint-staged`.
|
|
12
|
+
2. Add the config (`.pre-commit-config.yaml` or `package.json` `lint-staged` block) listing hooks: formatter, linter, and cheap checks.
|
|
13
|
+
3. Scope hooks to staged files only and run the same tools CI uses, so local and CI verdicts agree.
|
|
14
|
+
4. Install the git hook (`pre-commit install` or husky's `prepare` script) so it runs automatically on `git commit`.
|
|
15
|
+
5. Run the hooks across the whole repo once (`pre-commit run --all-files`) to surface and fix existing violations.
|
|
16
|
+
6. Document the one-line setup so a fresh clone installs hooks during `npm install` / bootstrap.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Keep hooks fast — only lint/format staged files; push heavy test suites to CI.
|
|
20
|
+
- Pin hook/tool versions so every developer runs identical checks.
|
|
21
|
+
- Make hooks fixable: prefer auto-formatters that re-stage, and give clear failure messages.
|
|
22
|
+
- Pre-commit is a convenience, not a gate — CI must still enforce the same checks (`--no-verify` exists).
|
|
23
|
+
- Ensure hooks install on clone (husky `prepare`) so they aren't silently skipped.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pricing-page
|
|
3
|
+
description: Design a clear, persuasive pricing page that steers users to the right plan and reduces decision anxiety.
|
|
4
|
+
category: ui-design
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pricing Page
|
|
8
|
+
|
|
9
|
+
Reach for this when designing or fixing a pricing page — clarity converts, and confusion kills more deals than price does.
|
|
10
|
+
|
|
11
|
+
1. Limit to 3–4 tiers and anchor with one recommended plan, visually elevated (border accent, "Most popular" badge, slight scale) — the decoy/anchor frames the others.
|
|
12
|
+
2. Make the price unmissable: large tabular number, `/mo` qualifier muted beside it, and a monthly↔annual toggle that shows the savings ("2 months free") to nudge annual.
|
|
13
|
+
3. Build a feature comparison that scales by inclusion, not repetition: list the delta each tier adds, use a clean check matrix for full comparison, and put the highest-value differentiator first.
|
|
14
|
+
4. Give each tier one CTA with consistent verbs; the recommended plan gets the solid primary button, others get quieter ghost buttons. Keep button widths and card heights aligned on the grid.
|
|
15
|
+
5. Defuse risk near the buttons: "no credit card", "cancel anytime", money-back guarantee, and a short FAQ for the predictable objections (overage, downgrades, taxes).
|
|
16
|
+
6. Polish hierarchy and motion: 8px rhythm, equal-height cards, a subtle hover lift on the recommended tier, and `prefers-reduced-motion` respected.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- One recommended plan, clearly signaled — an undifferentiated row of equal cards makes users bounce.
|
|
20
|
+
- Show the real total: surface annual-vs-monthly math and any per-seat/usage cost; hidden pricing erodes trust fast.
|
|
21
|
+
- CTA verbs match commitment ("Start free trial" vs "Contact sales"), never a generic "Submit" everywhere.
|
|
22
|
+
- Lead each tier with value/outcomes, not a feature dump; the comparison table is for buyers who already want detail.
|
|
23
|
+
- Keep contrast and legibility on badges/accents ≥4.5:1 — the "popular" highlight must not sacrifice readability.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-overview
|
|
3
|
+
description: Describe a project well — purpose, architecture, layout, and how to run it — for a README or newcomer.
|
|
4
|
+
category: docs
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Project Overview
|
|
8
|
+
|
|
9
|
+
Use to describe a project clearly: what it is, why, how it's built, and how to run it.
|
|
10
|
+
|
|
11
|
+
1. Explore: read the README/manifest (`package.json`, `pyproject.toml`, `go.mod`), the entry points, the top-level directory tree, and recent git history to infer purpose and what's active.
|
|
12
|
+
2. State the purpose in 1-2 sentences — what it does and who/what it's for — without jargon.
|
|
13
|
+
3. Describe the architecture: the main components, how they fit together, and the one or two design decisions that shape it (link an architecture diagram rather than re-prosing it — see the `architecture-diagram` skill).
|
|
14
|
+
4. Map the layout: a short tree of the key directories/files, one line of role each.
|
|
15
|
+
5. Give the essentials: install, run, test, and configuration (env vars), with copy-pasteable commands.
|
|
16
|
+
6. Write it where it belongs (README or `docs/`), honest about what's done vs. planned.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Accurate over impressive — describe what the code actually does; verify the commands run.
|
|
20
|
+
- Lead with purpose: a reader should get "what & why" in the first three lines.
|
|
21
|
+
- Link the diagram, don't duplicate it in words.
|
|
22
|
+
- Cut boilerplate — every line should help someone use or extend the project.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prompt-template
|
|
3
|
+
description: Design and refine a structured, testable LLM prompt template
|
|
4
|
+
category: data-ml
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Prompt Template
|
|
8
|
+
|
|
9
|
+
Use when building a reusable prompt for a production task (extraction, classification, generation) where output structure and reliability matter.
|
|
10
|
+
|
|
11
|
+
1. Write a clear role and task statement, then specify the exact output format (JSON schema, fields, or enum) the caller will parse.
|
|
12
|
+
2. Separate static instructions from dynamic inputs with explicit delimiters or template variables so user content can't override instructions.
|
|
13
|
+
3. Add 2-3 few-shot examples covering the tricky and edge cases, including how to handle missing or ambiguous input.
|
|
14
|
+
4. State failure behavior explicitly: what to output when the answer is unknown, input is empty, or it can't comply.
|
|
15
|
+
5. Test on a labeled set of inputs, read the failures, and iterate the wording — change one thing at a time.
|
|
16
|
+
6. Version the template and pin the model; treat prompt edits like code changes with before/after eval scores.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Specify output format precisely and validate/parse it on the way out; don't trust prose to be machine-readable.
|
|
20
|
+
- Keep instructions and untrusted input clearly separated to reduce prompt injection.
|
|
21
|
+
- Few-shot examples should target real failure modes, not just happy-path repetition.
|
|
22
|
+
- Change one variable per iteration and measure on a fixed set — vibes don't catch regressions.
|
|
23
|
+
- Pin the model and version the prompt; the same template can behave differently across models.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: property-test
|
|
3
|
+
description: Add property-based tests that assert invariants across generated inputs instead of fixed examples
|
|
4
|
+
category: testing
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Property Test
|
|
8
|
+
|
|
9
|
+
Use when a function has properties that must hold for all inputs, and example-based tests miss edge cases.
|
|
10
|
+
|
|
11
|
+
1. State the invariant in plain language (e.g. "decode(encode(x)) == x", "output is always sorted", "result never negative").
|
|
12
|
+
2. Pick a property-based library for the language (Hypothesis, fast-check, QuickCheck) and define a generator for the input domain.
|
|
13
|
+
3. Express the property as a test: generate inputs, run the code, assert the invariant holds for every case.
|
|
14
|
+
4. Constrain generators to valid inputs only (filters/preconditions) so failures reflect real bugs, not invalid data.
|
|
15
|
+
5. Run it; when it finds a failure, let the framework shrink to the minimal counterexample and inspect that case.
|
|
16
|
+
6. Fix the bug, then pin the shrunk counterexample as an explicit regression example test.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Test true invariants — round-trips, idempotence, ordering, conservation — not restatements of the implementation.
|
|
20
|
+
- Make generators match the real input domain; over-broad generators produce noise, over-narrow ones miss bugs.
|
|
21
|
+
- Always capture the shrunk counterexample as a permanent example-based regression test once fixed.
|
|
22
|
+
- Seed the RNG or record failing seeds so a found failure is reproducible, not a one-off in CI.
|
|
23
|
+
- Keep run counts reasonable in CI; raise iterations for a focused hunt, not on every commit.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: protobuf
|
|
3
|
+
description: Design protobuf schemas that stay backward- and forward-compatible as they evolve
|
|
4
|
+
category: networking
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Protobuf
|
|
8
|
+
|
|
9
|
+
Reach for this when designing the wire format for messages shared across services, languages, or versions. The schema is a long-lived contract — design it for change.
|
|
10
|
+
|
|
11
|
+
1. Start a `.proto` with `syntax = "proto3";`, a stable `package`, and one message per logical entity; keep messages small and composable.
|
|
12
|
+
2. Assign field tags deliberately: 1–15 (single-byte) for the hottest fields, and never change a tag once it ships.
|
|
13
|
+
3. Choose precise types — `int32`/`int64`/`bool`/`string`/`bytes`, `repeated` for lists, `map<k,v>` for dictionaries, and nested messages over flat blobs.
|
|
14
|
+
4. Use `enum` with a `0` value named `*_UNSPECIFIED` as the default, and `oneof` for mutually exclusive fields.
|
|
15
|
+
5. Evolve safely: add new fields with new tags, and `reserved` the tags/names of anything you remove.
|
|
16
|
+
6. Lint and check compatibility (`buf lint`, `buf breaking`) in CI so breaking changes are caught before merge.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Field tags are the contract, not field names — renaming a field is safe on the wire, renumbering is catastrophic.
|
|
20
|
+
- Every `enum` must have a `0 = *_UNSPECIFIED` member; proto3 treats `0` as the default and you can't tell "unset" from "first value" otherwise.
|
|
21
|
+
- Don't change a field's type (e.g. `int32`→`string`) in place — add a new field and migrate; type changes corrupt decoding.
|
|
22
|
+
- Reserve removed tags AND names (`reserved 4; reserved "old_name";`) so nobody silently reuses them.
|
|
23
|
+
- Prefer explicit messages over `Any`/`Struct`/JSON-in-a-string; you lose type safety and compatibility checking.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: py-async
|
|
3
|
+
description: Convert blocking Python code to async/await without deadlocks or hidden sync calls
|
|
4
|
+
category: languages
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Py Async
|
|
8
|
+
|
|
9
|
+
Use this when a module's I/O latency dominates and you want to move it to `asyncio`, or when porting sync callers into an existing async stack.
|
|
10
|
+
|
|
11
|
+
1. Map the blocking boundaries: identify every network, disk, subprocess, and `time.sleep` call — these become `await` points or run in an executor.
|
|
12
|
+
2. Swap sync libraries for async equivalents (`requests`→`httpx`/`aiohttp`, `psycopg2`→`asyncpg`, `open`→`aiofiles`) rather than wrapping everything in threads.
|
|
13
|
+
3. Convert functions to `async def` from the I/O leaves upward, propagating `await` to every caller until you reach an entry point.
|
|
14
|
+
4. For unavoidable blocking calls (CPU work, sync-only libs), offload with `await asyncio.to_thread(fn, ...)` or a process pool — don't call them directly on the loop.
|
|
15
|
+
5. Replace sequential awaits with `asyncio.gather` or `TaskGroup` where operations are independent, and guard shared state with `asyncio.Lock`.
|
|
16
|
+
6. Run under load and check for "coroutine was never awaited" warnings, blocked-loop stalls, and unhandled task exceptions.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Never call a blocking function directly inside a coroutine — it stalls the entire event loop for all tasks.
|
|
20
|
+
- One event loop per process: use `asyncio.run(main())` at the top; don't create nested loops or call `loop.run_until_complete` from within async code.
|
|
21
|
+
- Cancellation is cooperative — propagate `CancelledError`, and put cleanup in `finally` or `async with`.
|
|
22
|
+
- Set timeouts on every await that hits the network (`asyncio.timeout(...)`); an unbounded await is a hang waiting to happen.
|
|
23
|
+
- Don't mix sync and async versions of the same function in one call graph — pick a color and commit to it.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: py-typing
|
|
3
|
+
description: Add Python type hints to existing code and get it passing mypy or pyright cleanly
|
|
4
|
+
category: languages
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Py Typing
|
|
8
|
+
|
|
9
|
+
Reach for this when adding type hints to untyped Python or chasing down type-checker errors in a module or package.
|
|
10
|
+
|
|
11
|
+
1. Pick a checker and pin strictness: `mypy --strict <path>` or `pyright`, and capture the current error count as a baseline.
|
|
12
|
+
2. Annotate from the leaves up: type the most-imported helpers and data models first so call sites infer correctly.
|
|
13
|
+
3. Replace ambiguous returns with precise types — use `X | None` over bare `Optional` omission, `Sequence`/`Mapping` for read-only params, concrete types for returns.
|
|
14
|
+
4. Introduce `TypedDict`, `dataclass`, `Protocol`, or `@overload` instead of `dict[str, Any]` and `# type: ignore` where structure is known.
|
|
15
|
+
5. Use `typing.cast` or a narrowing `assert isinstance(...)` only when the checker genuinely can't follow control flow — never to silence a real bug.
|
|
16
|
+
6. Re-run the checker, drive the error count to zero, and add a CI step (`mypy` / `pyright`) so it stays there.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Prefer fixing the type over `# type: ignore`; if you must ignore, use a specific code like `# type: ignore[arg-type]` and a comment.
|
|
20
|
+
- Don't annotate with `Any` to pass the checker — that defeats the purpose and hides defects.
|
|
21
|
+
- Target the project's minimum Python version: use `from __future__ import annotations` or `typing_extensions` for newer constructs on older runtimes.
|
|
22
|
+
- Type public APIs precisely; internal locals usually don't need annotations (the checker infers them).
|
|
23
|
+
- Keep runtime behavior unchanged — adding hints must never alter logic, and avoid heavy `typing` imports inside hot paths.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: query-optimize
|
|
3
|
+
description: Optimize a slow SQL query using EXPLAIN, indexes, and rewrites
|
|
4
|
+
category: database
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Query Optimize
|
|
8
|
+
|
|
9
|
+
Use when a specific query is slow and you need to find and fix the bottleneck with evidence, not guesses.
|
|
10
|
+
|
|
11
|
+
1. Reproduce the slowness and capture the plan with `EXPLAIN ANALYZE` (or the engine's equivalent) on representative data volumes.
|
|
12
|
+
2. Read the plan for the real cost: sequential scans on large tables, nested loops over big row counts, expensive sorts, and bad row-count estimates.
|
|
13
|
+
3. Add or fix indexes to cover the `WHERE`, `JOIN`, and `ORDER BY` columns; consider composite indexes ordered by selectivity and partial indexes for filtered queries.
|
|
14
|
+
4. Rewrite the query where the plan demands it: avoid `SELECT *`, replace correlated subqueries with joins, push filters earlier, and avoid functions on indexed columns (they defeat the index).
|
|
15
|
+
5. Re-run `EXPLAIN ANALYZE` and confirm the plan improved and wall-clock time dropped on real data sizes.
|
|
16
|
+
6. Update table statistics (`ANALYZE`) and check for N+1 patterns if the query comes from an ORM.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Measure before and after with `EXPLAIN ANALYZE` on production-like data — small dev tables hide scan costs.
|
|
20
|
+
- An index helps reads but costs writes and storage; justify each one against the workload.
|
|
21
|
+
- Filter and sort on indexed expressions; wrapping a column in a function or leading-wildcard `LIKE` skips the index.
|
|
22
|
+
- Fix the query and indexes before reaching for caching or denormalization.
|
|
23
|
+
- Re-check the plan after the change; the optimizer may pick a different path than you expect.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rag-pipeline
|
|
3
|
+
description: Build a retrieval-augmented generation pipeline with grounded, cited answers
|
|
4
|
+
category: data-ml
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# RAG Pipeline
|
|
8
|
+
|
|
9
|
+
Use when an LLM needs to answer over a corpus it wasn't trained on — docs, knowledge base, tickets — and answers must be grounded in retrieved sources.
|
|
10
|
+
|
|
11
|
+
1. Chunk source documents thoughtfully (by section/heading, with overlap) and keep metadata: source id, title, and offsets for citation.
|
|
12
|
+
2. Embed chunks and index them in a vector store; consider hybrid retrieval (vector + keyword/BM25) for better recall on names and codes.
|
|
13
|
+
3. At query time, retrieve top-k, optionally rerank, and assemble a context block that fits the model's window with the most relevant chunks first.
|
|
14
|
+
4. Prompt the model to answer only from the provided context and to cite chunk ids; instruct it to say "not found" when context is insufficient.
|
|
15
|
+
5. Return citations to the user and evaluate retrieval (recall@k) and answer faithfulness separately.
|
|
16
|
+
6. Tune chunk size, k, and reranking against an eval set rather than by feel.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Ground every claim in retrieved context and require citations; an ungrounded answer is a hallucination risk.
|
|
20
|
+
- Retrieval quality caps answer quality — debug recall before blaming the generator.
|
|
21
|
+
- Use hybrid search when queries contain exact tokens (ids, error codes, proper nouns) that embeddings blur.
|
|
22
|
+
- Re-embed and reindex when the embedding model or chunking changes; never mix embedding spaces.
|
|
23
|
+
- Instruct the model to refuse when context is missing rather than filling gaps from parametric memory.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rails-resource
|
|
3
|
+
description: Scaffold a Rails resource with model, migration, controller, and routes
|
|
4
|
+
category: frameworks
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Rails Resource
|
|
8
|
+
|
|
9
|
+
Use to add a new resource to a Rails app — model + migration, RESTful controller, and routes — following convention over configuration.
|
|
10
|
+
|
|
11
|
+
1. Generate it: `rails generate scaffold <Name> field:type ...` (or `model` + `controller` separately for finer control).
|
|
12
|
+
2. Review the migration, adjust columns/indexes/null constraints, then run `rails db:migrate`.
|
|
13
|
+
3. Add `resources :<plural>` to `config/routes.rb` (only needed if you didn't use full scaffold), scoping or nesting as appropriate.
|
|
14
|
+
4. Lock down `params` with a strong-parameters `permit` list in the controller; add validations to the model.
|
|
15
|
+
5. Adjust controller actions and views to match real requirements; remove unused scaffold actions.
|
|
16
|
+
6. Run `rails server` and the generated tests; verify CRUD via the routes (`rails routes` to confirm paths).
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Always use strong parameters (`params.require(:x).permit(...)`); never pass raw `params` to `create`/`update`.
|
|
20
|
+
- Put validations and business rules on the model, not the controller.
|
|
21
|
+
- Keep controller actions thin and RESTful; reach for service objects before bloating actions.
|
|
22
|
+
- Add DB-level constraints/indexes in the migration, not just model validations.
|
|
23
|
+
- Run `rails db:migrate` (and commit `schema.rb`) before relying on the new table; never edit `schema.rb` by hand.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rate-limit
|
|
3
|
+
description: Add rate limiting to an API with correct keys, headers, and 429 responses
|
|
4
|
+
category: api
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Rate Limit
|
|
8
|
+
|
|
9
|
+
Use when an endpoint or whole API needs throttling to protect against abuse, runaway clients, or cost blowups.
|
|
10
|
+
|
|
11
|
+
1. Decide the limit key — per API key, per user, or per IP — and pick the scope (global vs per-route); document the chosen limit and window.
|
|
12
|
+
2. Choose an algorithm (token bucket or sliding window) and a store: in-memory only for single-instance, Redis/shared store for multi-instance.
|
|
13
|
+
3. Add the limiter as middleware or a decorator at the boundary, before expensive work runs.
|
|
14
|
+
4. On rejection return `429 Too Many Requests` with a `Retry-After` header and a clear error body.
|
|
15
|
+
5. Emit `RateLimit-Limit`, `RateLimit-Remaining`, and `RateLimit-Reset` headers on responses so clients can self-throttle.
|
|
16
|
+
6. Test the boundary: requests under the limit pass, the request over it returns 429, and the counter resets after the window.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Use a shared store (Redis) when more than one instance serves traffic — in-memory counters under-count behind a load balancer.
|
|
20
|
+
- Rate-limit on a trustworthy key; raw client IP is spoofable and breaks behind proxies unless you read the right forwarded header.
|
|
21
|
+
- Fail open or closed deliberately — if the limiter store is down, decide whether to allow or block, don't crash the request.
|
|
22
|
+
- Always include `Retry-After` so well-behaved clients back off instead of hammering.
|
|
23
|
+
- Keep the limiter cheap; a slow check on every request defeats the purpose.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-hooks
|
|
3
|
+
description: Convert a React class component to a function component using hooks
|
|
4
|
+
category: frameworks
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# React Hooks
|
|
8
|
+
|
|
9
|
+
Reach for this when modernizing a legacy class component into a function component with hooks, preserving behavior exactly.
|
|
10
|
+
|
|
11
|
+
1. Read the class: note `state` shape, `props` used, lifecycle methods, instance fields, and bound handlers.
|
|
12
|
+
2. Replace the class with a function component; turn each piece of `state` into a `useState` call (group related fields only if they update together).
|
|
13
|
+
3. Map lifecycles to effects: `componentDidMount`/`componentWillUnmount` → `useEffect(fn, [])` with a cleanup return; `componentDidUpdate` → `useEffect` with the right deps.
|
|
14
|
+
4. Convert instance fields that survive renders (timers, refs to DOM/values) to `useRef`; convert methods to inline functions or `useCallback` if passed as props.
|
|
15
|
+
5. Remove `this.`, `bind`, and the constructor; read props directly as the function argument.
|
|
16
|
+
6. Run the component and its tests; verify effects fire and clean up the same number of times as the old lifecycles.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- One `useEffect` per concern, not one giant effect mirroring `componentDidMount`.
|
|
20
|
+
- Every value referenced inside an effect must be in its dependency array; do not silence the exhaustive-deps lint by deleting deps.
|
|
21
|
+
- `useState` setters are async and don't merge objects — spread manually or split into multiple states.
|
|
22
|
+
- Don't wrap everything in `useCallback`/`useMemo`; add them only when an identity actually matters downstream.
|
|
23
|
+
- Preserve the original render output and ref-forwarding behavior; use `forwardRef` if the class exposed a ref.
|