shmakk 1.1.0 → 1.2.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 +16 -1
- package/package.json +6 -3
- package/scripts/import-skills.js +536 -0
- package/scripts/install-skills.js +64 -0
- package/skills/ai-elements.md +482 -0
- package/skills/architecture.md +151 -0
- package/skills/backend-adapter-aws-lambda.md +204 -0
- package/skills/backend-adapter-express.md +177 -0
- package/skills/backend-adapter-fastify.md +222 -0
- package/skills/backend-adapter-fetch.md +200 -0
- package/skills/backend-api-docs.md +22 -0
- package/skills/backend-aspire.md +232 -0
- package/skills/backend-aspnet-core.md +62 -0
- package/skills/backend-build-chatgpt-app.md +321 -0
- package/skills/backend-build-mcp-app.md +393 -0
- package/skills/backend-build-mcp-server.md +222 -0
- package/skills/backend-build-mcpb.md +200 -0
- package/skills/backend-building-ai-agent-on-cloudflare.md +401 -0
- package/skills/backend-caching.md +206 -0
- package/skills/backend-chatgpt-app-submission.md +157 -0
- package/skills/backend-chatgpt-apps.md +321 -0
- package/skills/backend-client-setup.md +318 -0
- package/skills/backend-containerize-aspnet-framework.md +455 -0
- package/skills/backend-create-spring-boot-java-project.md +164 -0
- package/skills/backend-create-spring-boot-kotlin-project.md +148 -0
- package/skills/backend-csharp-async.md +50 -0
- package/skills/backend-csharp-docs.md +63 -0
- package/skills/backend-csharp-mcp-server-generator.md +60 -0
- package/skills/backend-dotenv.md +201 -0
- package/skills/backend-dotenvx.md +119 -0
- package/skills/backend-env-vars.md +259 -0
- package/skills/backend-error-handling.md +254 -0
- package/skills/backend-fastapi.md +437 -0
- package/skills/backend-go-mcp-server-generator.md +335 -0
- package/skills/backend-java-mcp-server-generator.md +757 -0
- package/skills/backend-kotlin-mcp-server-generator.md +450 -0
- package/skills/backend-middlewares.md +243 -0
- package/skills/backend-multi-stage-dockerfile.md +47 -0
- package/skills/backend-nestjs.md +192 -0
- package/skills/backend-next-forge.md +375 -0
- package/skills/backend-nextjs.md +746 -0
- package/skills/backend-openapi-to-application-code.md +113 -0
- package/skills/backend-php-mcp-server-generator.md +523 -0
- package/skills/backend-python-mcp-server-generator.md +106 -0
- package/skills/backend-routing-middleware.md +251 -0
- package/skills/backend-ruby-mcp-server-generator.md +661 -0
- package/skills/backend-rust-mcp-server-generator.md +578 -0
- package/skills/backend-semantic-kernel.md +57 -0
- package/skills/backend-server-setup.md +379 -0
- package/skills/backend-server-side-calls.md +250 -0
- package/skills/backend-subscriptions.md +407 -0
- package/skills/backend-swift-mcp-server-generator.md +670 -0
- package/skills/backend-trpc-router.md +152 -0
- package/skills/backend-typescript-mcp-server-generator.md +91 -0
- package/skills/backend-validators.md +229 -0
- package/skills/backend.md +76 -0
- package/skills/backup.md +165 -0
- package/skills/budget.md +140 -0
- package/skills/business-gtm-0-to-1-launch.md +322 -0
- package/skills/business-gtm-operating-cadence.md +421 -0
- package/skills/business-gtm-positioning-strategy.md +439 -0
- package/skills/business-gtm-product-led-growth.md +340 -0
- package/skills/calendar.md +95 -0
- package/skills/code-review.md +130 -0
- package/skills/compliance.md +168 -0
- package/skills/contracts.md +130 -0
- package/skills/daily-job-run.md +46 -0
- package/skills/daily-webdesign.md +187 -0
- package/skills/database-bigquery-pipeline-audit.md +130 -0
- package/skills/database-cosmosdb-datamodeling.md +1046 -0
- package/skills/database-durable-objects.md +187 -0
- package/skills/database-ef-core.md +76 -0
- package/skills/database-fabric-lakehouse.md +107 -0
- package/skills/database-neon-postgres-egress-optimizer.md +213 -0
- package/skills/database-neon-postgres.md +218 -0
- package/skills/database-postgresql-code-review.md +213 -0
- package/skills/database-postgresql-optimization.md +405 -0
- package/skills/database-sql-code-review.md +302 -0
- package/skills/database-sql-optimization.md +297 -0
- package/skills/dependency-audit.md +165 -0
- package/skills/design-kami-landing.md +234 -0
- package/skills/design.md +221 -0
- package/skills/dev-acquire-codebase-knowledge.md +175 -0
- package/skills/dev-add-educational-comments.md +129 -0
- package/skills/dev-add-model-descriptions.md +74 -0
- package/skills/dev-adr-review.md +56 -0
- package/skills/dev-boost-prompt.md +26 -0
- package/skills/dev-build-run-debug.md +130 -0
- package/skills/dev-chunk.md +49 -0
- package/skills/dev-claude-md-improver.md +180 -0
- package/skills/dev-code-exemplars-blueprint-generator.md +127 -0
- package/skills/dev-code-tour.md +434 -0
- package/skills/dev-comment-code-generate-a-tutorial.md +27 -0
- package/skills/dev-commit.md +81 -0
- package/skills/dev-context-map.md +53 -0
- package/skills/dev-conventional-commit.md +73 -0
- package/skills/dev-create-architectural-decision-record.md +98 -0
- package/skills/dev-create-draft-pr.md +17 -0
- package/skills/dev-create-pr.md +17 -0
- package/skills/dev-create-readme.md +22 -0
- package/skills/dev-csharp-mstest.md +479 -0
- package/skills/dev-csharp-nunit.md +72 -0
- package/skills/dev-csharp-tunit.md +101 -0
- package/skills/dev-csharp-xunit.md +69 -0
- package/skills/dev-debug-failing-test.md +90 -0
- package/skills/dev-diff-analyze.md +32 -0
- package/skills/dev-diffs.md +24 -0
- package/skills/dev-dotnet-best-practices.md +86 -0
- package/skills/dev-dotnet-design-pattern-review.md +43 -0
- package/skills/dev-dotnet-timezone.md +110 -0
- package/skills/dev-dotnet-upgrade.md +117 -0
- package/skills/dev-doublecheck.md +278 -0
- package/skills/dev-explain-error.md +15 -0
- package/skills/dev-finding-discovery.md +164 -0
- package/skills/dev-fix-finding.md +111 -0
- package/skills/dev-full-file-edit.md +25 -0
- package/skills/dev-git-commit.md +125 -0
- package/skills/dev-git-flow-branch-creator.md +293 -0
- package/skills/dev-git-workflow.md +46 -0
- package/skills/dev-github-automation.md +64 -0
- package/skills/dev-github-code-review.md +1140 -0
- package/skills/dev-github-issues.md +202 -0
- package/skills/dev-gpt-5-4-prompting.md +55 -0
- package/skills/dev-investigation-mode.md +277 -0
- package/skills/dev-java-add-graalvm-native-image-support.md +450 -0
- package/skills/dev-java-docs.md +24 -0
- package/skills/dev-java-refactoring-extract-method.md +105 -0
- package/skills/dev-java-refactoring-remove-parameter.md +85 -0
- package/skills/dev-merge.md +73 -0
- package/skills/dev-migrate-create.md +36 -0
- package/skills/dev-migrate-validate.md +36 -0
- package/skills/dev-my-issues.md +9 -0
- package/skills/dev-my-pull-requests.md +15 -0
- package/skills/dev-planning-oracle-to-postgres-migration-integration-testing.md +45 -0
- package/skills/dev-playwright-generate-test.md +18 -0
- package/skills/dev-playwright.md +148 -0
- package/skills/dev-prompt-builder.md +142 -0
- package/skills/dev-pytest-coverage.md +29 -0
- package/skills/dev-python-manager-discovery.md +330 -0
- package/skills/dev-python-pypi-package-builder.md +445 -0
- package/skills/dev-readme-blueprint-generator.md +79 -0
- package/skills/dev-refactor-method-complexity-reduce.md +99 -0
- package/skills/dev-refactor-plan.md +66 -0
- package/skills/dev-refactor.md +646 -0
- package/skills/dev-review-and-refactor.md +16 -0
- package/skills/dev-reviewing-oracle-to-postgres-migration.md +68 -0
- package/skills/dev-ruff-recursive-fix.md +201 -0
- package/skills/dev-run-e2e-tests.md +126 -0
- package/skills/dev-run-pre-commit-checks.md +133 -0
- package/skills/dev-run-smoke-tests.md +127 -0
- package/skills/dev-scaffolding-oracle-to-postgres-migration-test-project.md +55 -0
- package/skills/dev-spring-boot-testing.md +190 -0
- package/skills/dev-sync-upstream.md +32 -0
- package/skills/dev-sync.md +74 -0
- package/skills/dev-tdd-workflow.md +23 -0
- package/skills/dev-terraform-azurerm-set-diff-analyzer.md +49 -0
- package/skills/dev-test-driven-development.md +372 -0
- package/skills/dev-test-gaps.md +18 -0
- package/skills/dev-test-triage.md +55 -0
- package/skills/dev-typer.md +267 -0
- package/skills/dev-typescript-setup.md +25 -0
- package/skills/dev-unified-diff-edit.md +16 -0
- package/skills/dev-unit-test-vue-pinia.md +198 -0
- package/skills/dev-using-git-worktrees.md +216 -0
- package/skills/dev-validation.md +99 -0
- package/skills/dev-verification.md +168 -0
- package/skills/dev-webapp-testing.md +134 -0
- package/skills/dev-write-coding-standards-from-file.md +317 -0
- package/skills/dev-write-tests.md +16 -0
- package/skills/devops-appinsights-instrumentation.md +49 -0
- package/skills/devops-az-cost-optimize.md +306 -0
- package/skills/devops-chronicle.md +154 -0
- package/skills/devops-deployments-cicd.md +331 -0
- package/skills/devops-devops-rollout-plan.md +118 -0
- package/skills/devops-geistdocs.md +276 -0
- package/skills/devops-observability.md +774 -0
- package/skills/devops-observe-metrics.md +35 -0
- package/skills/devops-observe-trace.md +30 -0
- package/skills/devops-phoenix-cli.md +163 -0
- package/skills/devops-phoenix-tracing.md +140 -0
- package/skills/devops-publish-to-pages.md +108 -0
- package/skills/devops-telemetry.md +87 -0
- package/skills/devops-update-avm-modules-in-bicep.md +61 -0
- package/skills/devops.md +81 -0
- package/skills/diagrams-canvas.md +204 -0
- package/skills/diagrams-draw-io-diagram-generator.md +463 -0
- package/skills/diagrams-excalidraw-diagram-generator.md +614 -0
- package/skills/diagrams-graphify.md +1277 -0
- package/skills/docs-bear-notes.md +108 -0
- package/skills/docs-create-llms.md +211 -0
- package/skills/docs-doc-gen.md +20 -0
- package/skills/docs-documentation-writer.md +46 -0
- package/skills/docs-llm-config.md +33 -0
- package/skills/docs-mkdocs-translations.md +109 -0
- package/skills/docs-obsidian-vault-maintainer.md +14 -0
- package/skills/docs-obsidian.md +82 -0
- package/skills/docs-prose.md +324 -0
- package/skills/docs-update-llms.md +217 -0
- package/skills/docs-update-markdown-file-index.md +77 -0
- package/skills/docs-wiki-maintainer.md +20 -0
- package/skills/documents.md +120 -0
- package/skills/email.md +113 -0
- package/skills/expenses.md +140 -0
- package/skills/file-ops.md +149 -0
- package/skills/files-convert-plaintext-to-md.md +363 -0
- package/skills/files-doc.md +81 -0
- package/skills/files-docx.md +594 -0
- package/skills/files-markdown-to-html.md +917 -0
- package/skills/files-nano-pdf.md +39 -0
- package/skills/files-pdf.md +315 -0
- package/skills/files-pdftk-server.md +163 -0
- package/skills/files-pptx-html-fidelity-audit.md +255 -0
- package/skills/files-pptx.md +231 -0
- package/skills/files-xlsx.md +301 -0
- package/skills/find-jobs.md +78 -0
- package/skills/format-conversion.md +157 -0
- package/skills/frontend-ai-elements.md +483 -0
- package/skills/frontend-ai-gateway.md +563 -0
- package/skills/frontend-ai-generation-persistence.md +242 -0
- package/skills/frontend-ai-sdk.md +799 -0
- package/skills/frontend-ai-visibility.md +127 -0
- package/skills/frontend-angular-developer.md +130 -0
- package/skills/frontend-aspnet-minimal-api-openapi.md +42 -0
- package/skills/frontend-bencium-innovative-ux-designer.md +719 -0
- package/skills/frontend-chat-sdk.md +666 -0
- package/skills/frontend-chrome-devtools.md +98 -0
- package/skills/frontend-frontend-app-builder.md +186 -0
- package/skills/frontend-frontend-design.md +43 -0
- package/skills/frontend-frontend-testing-debugging.md +143 -0
- package/skills/frontend-gsap-framer-scroll-animation.md +152 -0
- package/skills/frontend-internal-linking.md +109 -0
- package/skills/frontend-json-render.md +335 -0
- package/skills/frontend-keyword-clustering.md +118 -0
- package/skills/frontend-next-intl-add-language.md +20 -0
- package/skills/frontend-on-page-seo.md +112 -0
- package/skills/frontend-premium-frontend-ui.md +114 -0
- package/skills/frontend-react-best-practices.md +143 -0
- package/skills/frontend-schema-markup.md +160 -0
- package/skills/frontend-seo-audit.md +110 -0
- package/skills/frontend-swr.md +215 -0
- package/skills/frontend-technical-seo.md +162 -0
- package/skills/frontend-use-dom.md +418 -0
- package/skills/frontend-web-coder.md +564 -0
- package/skills/frontend-web-design-reviewer.md +369 -0
- package/skills/frontend-web-perf.md +202 -0
- package/skills/frontend.md +125 -0
- package/skills/general-adapter-standalone.md +199 -0
- package/skills/general-auth.md +356 -0
- package/skills/general-containerize-aspnetcore.md +393 -0
- package/skills/general-create-technical-spike.md +231 -0
- package/skills/general-cron-jobs.md +72 -0
- package/skills/general-ddd-aggregate.md +52 -0
- package/skills/general-ddd-context.md +46 -0
- package/skills/general-ddd-validate.md +51 -0
- package/skills/general-dependency-check.md +26 -0
- package/skills/general-email-marketing.md +86 -0
- package/skills/general-healthcheck.md +246 -0
- package/skills/general-import-infrastructure-as-code.md +368 -0
- package/skills/general-init.md +49 -0
- package/skills/general-java-junit.md +64 -0
- package/skills/general-java-springboot.md +66 -0
- package/skills/general-javascript-typescript-jest.md +45 -0
- package/skills/general-kotlin-springboot.md +71 -0
- package/skills/general-make-repo-contribution.md +91 -0
- package/skills/general-market-research.md +78 -0
- package/skills/general-marketplace.md +468 -0
- package/skills/general-model-recommendation.md +673 -0
- package/skills/general-payments.md +352 -0
- package/skills/general-quality-playbook.md +480 -0
- package/skills/general-run-integration-tests.md +113 -0
- package/skills/general-superjson.md +274 -0
- package/skills/general-swiftpm-macos.md +51 -0
- package/skills/general-threat-model.md +61 -0
- package/skills/invoices.md +167 -0
- package/skills/licenses.md +159 -0
- package/skills/logs.md +156 -0
- package/skills/marketing.md +139 -0
- package/skills/media-image-manipulation-image-magick.md +253 -0
- package/skills/media-imagegen.md +357 -0
- package/skills/media-openai-whisper-api.md +63 -0
- package/skills/media-openai-whisper.md +39 -0
- package/skills/media-peekaboo.md +191 -0
- package/skills/media-screenshot.md +268 -0
- package/skills/media-speech.md +145 -0
- package/skills/media-transcribe.md +82 -0
- package/skills/media-video-frames.md +47 -0
- package/skills/mobile-android-emulator-qa.md +81 -0
- package/skills/mobile-android-performance.md +280 -0
- package/skills/mobile-building-mcp-server-on-cloudflare.md +267 -0
- package/skills/mobile-building-native-ui.md +322 -0
- package/skills/mobile-expo-api-routes.md +369 -0
- package/skills/mobile-expo-cicd-workflows.md +92 -0
- package/skills/mobile-expo-deployment.md +191 -0
- package/skills/mobile-expo-dev-client.md +165 -0
- package/skills/mobile-expo-module.md +177 -0
- package/skills/mobile-expo-tailwind-setup.md +481 -0
- package/skills/mobile-expo-ui-jetpack-compose.md +41 -0
- package/skills/mobile-expo-ui-swift-ui.md +40 -0
- package/skills/mobile-ios-app-intents.md +78 -0
- package/skills/mobile-ios-debugger-agent.md +52 -0
- package/skills/mobile-ios-ettrace-performance.md +198 -0
- package/skills/mobile-ios-memgraph-leaks.md +77 -0
- package/skills/mobile-native-data-fetching.md +508 -0
- package/skills/mobile-packaging-notarization.md +48 -0
- package/skills/mobile-react-native-architecture.md +672 -0
- package/skills/mobile-react-native-mobile-design.md +438 -0
- package/skills/mobile-signing-entitlements.md +59 -0
- package/skills/mobile-swiftui-liquid-glass.md +91 -0
- package/skills/mobile-swiftui-patterns.md +210 -0
- package/skills/mobile-swiftui-performance-audit.md +108 -0
- package/skills/mobile-swiftui-ui-patterns.md +97 -0
- package/skills/mobile-swiftui-view-refactor.md +204 -0
- package/skills/mobile-upgrading-expo.md +134 -0
- package/skills/mobile.md +183 -0
- package/skills/notes.md +106 -0
- package/skills/planning-adr-create.md +62 -0
- package/skills/planning-adr-index.md +67 -0
- package/skills/planning-architecture-blueprint-generator.md +323 -0
- package/skills/planning-brainstorming.md +165 -0
- package/skills/planning-breakdown-epic-arch.md +67 -0
- package/skills/planning-breakdown-epic-pm.md +59 -0
- package/skills/planning-breakdown-feature-implementation.md +129 -0
- package/skills/planning-breakdown-feature-prd.md +62 -0
- package/skills/planning-breakdown-plan.md +510 -0
- package/skills/planning-breakdown-test.md +366 -0
- package/skills/planning-cloud-design-patterns.md +63 -0
- package/skills/planning-content-brief.md +128 -0
- package/skills/planning-content-strategy.md +138 -0
- package/skills/planning-content-translation.md +143 -0
- package/skills/planning-create-github-action-workflow-specification.md +277 -0
- package/skills/planning-create-github-issues-feature-from-implementation-plan.md +29 -0
- package/skills/planning-create-github-issues-for-unmet-specification-requirements.md +36 -0
- package/skills/planning-create-github-pull-request-from-specification.md +25 -0
- package/skills/planning-create-implementation-plan.md +158 -0
- package/skills/planning-create-specification.md +128 -0
- package/skills/planning-first-ask.md +31 -0
- package/skills/planning-folder-structure-blueprint-generator.md +406 -0
- package/skills/planning-gen-specs-as-issues.md +166 -0
- package/skills/planning-generate-snapshot.md +144 -0
- package/skills/planning-generate-status-report.md +336 -0
- package/skills/planning-metric-pack-designer.md +27 -0
- package/skills/planning-pm-spec.md +53 -0
- package/skills/planning-prd.md +144 -0
- package/skills/planning-project-assessment.md +182 -0
- package/skills/planning-project-setup-info-local.md +128 -0
- package/skills/planning-project-workflow-analysis-blueprint-generator.md +294 -0
- package/skills/planning-service-oriented-architecture.md +248 -0
- package/skills/planning-spec-to-backlog.md +544 -0
- package/skills/planning-technology-stack-blueprint-generator.md +243 -0
- package/skills/planning-update-implementation-plan.md +158 -0
- package/skills/planning-update-specification.md +128 -0
- package/skills/planning-what-context-needed.md +40 -0
- package/skills/planning-writing-plans.md +153 -0
- package/skills/prepare-application.md +81 -0
- package/skills/productivity-apple-notes.md +78 -0
- package/skills/productivity-apple-reminders.md +119 -0
- package/skills/productivity-capture-tasks-from-meeting-notes.md +680 -0
- package/skills/productivity-daily-prep.md +156 -0
- package/skills/productivity-email-drafter.md +101 -0
- package/skills/productivity-hr-onboarding.md +53 -0
- package/skills/productivity-things-mac.md +87 -0
- package/skills/productivity-update.md +169 -0
- package/skills/reminders.md +109 -0
- package/skills/research-dossier-collect.md +71 -0
- package/skills/research-kg-extract.md +37 -0
- package/skills/research-openai-docs.md +89 -0
- package/skills/research-research-add-items.md +31 -0
- package/skills/research-research-report.md +94 -0
- package/skills/research-research-synthesize.md +63 -0
- package/skills/research-summarize.md +88 -0
- package/skills/research-transformers-js.md +635 -0
- package/skills/research.md +119 -0
- package/skills/security-ai-prompt-engineering-safety-review.md +231 -0
- package/skills/security-attack-path-analysis.md +182 -0
- package/skills/security-gdpr-compliant.md +284 -0
- package/skills/security-mcp-security-audit.md +279 -0
- package/skills/security-pii-detect.md +31 -0
- package/skills/security-secret-scanning.md +243 -0
- package/skills/security-security-best-practices.md +87 -0
- package/skills/security-security-ownership-map.md +207 -0
- package/skills/security-security-review.md +169 -0
- package/skills/security-security-scan.md +138 -0
- package/skills/security-security-threat-model.md +82 -0
- package/skills/security-threat-model-analyst.md +76 -0
- package/skills/sysmon.md +181 -0
- package/skills/system-arch-linux-triage.md +32 -0
- package/skills/system-centos-linux-triage.md +32 -0
- package/skills/system-debian-linux-triage.md +32 -0
- package/skills/system-fedora-linux-triage.md +32 -0
- package/skills/system-geofeed-tuner.md +865 -0
- package/skills/system-iot-anomalies.md +15 -0
- package/skills/system-iot-firmware.md +16 -0
- package/skills/system-iot-fleet.md +14 -0
- package/skills/system-iot-register.md +19 -0
- package/skills/system-iot-witness-verify.md +15 -0
- package/skills/system-tmux.md +171 -0
- package/skills/system-window-management.md +228 -0
- package/skills/task-management.md +90 -0
- package/skills/tasks.md +102 -0
- package/skills/test-coverage.md +188 -0
- package/skills/ux-ui.md +128 -0
- package/skills/web.md +186 -0
- package/skills/workflow-act-on-feedback.md +15 -0
- package/skills/workflow-automate-this.md +245 -0
- package/skills/workflow-autoresearch.md +276 -0
- package/skills/workflow-coding-agent.md +317 -0
- package/skills/workflow-deep-research.md +44 -0
- package/skills/workflow-dispatching-parallel-agents.md +183 -0
- package/skills/workflow-eval-driven-dev.md +148 -0
- package/skills/workflow-executing-plans.md +71 -0
- package/skills/workflow-mentoring-juniors.md +311 -0
- package/skills/workflow-receiving-code-review.md +214 -0
- package/skills/workflow-repo-story-time.md +155 -0
- package/skills/workflow-requesting-code-review.md +104 -0
- package/skills/workflow-session-report.md +43 -0
- package/skills/workflow-structured-autonomy-generate.md +126 -0
- package/skills/workflow-subagent-driven-development.md +280 -0
- package/skills/writing.md +106 -0
- package/src/agent.js +0 -0
- package/src/browser.js +297 -0
- package/src/cli.js +25 -4
- package/src/code-reviewer.js +119 -0
- package/src/completions.js +1 -1
- package/src/control.js +222 -30
- package/src/coordinator.js +303 -0
- package/src/correction.js +29 -8
- package/src/edit-tracker.js +21 -0
- package/src/edit-viewer.js +414 -0
- package/src/endpoints.js +64 -15
- package/src/index.js +45 -11
- package/src/llm.js +86 -2
- package/src/mcp-client.js +416 -0
- package/src/memory.js +182 -0
- package/src/planner.js +216 -0
- package/src/rules.js +90 -0
- package/src/self-commands.js +757 -0
- package/src/services/voice.js +10 -7
- package/src/session-search.js +427 -0
- package/src/session.js +487 -99
- package/src/shmakk-server.js +91 -0
- package/src/skills.js +410 -3
- package/src/subagent.js +4 -1
- package/src/system-prompt.js +13 -5
- package/src/task-file.js +114 -0
- package/src/taskClassifier.js +246 -0
- package/src/team.js +752 -0
- package/src/tools.js +142 -21
- package/src/web.js +35 -5
- package/src/workflows.js +261 -0
- package/src/workspace-index.js +25 -6
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: durable-objects
|
|
3
|
+
description: Create and review Cloudflare Durable Objects. Use when building stateful coordination (chat rooms, multiplayer games, booking systems), implementing RPC methods, SQLite storage, alarms, WebSockets, or reviewing DO code for best practices. Covers Workers integration, wrangler config, and testing with Vitest. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
|
|
4
|
+
category: database
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Durable Objects
|
|
8
|
+
|
|
9
|
+
Build stateful, coordinated applications on Cloudflare's edge using Durable Objects.
|
|
10
|
+
|
|
11
|
+
## Retrieval Sources
|
|
12
|
+
|
|
13
|
+
Your knowledge of Durable Objects APIs and configuration may be outdated. **Prefer retrieval over pre-training** for any Durable Objects task.
|
|
14
|
+
|
|
15
|
+
| Resource | URL |
|
|
16
|
+
|----------|-----|
|
|
17
|
+
| Docs | https://developers.cloudflare.com/durable-objects/ |
|
|
18
|
+
| API Reference | https://developers.cloudflare.com/durable-objects/api/ |
|
|
19
|
+
| Best Practices | https://developers.cloudflare.com/durable-objects/best-practices/ |
|
|
20
|
+
| Examples | https://developers.cloudflare.com/durable-objects/examples/ |
|
|
21
|
+
|
|
22
|
+
Fetch the relevant doc page when implementing features.
|
|
23
|
+
|
|
24
|
+
## When to Use
|
|
25
|
+
|
|
26
|
+
- Creating new Durable Object classes for stateful coordination
|
|
27
|
+
- Implementing RPC methods, alarms, or WebSocket handlers
|
|
28
|
+
- Reviewing existing DO code for best practices
|
|
29
|
+
- Configuring wrangler.jsonc/toml for DO bindings and migrations
|
|
30
|
+
- Writing tests with `@cloudflare/vitest-pool-workers`
|
|
31
|
+
- Designing sharding strategies and parent-child relationships
|
|
32
|
+
|
|
33
|
+
## Reference Documentation
|
|
34
|
+
|
|
35
|
+
- `./references/rules.md` - Core rules, storage, concurrency, RPC, alarms
|
|
36
|
+
- `./references/testing.md` - Vitest setup, unit/integration tests, alarm testing
|
|
37
|
+
- `./references/workers.md` - Workers handlers, types, wrangler config, observability
|
|
38
|
+
|
|
39
|
+
Search: `blockConcurrencyWhile`, `idFromName`, `getByName`, `setAlarm`, `sql.exec`
|
|
40
|
+
|
|
41
|
+
## Core Principles
|
|
42
|
+
|
|
43
|
+
### Use Durable Objects For
|
|
44
|
+
|
|
45
|
+
| Need | Example |
|
|
46
|
+
|------|---------|
|
|
47
|
+
| Coordination | Chat rooms, multiplayer games, collaborative docs |
|
|
48
|
+
| Strong consistency | Inventory, booking systems, turn-based games |
|
|
49
|
+
| Per-entity storage | Multi-tenant SaaS, per-user data |
|
|
50
|
+
| Persistent connections | WebSockets, real-time notifications |
|
|
51
|
+
| Scheduled work per entity | Subscription renewals, game timeouts |
|
|
52
|
+
|
|
53
|
+
### Do NOT Use For
|
|
54
|
+
|
|
55
|
+
- Stateless request handling (use plain Workers)
|
|
56
|
+
- Maximum global distribution needs
|
|
57
|
+
- High fan-out independent requests
|
|
58
|
+
|
|
59
|
+
## Quick Reference
|
|
60
|
+
|
|
61
|
+
### Wrangler Configuration
|
|
62
|
+
|
|
63
|
+
```jsonc
|
|
64
|
+
// wrangler.jsonc
|
|
65
|
+
{
|
|
66
|
+
"durable_objects": {
|
|
67
|
+
"bindings": [{ "name": "MY_DO", "class_name": "MyDurableObject" }]
|
|
68
|
+
},
|
|
69
|
+
"migrations": [{ "tag": "v1", "new_sqlite_classes": ["MyDurableObject"] }]
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Basic Durable Object Pattern
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { DurableObject } from "cloudflare:workers";
|
|
77
|
+
|
|
78
|
+
export interface Env {
|
|
79
|
+
MY_DO: DurableObjectNamespace<MyDurableObject>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export class MyDurableObject extends DurableObject<Env> {
|
|
83
|
+
constructor(ctx: DurableObjectState, env: Env) {
|
|
84
|
+
super(ctx, env);
|
|
85
|
+
ctx.blockConcurrencyWhile(async () => {
|
|
86
|
+
this.ctx.storage.sql.exec(`
|
|
87
|
+
CREATE TABLE IF NOT EXISTS items (
|
|
88
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
89
|
+
data TEXT NOT NULL
|
|
90
|
+
)
|
|
91
|
+
`);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async addItem(data: string): Promise<number> {
|
|
96
|
+
const result = this.ctx.storage.sql.exec<{ id: number }>(
|
|
97
|
+
"INSERT INTO items (data) VALUES (?) RETURNING id",
|
|
98
|
+
data
|
|
99
|
+
);
|
|
100
|
+
return result.one().id;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default {
|
|
105
|
+
async fetch(request: Request, env: Env): Promise<Response> {
|
|
106
|
+
const stub = env.MY_DO.getByName("my-instance");
|
|
107
|
+
const id = await stub.addItem("hello");
|
|
108
|
+
return Response.json({ id });
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Critical Rules
|
|
114
|
+
|
|
115
|
+
1. **Model around coordination atoms** - One DO per chat room/game/user, not one global DO
|
|
116
|
+
2. **Use `getByName()` for deterministic routing** - Same input = same DO instance
|
|
117
|
+
3. **Use SQLite storage** - Configure `new_sqlite_classes` in migrations
|
|
118
|
+
4. **Initialize in constructor** - Use `blockConcurrencyWhile()` for schema setup only
|
|
119
|
+
5. **Use RPC methods** - Not fetch() handler (compatibility date >= 2024-04-03)
|
|
120
|
+
6. **Persist first, cache second** - Always write to storage before updating in-memory state
|
|
121
|
+
7. **One alarm per DO** - `setAlarm()` replaces any existing alarm
|
|
122
|
+
|
|
123
|
+
## Anti-Patterns (NEVER)
|
|
124
|
+
|
|
125
|
+
- Single global DO handling all requests (bottleneck)
|
|
126
|
+
- Using `blockConcurrencyWhile()` on every request (kills throughput)
|
|
127
|
+
- Storing critical state only in memory (lost on eviction/crash)
|
|
128
|
+
- Using `await` between related storage writes (breaks atomicity)
|
|
129
|
+
- Holding `blockConcurrencyWhile()` across `fetch()` or external I/O
|
|
130
|
+
|
|
131
|
+
## Stub Creation
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
// Deterministic - preferred for most cases
|
|
135
|
+
const stub = env.MY_DO.getByName("room-123");
|
|
136
|
+
|
|
137
|
+
// From existing ID string
|
|
138
|
+
const id = env.MY_DO.idFromString(storedIdString);
|
|
139
|
+
const stub = env.MY_DO.get(id);
|
|
140
|
+
|
|
141
|
+
// New unique ID - store mapping externally
|
|
142
|
+
const id = env.MY_DO.newUniqueId();
|
|
143
|
+
const stub = env.MY_DO.get(id);
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Storage Operations
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
// SQL (synchronous, recommended)
|
|
150
|
+
this.ctx.storage.sql.exec("INSERT INTO t (c) VALUES (?)", value);
|
|
151
|
+
const rows = this.ctx.storage.sql.exec<Row>("SELECT * FROM t").toArray();
|
|
152
|
+
|
|
153
|
+
// KV (async)
|
|
154
|
+
await this.ctx.storage.put("key", value);
|
|
155
|
+
const val = await this.ctx.storage.get<Type>("key");
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Alarms
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
// Schedule (replaces existing)
|
|
162
|
+
await this.ctx.storage.setAlarm(Date.now() + 60_000);
|
|
163
|
+
|
|
164
|
+
// Handler
|
|
165
|
+
async alarm(): Promise<void> {
|
|
166
|
+
// Process scheduled work
|
|
167
|
+
// Optionally reschedule: await this.ctx.storage.setAlarm(...)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Cancel
|
|
171
|
+
await this.ctx.storage.deleteAlarm();
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Testing Quick Start
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
import { env } from "cloudflare:test";
|
|
178
|
+
import { describe, it, expect } from "vitest";
|
|
179
|
+
|
|
180
|
+
describe("MyDO", () => {
|
|
181
|
+
it("should work", async () => {
|
|
182
|
+
const stub = env.MY_DO.getByName("test");
|
|
183
|
+
const result = await stub.addItem("test");
|
|
184
|
+
expect(result).toBe(1);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
```
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ef-core
|
|
3
|
+
description: 'Get best practices for Entity Framework Core'
|
|
4
|
+
category: database
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Entity Framework Core Best Practices
|
|
8
|
+
|
|
9
|
+
Your goal is to help me follow best practices when working with Entity Framework Core.
|
|
10
|
+
|
|
11
|
+
## Data Context Design
|
|
12
|
+
|
|
13
|
+
- Keep DbContext classes focused and cohesive
|
|
14
|
+
- Use constructor injection for configuration options
|
|
15
|
+
- Override OnModelCreating for fluent API configuration
|
|
16
|
+
- Separate entity configurations using IEntityTypeConfiguration
|
|
17
|
+
- Consider using DbContextFactory pattern for console apps or tests
|
|
18
|
+
|
|
19
|
+
## Entity Design
|
|
20
|
+
|
|
21
|
+
- Use meaningful primary keys (consider natural vs surrogate keys)
|
|
22
|
+
- Implement proper relationships (one-to-one, one-to-many, many-to-many)
|
|
23
|
+
- Use data annotations or fluent API for constraints and validations
|
|
24
|
+
- Implement appropriate navigational properties
|
|
25
|
+
- Consider using owned entity types for value objects
|
|
26
|
+
|
|
27
|
+
## Performance
|
|
28
|
+
|
|
29
|
+
- Use AsNoTracking() for read-only queries
|
|
30
|
+
- Implement pagination for large result sets with Skip() and Take()
|
|
31
|
+
- Use Include() to eager load related entities when needed
|
|
32
|
+
- Consider projection (Select) to retrieve only required fields
|
|
33
|
+
- Use compiled queries for frequently executed queries
|
|
34
|
+
- Avoid N+1 query problems by properly including related data
|
|
35
|
+
|
|
36
|
+
## Migrations
|
|
37
|
+
|
|
38
|
+
- Create small, focused migrations
|
|
39
|
+
- Name migrations descriptively
|
|
40
|
+
- Verify migration SQL scripts before applying to production
|
|
41
|
+
- Consider using migration bundles for deployment
|
|
42
|
+
- Add data seeding through migrations when appropriate
|
|
43
|
+
|
|
44
|
+
## Querying
|
|
45
|
+
|
|
46
|
+
- Use IQueryable judiciously and understand when queries execute
|
|
47
|
+
- Prefer strongly-typed LINQ queries over raw SQL
|
|
48
|
+
- Use appropriate query operators (Where, OrderBy, GroupBy)
|
|
49
|
+
- Consider database functions for complex operations
|
|
50
|
+
- Implement specifications pattern for reusable queries
|
|
51
|
+
|
|
52
|
+
## Change Tracking & Saving
|
|
53
|
+
|
|
54
|
+
- Use appropriate change tracking strategies
|
|
55
|
+
- Batch your SaveChanges() calls
|
|
56
|
+
- Implement concurrency control for multi-user scenarios
|
|
57
|
+
- Consider using transactions for multiple operations
|
|
58
|
+
- Use appropriate DbContext lifetimes (scoped for web apps)
|
|
59
|
+
|
|
60
|
+
## Security
|
|
61
|
+
|
|
62
|
+
- Avoid SQL injection by using parameterized queries
|
|
63
|
+
- Implement appropriate data access permissions
|
|
64
|
+
- Be careful with raw SQL queries
|
|
65
|
+
- Consider data encryption for sensitive information
|
|
66
|
+
- Use migrations to manage database user permissions
|
|
67
|
+
|
|
68
|
+
## Testing
|
|
69
|
+
|
|
70
|
+
- Use in-memory database provider for unit tests
|
|
71
|
+
- Create separate testing contexts with SQLite for integration tests
|
|
72
|
+
- Mock DbContext and DbSet for pure unit tests
|
|
73
|
+
- Test migrations in isolated environments
|
|
74
|
+
- Consider snapshot testing for model changes
|
|
75
|
+
|
|
76
|
+
When reviewing my EF Core code, identify issues and suggest improvements that follow these best practices.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fabric-lakehouse
|
|
3
|
+
description: 'Use this skill to get context about Fabric Lakehouse and its features for software systems and AI-powered functions. It offers descriptions of Lakehouse data components, organization with schemas and shortcuts, access control, and code examples. This skill supports users in designing, building, and optimizing Lakehouse solutions using best practices.'
|
|
4
|
+
metadata:
|
|
5
|
+
author: tedvilutis
|
|
6
|
+
version: "1.0"
|
|
7
|
+
category: database
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# When to Use This Skill
|
|
11
|
+
|
|
12
|
+
Use this skill when you need to:
|
|
13
|
+
- Generate a document or explanation that includes definition and context about Fabric Lakehouse and its capabilities.
|
|
14
|
+
- Design, build, and optimize Lakehouse solutions using best practices.
|
|
15
|
+
- Understand the core concepts and components of a Lakehouse in Microsoft Fabric.
|
|
16
|
+
- Learn how to manage tabular and non-tabular data within a Lakehouse.
|
|
17
|
+
|
|
18
|
+
# Fabric Lakehouse
|
|
19
|
+
|
|
20
|
+
## Core Concepts
|
|
21
|
+
|
|
22
|
+
### What is a Lakehouse?
|
|
23
|
+
|
|
24
|
+
Lakehouse in Microsoft Fabric is an item that gives users a place to store their tabular data (like tables) and non-tabular data (like files). It combines the flexibility of a data lake with the management capabilities of a data warehouse. It provides:
|
|
25
|
+
|
|
26
|
+
- **Unified storage** in OneLake for structured and unstructured data
|
|
27
|
+
- **Delta Lake format** for ACID transactions, versioning, and time travel
|
|
28
|
+
- **SQL analytics endpoint** for T-SQL queries
|
|
29
|
+
- **Semantic model** for Power BI integration
|
|
30
|
+
- Support for other table formats like CSV, Parquet
|
|
31
|
+
- Support for any file formats
|
|
32
|
+
- Tools for table optimization and data management
|
|
33
|
+
|
|
34
|
+
### Key Components
|
|
35
|
+
|
|
36
|
+
- **Delta Tables**: Managed tables with ACID compliance and schema enforcement
|
|
37
|
+
- **Files**: Unstructured/semi-structured data in the Files section
|
|
38
|
+
- **SQL Endpoint**: Auto-generated read-only SQL interface for querying
|
|
39
|
+
- **Shortcuts**: Virtual links to external/internal data without copying
|
|
40
|
+
- **Fabric Materialized Views**: Pre-computed tables for fast query performance
|
|
41
|
+
|
|
42
|
+
### Tabular data in a Lakehouse
|
|
43
|
+
|
|
44
|
+
Tabular data in a form of tables are stored under "Tables" folder. Main format for tables in Lakehouse is Delta. Lakehouse can store tabular data in other formats like CSV or Parquet, these formats are only available for Spark querying.
|
|
45
|
+
Tables can be internal, when data is stored under "Tables" folder, or external, when only reference to a table is stored under "Tables" folder but the data itself is stored in a referenced location. Tables are referenced through Shortcuts, which can be internal (pointing to another location in Fabric) or external (pointing to data stored outside of Fabric).
|
|
46
|
+
|
|
47
|
+
### Schemas for tables in a Lakehouse
|
|
48
|
+
|
|
49
|
+
When creating a lakehouse, users can choose to enable schemas. Schemas are used to organize Lakehouse tables. Schemas are implemented as folders under the "Tables" folder and store tables inside of those folders. The default schema is "dbo" and it can't be deleted or renamed. All other schemas are optional and can be created, renamed, or deleted. Users can reference a schema located in another lakehouse using a Schema Shortcut, thereby referencing all tables in the destination schema with a single shortcut.
|
|
50
|
+
|
|
51
|
+
### Files in a Lakehouse
|
|
52
|
+
|
|
53
|
+
Files are stored under "Files" folder. Users can create folders and subfolders to organize their files. Any file format can be stored in Lakehouse.
|
|
54
|
+
|
|
55
|
+
### Fabric Materialized Views
|
|
56
|
+
|
|
57
|
+
Set of pre-computed tables that are automatically updated based on a schedule. They provide fast query performance for complex aggregations and joins. Materialized views are defined using PySpark or Spark SQL and stored in an associated Notebook.
|
|
58
|
+
|
|
59
|
+
### Spark Views
|
|
60
|
+
|
|
61
|
+
Logical tables defined by a SQL query. They do not store data but provide a virtual layer for querying. Views are defined using Spark SQL and stored in Lakehouse next to Tables.
|
|
62
|
+
|
|
63
|
+
## Security
|
|
64
|
+
|
|
65
|
+
### Item access or control plane security
|
|
66
|
+
|
|
67
|
+
Users can have workspace roles (Admin, Member, Contributor, Viewer) that provide different levels of access to Lakehouse and its contents. Users can also get access permission using sharing capabilities of Lakehouse.
|
|
68
|
+
|
|
69
|
+
### Data access or OneLake Security
|
|
70
|
+
|
|
71
|
+
For data access use OneLake security model, which is based on Microsoft Entra ID (formerly Azure Active Directory) and role-based access control (RBAC). Lakehouse data is stored in OneLake, so access to data is controlled through OneLake permissions. In addition to object-level permissions, Lakehouse also supports column-level and row-level security for tables, allowing fine-grained control over who can see specific columns or rows in a table.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Lakehouse Shortcuts
|
|
75
|
+
|
|
76
|
+
Shortcuts create virtual links to data without copying:
|
|
77
|
+
|
|
78
|
+
### Types of Shortcuts
|
|
79
|
+
|
|
80
|
+
- **Internal**: Link to other Fabric Lakehouses/tables, cross-workspace data sharing
|
|
81
|
+
- **ADLS Gen2**: Link to ADLS Gen2 containers in Azure
|
|
82
|
+
- **Amazon S3**: AWS S3 buckets, cross-cloud data access
|
|
83
|
+
- **Dataverse**: Microsoft Dataverse, business application data
|
|
84
|
+
- **Google Cloud Storage**: GCS buckets, cross-cloud data access
|
|
85
|
+
|
|
86
|
+
## Performance Optimization
|
|
87
|
+
|
|
88
|
+
### V-Order Optimization
|
|
89
|
+
|
|
90
|
+
For faster data read with semantic model enable V-Order optimization on Delta tables. This presorts data in a way that improves query performance for common access patterns.
|
|
91
|
+
|
|
92
|
+
### Table Optimization
|
|
93
|
+
|
|
94
|
+
Tables can also be optimized using the OPTIMIZE command, which compacts small files into larger ones and can also apply Z-ordering to improve query performance on specific columns. Regular optimization helps maintain performance as data is ingested and updated over time. The Vacuum command can be used to clean up old files and free up storage space, especially after updates and deletes.
|
|
95
|
+
|
|
96
|
+
## Lineage
|
|
97
|
+
|
|
98
|
+
The Lakehouse item supports lineage, which allows users to track the origin and transformations of data. Lineage information is automatically captured for tables and files in Lakehouse, showing how data flows from source to destination. This helps with debugging, auditing, and understanding data dependencies.
|
|
99
|
+
|
|
100
|
+
## PySpark Code Examples
|
|
101
|
+
|
|
102
|
+
See [PySpark code](references/pyspark.md) for details.
|
|
103
|
+
|
|
104
|
+
## Getting data into Lakehouse
|
|
105
|
+
|
|
106
|
+
See [Get data](references/getdata.md) for details.
|
|
107
|
+
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: neon-postgres-egress-optimizer
|
|
3
|
+
description: >-
|
|
4
|
+
Diagnose and fix excessive Postgres egress (network data transfer) in a codebase.
|
|
5
|
+
Use when a user mentions high database bills, unexpected data transfer costs,
|
|
6
|
+
network transfer charges, egress spikes, "why is my Neon bill so high",
|
|
7
|
+
"database costs jumped", SELECT * optimization, query overfetching,
|
|
8
|
+
reduce Neon costs, optimize database usage, or wants to reduce data sent
|
|
9
|
+
from their database to their application. Also use when reviewing query
|
|
10
|
+
patterns for cost efficiency, even if the user doesn't explicitly mention
|
|
11
|
+
egress or data transfer.
|
|
12
|
+
category: database
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Postgres Egress Optimizer
|
|
16
|
+
|
|
17
|
+
Guide the user through diagnosing and fixing application-side query patterns that cause excessive data transfer (egress) from their Postgres database. Most high egress bills come from the application fetching more data than it uses.
|
|
18
|
+
|
|
19
|
+
## Step 1: Diagnose
|
|
20
|
+
|
|
21
|
+
Identify which queries transfer the most data. The primary tool is the `pg_stat_statements` extension.
|
|
22
|
+
|
|
23
|
+
### Check if pg_stat_statements is available
|
|
24
|
+
|
|
25
|
+
```sql
|
|
26
|
+
SELECT 1 FROM pg_stat_statements LIMIT 1;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
If this errors, the extension needs to be created:
|
|
30
|
+
|
|
31
|
+
```sql
|
|
32
|
+
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
On Neon, it is available by default but may need this CREATE EXTENSION step.
|
|
36
|
+
|
|
37
|
+
### Handle empty stats
|
|
38
|
+
|
|
39
|
+
Stats are cleared when a Neon compute scales to zero and restarts. If the stats are empty or the compute recently woke up:
|
|
40
|
+
|
|
41
|
+
1. Reset the stats to start a clean measurement window: `SELECT pg_stat_statements_reset();`
|
|
42
|
+
2. Let the application run under representative traffic for at least an hour.
|
|
43
|
+
3. Return and run the diagnostic queries below.
|
|
44
|
+
|
|
45
|
+
If the user has stats from a production database, use those. If they have no access to production stats, proceed to Step 2 and analyze the codebase directly — code-level patterns are often sufficient to identify the worst offenders.
|
|
46
|
+
|
|
47
|
+
### Diagnostic queries
|
|
48
|
+
|
|
49
|
+
Run these to identify the top egress contributors. Focus on queries that return many rows, return wide rows (JSONB, TEXT, BYTEA columns), or are called very frequently.
|
|
50
|
+
|
|
51
|
+
**Queries returning the most total rows:**
|
|
52
|
+
|
|
53
|
+
```sql
|
|
54
|
+
SELECT query, calls, rows AS total_rows, rows / calls AS avg_rows_per_call
|
|
55
|
+
FROM pg_stat_statements
|
|
56
|
+
WHERE calls > 0
|
|
57
|
+
ORDER BY rows DESC
|
|
58
|
+
LIMIT 10;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Queries returning the most rows per execution** (poorly scoped SELECTs, missing pagination):
|
|
62
|
+
|
|
63
|
+
```sql
|
|
64
|
+
SELECT query, calls, rows AS total_rows, rows / calls AS avg_rows_per_call
|
|
65
|
+
FROM pg_stat_statements
|
|
66
|
+
WHERE calls > 0
|
|
67
|
+
ORDER BY avg_rows_per_call DESC
|
|
68
|
+
LIMIT 10;
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Most frequently called queries** (candidates for caching):
|
|
72
|
+
|
|
73
|
+
```sql
|
|
74
|
+
SELECT query, calls, rows AS total_rows, rows / calls AS avg_rows_per_call
|
|
75
|
+
FROM pg_stat_statements
|
|
76
|
+
WHERE calls > 0
|
|
77
|
+
ORDER BY calls DESC
|
|
78
|
+
LIMIT 10;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Longest running queries** (not a direct egress measure, but helps identify problem queries during a spike):
|
|
82
|
+
|
|
83
|
+
```sql
|
|
84
|
+
SELECT query, calls, rows AS total_rows,
|
|
85
|
+
round(total_exec_time::numeric, 2) AS total_exec_time_ms
|
|
86
|
+
FROM pg_stat_statements
|
|
87
|
+
WHERE calls > 0
|
|
88
|
+
ORDER BY total_exec_time DESC
|
|
89
|
+
LIMIT 10;
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Interpret the results
|
|
93
|
+
|
|
94
|
+
Rank findings by estimated egress impact:
|
|
95
|
+
|
|
96
|
+
- **High row count + wide rows** = biggest egress. A query returning 1,000 rows where each row includes a 50KB JSONB column transfers ~50MB per call.
|
|
97
|
+
- **Extreme call frequency** on even small queries adds up. A query called 50,000 times/day returning 10 rows each = 500,000 rows/day.
|
|
98
|
+
- **Cross-reference with the schema** to identify which columns are wide. Look for JSONB, TEXT, BYTEA, and large VARCHAR columns.
|
|
99
|
+
|
|
100
|
+
## Step 2: Analyze codebase
|
|
101
|
+
|
|
102
|
+
For each query identified in Step 1, or for each database query in the codebase if no stats are available, check:
|
|
103
|
+
|
|
104
|
+
- Does it select only the columns the response needs?
|
|
105
|
+
- Does it return a bounded number of rows (LIMIT/pagination)?
|
|
106
|
+
- Is it called frequently enough to benefit from caching?
|
|
107
|
+
- Does it fetch raw data that gets aggregated in application code?
|
|
108
|
+
- Does it use a JOIN that duplicates parent data across child rows?
|
|
109
|
+
|
|
110
|
+
## Step 3: Fix
|
|
111
|
+
|
|
112
|
+
Apply the appropriate fix for each problem found. Below are the most common egress anti-patterns and how to fix them.
|
|
113
|
+
|
|
114
|
+
### Unused columns (SELECT \*)
|
|
115
|
+
|
|
116
|
+
**Problem:** The query fetches all columns but the application only uses a few. Large columns (JSONB blobs, TEXT fields) get transferred over the wire and discarded.
|
|
117
|
+
|
|
118
|
+
**Before:**
|
|
119
|
+
|
|
120
|
+
```sql
|
|
121
|
+
SELECT * FROM products;
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**After:**
|
|
125
|
+
|
|
126
|
+
```sql
|
|
127
|
+
SELECT id, name, price, image_urls FROM products;
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Missing pagination
|
|
131
|
+
|
|
132
|
+
**Problem:** A list endpoint returns all rows with no LIMIT. This is an unbounded egress risk — every new row in the table increases data transfer on every request. Flag this regardless of current table size.
|
|
133
|
+
|
|
134
|
+
This is easy to miss because the application may work fine with small datasets. But at scale, an unpaginated endpoint returning 10,000 rows with even moderate column widths can transfer hundreds of megabytes per day.
|
|
135
|
+
|
|
136
|
+
**Before:**
|
|
137
|
+
|
|
138
|
+
```sql
|
|
139
|
+
SELECT id, name, price FROM products;
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**After:**
|
|
143
|
+
|
|
144
|
+
```sql
|
|
145
|
+
SELECT id, name, price FROM products
|
|
146
|
+
ORDER BY id
|
|
147
|
+
LIMIT 50 OFFSET 0;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
When adding pagination, check whether the consuming client already supports paginated responses. If not, pick sensible defaults and document the pagination parameters in the API.
|
|
151
|
+
|
|
152
|
+
### High-frequency queries on static data
|
|
153
|
+
|
|
154
|
+
**Problem:** A query is called thousands of times per day but returns data that rarely changes. Every call transfers the same rows from the database. This pattern is only visible from `pg_stat_statements` — the code itself looks normal.
|
|
155
|
+
|
|
156
|
+
Look for queries with extremely high call counts relative to other queries. Common examples: configuration tables, category lists, feature flags, user role definitions.
|
|
157
|
+
|
|
158
|
+
**Fix:** Add a caching layer between the application and the database so it avoids hitting the database on every request.
|
|
159
|
+
|
|
160
|
+
### Application-side aggregation
|
|
161
|
+
|
|
162
|
+
**Problem:** The application fetches all rows from a table and then computes aggregates (averages, counts, sums, groupings) in application code. The full dataset transfers over the wire even though the result is a small summary.
|
|
163
|
+
|
|
164
|
+
**Fix:** Push the aggregation into SQL.
|
|
165
|
+
|
|
166
|
+
**Before:** The application fetches entire tables and aggregates in code with loops or `.reduce()`.
|
|
167
|
+
|
|
168
|
+
**After:**
|
|
169
|
+
|
|
170
|
+
```sql
|
|
171
|
+
SELECT p.category_id,
|
|
172
|
+
AVG(r.rating) AS avg_rating,
|
|
173
|
+
COUNT(r.id) AS review_count
|
|
174
|
+
FROM reviews r
|
|
175
|
+
INNER JOIN products p ON r.product_id = p.id
|
|
176
|
+
GROUP BY p.category_id;
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### JOIN duplication
|
|
180
|
+
|
|
181
|
+
**Problem:** A JOIN between a wide parent table and a child table duplicates all parent columns across every child row. If a product has 200 reviews and the product row includes a 50KB JSONB column, the join sends that 50KB x 200 = ~10MB for a single request.
|
|
182
|
+
|
|
183
|
+
This is distinct from the SELECT \* problem. Even if you select only needed columns, a JOIN still repeats the parent data for every child row. The fix is structural: avoid the join entirely.
|
|
184
|
+
|
|
185
|
+
**Before:**
|
|
186
|
+
|
|
187
|
+
```sql
|
|
188
|
+
SELECT * FROM products
|
|
189
|
+
LEFT JOIN reviews ON reviews.product_id = products.id
|
|
190
|
+
WHERE products.id = 1;
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**After (two separate queries):**
|
|
194
|
+
|
|
195
|
+
```sql
|
|
196
|
+
SELECT id, name, price, description, image_urls FROM products WHERE id = 1;
|
|
197
|
+
SELECT id, user_name, rating, body FROM reviews WHERE product_id = 1;
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Two queries instead of one JOIN. The product data is fetched once. The reviews are fetched once. No duplication.
|
|
201
|
+
|
|
202
|
+
## Step 4: Verify
|
|
203
|
+
|
|
204
|
+
After applying fixes:
|
|
205
|
+
|
|
206
|
+
1. **Run existing tests** to confirm nothing broke.
|
|
207
|
+
2. **Check the responses** — make sure the API still returns the same data shape. Column selection and pagination changes can break clients that depend on specific fields or full result sets.
|
|
208
|
+
3. **Measure the improvement** — if pg_stat_statements data is available, reset it (`SELECT pg_stat_statements_reset();`), let traffic run, then re-run the diagnostic queries to compare before and after.
|
|
209
|
+
|
|
210
|
+
## Further reading
|
|
211
|
+
|
|
212
|
+
- https://neon.com/docs/introduction/network-transfer.md
|
|
213
|
+
- https://neon.com/docs/introduction/cost-optimization.md
|