@synapta/skills 0.1.0 → 0.1.2
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/dist/index.js +11 -4
- package/package.json +3 -4
- package/skills/ATTRIBUTION.md +80 -0
- package/skills/accessibility-audit/SKILL.md +325 -0
- package/skills/accessibility-audit/reference/wcag-checklist.md +103 -0
- package/skills/apns-notifier/SKILL.md +86 -0
- package/skills/approval-policy-enforcer/SKILL.md +66 -0
- package/skills/apps-sdk-builder/LICENSE.txt +201 -0
- package/skills/apps-sdk-builder/SKILL.md +328 -0
- package/skills/apps-sdk-builder/agents/openai.yaml +13 -0
- package/skills/apps-sdk-builder/references/app-archetypes.md +132 -0
- package/skills/apps-sdk-builder/references/apps-sdk-docs-workflow.md +135 -0
- package/skills/apps-sdk-builder/references/interactive-state-sync-patterns.md +113 -0
- package/skills/apps-sdk-builder/references/repo-contract-and-validation.md +93 -0
- package/skills/apps-sdk-builder/references/search-fetch-standard.md +67 -0
- package/skills/apps-sdk-builder/references/upstream-example-workflow.md +79 -0
- package/skills/apps-sdk-builder/references/window-openai-patterns.md +79 -0
- package/skills/apps-sdk-builder/scripts/scaffold_node_ext_apps.mjs +606 -0
- package/skills/architecture-selector/SKILL.md +64 -0
- package/skills/backlog-planner/SKILL.md +68 -0
- package/skills/carplay-entitlement-checker/SKILL.md +82 -0
- package/skills/concept-discovery/SKILL.md +517 -0
- package/skills/concept-discovery/assets/sample-analysis.json +81 -0
- package/skills/concept-discovery/expected_outputs/sample-enum-dictionary.md +25 -0
- package/skills/concept-discovery/expected_outputs/sample-page-user-list.md +83 -0
- package/skills/concept-discovery/expected_outputs/sample-prd-readme.md +43 -0
- package/skills/concept-discovery/references/framework-patterns.md +228 -0
- package/skills/concept-discovery/references/prd-quality-checklist.md +65 -0
- package/skills/concept-discovery/scripts/codebase_analyzer.py +732 -0
- package/skills/concept-discovery/scripts/prd_scaffolder.py +435 -0
- package/skills/dast-zap/SKILL.md +453 -0
- package/skills/dast-zap/assets/.gitkeep +9 -0
- package/skills/dast-zap/assets/github_action.yml +207 -0
- package/skills/dast-zap/assets/gitlab_ci.yml +226 -0
- package/skills/dast-zap/assets/zap_automation.yaml +196 -0
- package/skills/dast-zap/assets/zap_context.xml +192 -0
- package/skills/dast-zap/references/EXAMPLE.md +40 -0
- package/skills/dast-zap/references/api_testing_guide.md +475 -0
- package/skills/dast-zap/references/authentication_guide.md +431 -0
- package/skills/dast-zap/references/false_positive_handling.md +427 -0
- package/skills/dast-zap/references/owasp_mapping.md +255 -0
- package/skills/dep-sbom-scan/SKILL.md +466 -0
- package/skills/deploy-cloudflare/SKILL.md +930 -0
- package/skills/deploy-docker/SKILL.md +55 -0
- package/skills/deploy-fly/SKILL.md +228 -0
- package/skills/deploy-k8s/SKILL.md +108 -0
- package/skills/deploy-k8s/assets/logo.png +0 -0
- package/skills/deploy-k8s/docs/README.md +29 -0
- package/skills/deploy-k8s/docs/SUMMARY.md +56 -0
- package/skills/deploy-k8s/docs/advanced/token-efficiency.md +61 -0
- package/skills/deploy-k8s/docs/architecture/multi-tenancy.md +96 -0
- package/skills/deploy-k8s/docs/architecture/storage-and-state.md +102 -0
- package/skills/deploy-k8s/docs/architecture/workload-patterns.md +87 -0
- package/skills/deploy-k8s/docs/book.json +16 -0
- package/skills/deploy-k8s/docs/community/changelog.md +34 -0
- package/skills/deploy-k8s/docs/community/contributing.md +67 -0
- package/skills/deploy-k8s/docs/core-concepts/failure-modes.md +153 -0
- package/skills/deploy-k8s/docs/core-concepts/philosophy.md +83 -0
- package/skills/deploy-k8s/docs/core-concepts/workflow.md +124 -0
- package/skills/deploy-k8s/docs/examples/bad-patterns.md +47 -0
- package/skills/deploy-k8s/docs/examples/do-dont-checklist.md +37 -0
- package/skills/deploy-k8s/docs/examples/good-patterns.md +49 -0
- package/skills/deploy-k8s/docs/failure-modes/api-drift.md +104 -0
- package/skills/deploy-k8s/docs/failure-modes/fragile-rollouts.md +99 -0
- package/skills/deploy-k8s/docs/failure-modes/insecure-workload-defaults.md +80 -0
- package/skills/deploy-k8s/docs/failure-modes/network-exposure.md +98 -0
- package/skills/deploy-k8s/docs/failure-modes/privilege-sprawl.md +91 -0
- package/skills/deploy-k8s/docs/failure-modes/resource-starvation.md +85 -0
- package/skills/deploy-k8s/docs/getting-started/installation.md +152 -0
- package/skills/deploy-k8s/docs/getting-started/quick-start.md +115 -0
- package/skills/deploy-k8s/docs/guides/helm-patterns.md +71 -0
- package/skills/deploy-k8s/docs/guides/kustomize-patterns.md +65 -0
- package/skills/deploy-k8s/docs/guides/observability.md +67 -0
- package/skills/deploy-k8s/docs/guides/security-hardening.md +59 -0
- package/skills/deploy-k8s/docs/guides/validation-and-policy.md +66 -0
- package/skills/deploy-k8s/docs/integrations/mcp-integration.md +52 -0
- package/skills/deploy-k8s/docs/package-lock.json +2892 -0
- package/skills/deploy-k8s/docs/package.json +13 -0
- package/skills/deploy-k8s/references/api-drift.md +298 -0
- package/skills/deploy-k8s/references/conditional/aks-patterns.md +70 -0
- package/skills/deploy-k8s/references/conditional/eks-patterns.md +79 -0
- package/skills/deploy-k8s/references/conditional/gitops-controllers.md +71 -0
- package/skills/deploy-k8s/references/conditional/gke-patterns.md +74 -0
- package/skills/deploy-k8s/references/conditional/observability-stacks.md +80 -0
- package/skills/deploy-k8s/references/conditional/openshift-patterns.md +67 -0
- package/skills/deploy-k8s/references/daemonset-operator-patterns.md +155 -0
- package/skills/deploy-k8s/references/deployment-patterns.md +146 -0
- package/skills/deploy-k8s/references/do-dont-patterns.md +87 -0
- package/skills/deploy-k8s/references/examples-bad.md +282 -0
- package/skills/deploy-k8s/references/examples-good.md +440 -0
- package/skills/deploy-k8s/references/fragile-rollouts.md +303 -0
- package/skills/deploy-k8s/references/helm-patterns.md +203 -0
- package/skills/deploy-k8s/references/insecure-workload-defaults.md +300 -0
- package/skills/deploy-k8s/references/job-patterns.md +120 -0
- package/skills/deploy-k8s/references/kustomize-patterns.md +239 -0
- package/skills/deploy-k8s/references/multi-tenancy.md +343 -0
- package/skills/deploy-k8s/references/network-exposure.md +481 -0
- package/skills/deploy-k8s/references/observability.md +302 -0
- package/skills/deploy-k8s/references/privilege-sprawl.md +273 -0
- package/skills/deploy-k8s/references/resource-starvation.md +374 -0
- package/skills/deploy-k8s/references/security-hardening.md +209 -0
- package/skills/deploy-k8s/references/stateful-patterns.md +130 -0
- package/skills/deploy-k8s/references/storage-and-state.md +330 -0
- package/skills/deploy-k8s/references/validation-and-policy.md +242 -0
- package/skills/deploy-railway/SKILL.md +235 -0
- package/skills/deploy-railway/references/analyze-db-mongo.md +84 -0
- package/skills/deploy-railway/references/analyze-db-mysql.md +254 -0
- package/skills/deploy-railway/references/analyze-db-postgres.md +479 -0
- package/skills/deploy-railway/references/analyze-db-redis.md +208 -0
- package/skills/deploy-railway/references/analyze-db.md +344 -0
- package/skills/deploy-railway/references/configure.md +309 -0
- package/skills/deploy-railway/references/deploy.md +195 -0
- package/skills/deploy-railway/references/operate.md +214 -0
- package/skills/deploy-railway/references/request.md +248 -0
- package/skills/deploy-railway/references/setup.md +312 -0
- package/skills/deploy-railway/scripts/analyze-mongo.py +1549 -0
- package/skills/deploy-railway/scripts/analyze-mysql.py +1195 -0
- package/skills/deploy-railway/scripts/analyze-postgres.py +3058 -0
- package/skills/deploy-railway/scripts/analyze-redis.py +1090 -0
- package/skills/deploy-railway/scripts/dal.py +671 -0
- package/skills/deploy-railway/scripts/enable-pg-stats.py +170 -0
- package/skills/deploy-railway/scripts/pg-extensions.py +370 -0
- package/skills/deploy-railway/scripts/railway-api.sh +52 -0
- package/skills/deploy-ssh/SKILL.md +91 -0
- package/skills/deploy-vercel/SKILL.md +304 -0
- package/skills/deploy-vercel/resources/deploy-codex.sh +301 -0
- package/skills/deploy-vercel/resources/deploy.sh +301 -0
- package/skills/docs-runbooks/SKILL.md +399 -0
- package/skills/drive-status-renderer/SKILL.md +62 -0
- package/skills/iac-scan/SKILL.md +680 -0
- package/skills/iac-scan/assets/.gitkeep +9 -0
- package/skills/iac-scan/assets/checkov_config.yaml +94 -0
- package/skills/iac-scan/assets/github_actions.yml +199 -0
- package/skills/iac-scan/assets/gitlab_ci.yml +218 -0
- package/skills/iac-scan/assets/pre_commit_config.yaml +92 -0
- package/skills/iac-scan/references/EXAMPLE.md +40 -0
- package/skills/iac-scan/references/compliance_mapping.md +237 -0
- package/skills/iac-scan/references/custom_policies.md +460 -0
- package/skills/iac-scan/references/suppression_guide.md +431 -0
- package/skills/incident-briefing/SKILL.md +66 -0
- package/skills/incident-triage/SKILL.md +481 -0
- package/{LICENSE → skills/mcp-builder/LICENSE.txt} +15 -14
- package/skills/mcp-builder/SKILL.md +244 -0
- package/skills/mcp-builder/reference/evaluation.md +602 -0
- package/skills/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/skills/mcp-builder/reference/node_mcp_server.md +970 -0
- package/skills/mcp-builder/reference/python_mcp_server.md +719 -0
- package/skills/mcp-builder/scripts/connections.py +151 -0
- package/skills/mcp-builder/scripts/evaluation.py +373 -0
- package/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/skills/mcp-builder/scripts/requirements.txt +2 -0
- package/skills/mobile-pairing/SKILL.md +52 -0
- package/skills/ops-sre/SKILL.md +297 -0
- package/skills/playwright-qa/LICENSE.txt +201 -0
- package/skills/playwright-qa/NOTICE.txt +14 -0
- package/skills/playwright-qa/SKILL.md +156 -0
- package/skills/playwright-qa/agents/openai.yaml +6 -0
- package/skills/playwright-qa/assets/playwright-small.svg +3 -0
- package/skills/playwright-qa/assets/playwright.png +0 -0
- package/skills/playwright-qa/references/cli.md +116 -0
- package/skills/playwright-qa/references/workflows.md +95 -0
- package/skills/playwright-qa/scripts/playwright_cli.sh +25 -0
- package/skills/release-publish/SKILL.md +85 -0
- package/skills/repo-bootstrap/SKILL.md +92 -0
- package/skills/repo-bootstrap/assets/example-workflows/validate-agents.yml +89 -0
- package/skills/repo-bootstrap/assets/root-thin.md +141 -0
- package/skills/repo-bootstrap/assets/root-verbose.md +149 -0
- package/skills/repo-bootstrap/assets/scoped/backend-go.md +107 -0
- package/skills/repo-bootstrap/assets/scoped/backend-php.md +94 -0
- package/skills/repo-bootstrap/assets/scoped/backend-python.md +84 -0
- package/skills/repo-bootstrap/assets/scoped/backend-typescript.md +89 -0
- package/skills/repo-bootstrap/assets/scoped/claude-code-skill.md +101 -0
- package/skills/repo-bootstrap/assets/scoped/cli.md +83 -0
- package/skills/repo-bootstrap/assets/scoped/concourse.md +196 -0
- package/skills/repo-bootstrap/assets/scoped/ddev.md +68 -0
- package/skills/repo-bootstrap/assets/scoped/docker.md +160 -0
- package/skills/repo-bootstrap/assets/scoped/documentation.md +98 -0
- package/skills/repo-bootstrap/assets/scoped/examples.md +96 -0
- package/skills/repo-bootstrap/assets/scoped/frontend-typescript.md +88 -0
- package/skills/repo-bootstrap/assets/scoped/github-actions.md +174 -0
- package/skills/repo-bootstrap/assets/scoped/gitlab-ci.md +174 -0
- package/skills/repo-bootstrap/assets/scoped/oro-bundle.md +209 -0
- package/skills/repo-bootstrap/assets/scoped/oro-project.md +170 -0
- package/skills/repo-bootstrap/assets/scoped/python-modern.md +170 -0
- package/skills/repo-bootstrap/assets/scoped/resources.md +96 -0
- package/skills/repo-bootstrap/assets/scoped/skill-repo.md +139 -0
- package/skills/repo-bootstrap/assets/scoped/symfony.md +168 -0
- package/skills/repo-bootstrap/assets/scoped/testing.md +87 -0
- package/skills/repo-bootstrap/assets/scoped/typo3-docs.md +103 -0
- package/skills/repo-bootstrap/assets/scoped/typo3-extension.md +133 -0
- package/skills/repo-bootstrap/assets/scoped/typo3-project.md +137 -0
- package/skills/repo-bootstrap/assets/scoped/typo3-testing.md +80 -0
- package/skills/repo-bootstrap/checkpoints.yaml +279 -0
- package/skills/repo-bootstrap/evals/evals.json +385 -0
- package/skills/repo-bootstrap/references/ai-contribution-guidelines.md +63 -0
- package/skills/repo-bootstrap/references/ai-tool-compatibility.md +223 -0
- package/skills/repo-bootstrap/references/directory-coverage.md +82 -0
- package/skills/repo-bootstrap/references/examples/coding-agent-cli/AGENTS.md +70 -0
- package/skills/repo-bootstrap/references/examples/coding-agent-cli/go.mod +3 -0
- package/skills/repo-bootstrap/references/examples/coding-agent-cli/scripts-AGENTS.md +389 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/.env.example +13 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/AGENTS.md +91 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/package.json +33 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/pnpm-lock.yaml +3 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/src/AGENTS.md +91 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/src/config.ts +28 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/src/controllers/userController.ts +74 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/src/index.ts +26 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/src/middleware/errorHandler.ts +45 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/src/middleware/requestLogger.ts +18 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/src/routes/health.ts +18 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/src/routes/users.ts +13 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/src/utils/errors.ts +40 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/src/utils/logger.ts +14 -0
- package/skills/repo-bootstrap/references/examples/express-api-ts/tsconfig.json +24 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/.env.example +19 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/AGENTS.md +92 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/pyproject.toml +88 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/AGENTS.md +85 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/__init__.py +3 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/config.py +49 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/main.py +66 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/models/__init__.py +13 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/models/item.py +43 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/models/user.py +40 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/routes/__init__.py +5 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/routes/health.py +20 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/routes/items.py +61 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/routes/users.py +55 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/services/__init__.py +6 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/services/item_service.py +77 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/src/services/user_service.py +69 -0
- package/skills/repo-bootstrap/references/examples/fastapi-app/uv.lock +4 -0
- package/skills/repo-bootstrap/references/examples/go-api-with-react-admin/.scopes +3 -0
- package/skills/repo-bootstrap/references/examples/go-api-with-react-admin/AGENTS.md +86 -0
- package/skills/repo-bootstrap/references/examples/go-api-with-react-admin/admin/package.json +20 -0
- package/skills/repo-bootstrap/references/examples/go-api-with-react-admin/admin/src/App.tsx +5 -0
- package/skills/repo-bootstrap/references/examples/go-api-with-react-admin/cmd/api/main.go +7 -0
- package/skills/repo-bootstrap/references/examples/go-api-with-react-admin/go.mod +2 -0
- package/skills/repo-bootstrap/references/examples/go-api-with-react-admin/main.go +7 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/.scopes +3 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/AGENTS.md +89 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/go.mod +2 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/internal/web/AGENTS.md +90 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/internal/web/package.json +17 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/internal/web/src/App.tsx +1 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/internal/web/src/Button.tsx +1 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/internal/web/src/Footer.tsx +1 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/internal/web/src/Header.tsx +1 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/internal/web/src/Sidebar.tsx +1 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/main.go +7 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/package-lock.json +0 -0
- package/skills/repo-bootstrap/references/examples/go-with-internal-web-tsx/package.json +12 -0
- package/skills/repo-bootstrap/references/examples/ldap-selfservice/AGENTS.md +70 -0
- package/skills/repo-bootstrap/references/examples/ldap-selfservice/go.mod +3 -0
- package/skills/repo-bootstrap/references/examples/ldap-selfservice/internal-AGENTS.md +371 -0
- package/skills/repo-bootstrap/references/examples/ldap-selfservice/internal-web-AGENTS.md +448 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/.scopes +3 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/AGENTS.md +91 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/composer.json +8 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/package.json +15 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/pnpm-lock.yaml +0 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/src/Controller.php +3 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/web/AGENTS.md +92 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/web/package.json +26 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/web/src/App.tsx +3 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/web/src/Button.tsx +10 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/web/src/Footer.tsx +9 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/web/src/Header.tsx +9 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/web/src/main.tsx +3 -0
- package/skills/repo-bootstrap/references/examples/php-with-frontend/web/tsconfig.json +13 -0
- package/skills/repo-bootstrap/references/examples/pnpm-workspace/AGENTS.md +75 -0
- package/skills/repo-bootstrap/references/examples/pnpm-workspace/package.json +7 -0
- package/skills/repo-bootstrap/references/examples/pnpm-workspace/packages/web/package.json +11 -0
- package/skills/repo-bootstrap/references/examples/pnpm-workspace/packages/web/src/index.ts +11 -0
- package/skills/repo-bootstrap/references/examples/pnpm-workspace/pnpm-lock.yaml +42 -0
- package/skills/repo-bootstrap/references/examples/pnpm-workspace/pnpm-workspace.yaml +2 -0
- package/skills/repo-bootstrap/references/examples/simple-ldap-go/AGENTS.md +70 -0
- package/skills/repo-bootstrap/references/examples/simple-ldap-go/examples-AGENTS.md +45 -0
- package/skills/repo-bootstrap/references/examples/simple-ldap-go/go.mod +3 -0
- package/skills/repo-bootstrap/references/examples/t3x-rte-ckeditor-image/AGENTS.md +70 -0
- package/skills/repo-bootstrap/references/examples/t3x-rte-ckeditor-image/Classes-AGENTS.md +392 -0
- package/skills/repo-bootstrap/references/examples/t3x-rte-ckeditor-image/composer.json +8 -0
- package/skills/repo-bootstrap/references/feedback-memory-schema.md +135 -0
- package/skills/repo-bootstrap/references/git-hooks-setup.md +79 -0
- package/skills/repo-bootstrap/references/output-structure.md +124 -0
- package/skills/repo-bootstrap/references/scripts-guide.md +175 -0
- package/skills/repo-bootstrap/references/verification-guide.md +137 -0
- package/skills/repo-bootstrap/scripts/analyze-git-history.sh +315 -0
- package/skills/repo-bootstrap/scripts/check-freshness.sh +230 -0
- package/skills/repo-bootstrap/scripts/detect-golden-samples.sh +161 -0
- package/skills/repo-bootstrap/scripts/detect-heuristics.sh +93 -0
- package/skills/repo-bootstrap/scripts/detect-project.sh +486 -0
- package/skills/repo-bootstrap/scripts/detect-scopes.sh +330 -0
- package/skills/repo-bootstrap/scripts/detect-utilities.sh +133 -0
- package/skills/repo-bootstrap/scripts/extract-adrs.sh +194 -0
- package/skills/repo-bootstrap/scripts/extract-agent-configs.sh +331 -0
- package/skills/repo-bootstrap/scripts/extract-architecture-rules.sh +522 -0
- package/skills/repo-bootstrap/scripts/extract-ci-commands.sh +385 -0
- package/skills/repo-bootstrap/scripts/extract-ci-rules.sh +384 -0
- package/skills/repo-bootstrap/scripts/extract-commands.sh +358 -0
- package/skills/repo-bootstrap/scripts/extract-documentation.sh +308 -0
- package/skills/repo-bootstrap/scripts/extract-github-rulesets.sh +96 -0
- package/skills/repo-bootstrap/scripts/extract-github-settings.sh +88 -0
- package/skills/repo-bootstrap/scripts/extract-ide-settings.sh +228 -0
- package/skills/repo-bootstrap/scripts/extract-platform-files.sh +290 -0
- package/skills/repo-bootstrap/scripts/extract-quality-configs.sh +442 -0
- package/skills/repo-bootstrap/scripts/generate-agents.sh +2424 -0
- package/skills/repo-bootstrap/scripts/generate-file-map.sh +153 -0
- package/skills/repo-bootstrap/scripts/lib/config-root.sh +211 -0
- package/skills/repo-bootstrap/scripts/lib/summary.sh +244 -0
- package/skills/repo-bootstrap/scripts/lib/template.sh +397 -0
- package/skills/repo-bootstrap/scripts/validate-structure.sh +324 -0
- package/skills/repo-bootstrap/scripts/verify-commands.sh +615 -0
- package/skills/repo-bootstrap/scripts/verify-content.sh +302 -0
- package/skills/schema-api-contracts/SKILL.md +56 -0
- package/skills/secret-hygiene/SKILL.md +511 -0
- package/skills/secret-hygiene/assets/.gitkeep +9 -0
- package/skills/secret-hygiene/assets/config-balanced.toml +81 -0
- package/skills/secret-hygiene/assets/config-custom.toml +178 -0
- package/skills/secret-hygiene/assets/config-strict.toml +48 -0
- package/skills/secret-hygiene/assets/github-action.yml +181 -0
- package/skills/secret-hygiene/assets/gitlab-ci.yml +257 -0
- package/skills/secret-hygiene/assets/precommit-config.yaml +70 -0
- package/skills/secret-hygiene/references/EXAMPLE.md +40 -0
- package/skills/secret-hygiene/references/compliance_mapping.md +538 -0
- package/skills/secret-hygiene/references/detection_rules.md +276 -0
- package/skills/secret-hygiene/references/false_positives.md +598 -0
- package/skills/secret-hygiene/references/remediation_guide.md +530 -0
- package/skills/stack-selector/SKILL.md +56 -0
- package/skills/telegram-control/SKILL.md +110 -0
- package/skills/telegram-control/references/architecture.md +184 -0
- package/skills/telegram-control/references/convex.md +173 -0
- package/skills/telegram-control/references/error_handling.md +212 -0
- package/skills/telegram-control/references/initial_setup.md +165 -0
- package/skills/telegram-control/references/telegram_api.md +156 -0
- package/skills/telegram-control/scripts/cancel_message.ts +53 -0
- package/skills/telegram-control/scripts/list_scheduled.ts +103 -0
- package/skills/telegram-control/scripts/logger.ts +121 -0
- package/skills/telegram-control/scripts/proxy-util.ts +11 -0
- package/skills/telegram-control/scripts/schedule_message.ts +216 -0
- package/skills/telegram-control/scripts/send_message.ts +115 -0
- package/skills/telegram-control/scripts/setup.ts +185 -0
- package/skills/telegram-control/scripts/types.ts +75 -0
- package/skills/telegram-control/scripts/view_history.ts +74 -0
- package/skills/test-strategy/SKILL.md +352 -0
- package/skills/threat-model/SKILL.md +303 -0
- package/skills/threat-model/examples/example-output.md +196 -0
- package/skills/threat-model/template.md +96 -0
- package/skills/ts-lint/SKILL.md +80 -0
- package/skills/ui-flow/SKILL.md +668 -0
- package/skills/voice-command-router/SKILL.md +51 -0
- package/skills/widget-live-activity-sync/SKILL.md +66 -0
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
# PostgreSQL Analysis
|
|
2
|
+
|
|
3
|
+
This reference covers PostgreSQL-specific metrics, tuning, and analysis guidance.
|
|
4
|
+
For common analysis patterns (output structure, collection status handling, performance thinking), see [analyze-db.md](analyze-db.md).
|
|
5
|
+
|
|
6
|
+
## What the Script Collects
|
|
7
|
+
|
|
8
|
+
**`collection_status`** — check this FIRST. Shows what succeeded vs failed:
|
|
9
|
+
- `database_query`: SSH → psql batched query (connections, cache, vacuum, queries, etc.)
|
|
10
|
+
- `metrics_api`: Railway API for disk, CPU, memory
|
|
11
|
+
- `logs_api`: Railway API for recent log lines
|
|
12
|
+
- `ha_cluster`: SSH → Patroni REST API (HA services only)
|
|
13
|
+
|
|
14
|
+
Each entry has `"status"` (`"success"`, `"error"`, or `"skipped"`) and optional `"error"` or `"reason"` fields.
|
|
15
|
+
|
|
16
|
+
All in ONE operation (no additional queries needed):
|
|
17
|
+
|
|
18
|
+
**Connections:**
|
|
19
|
+
- Current/max/available counts
|
|
20
|
+
- States (active, idle, idle_in_transaction)
|
|
21
|
+
- By application name
|
|
22
|
+
- By age (buckets: <1min, 1-5min, 5-60min, 1-24hr, >24hr)
|
|
23
|
+
- Oldest connection age
|
|
24
|
+
|
|
25
|
+
**Memory & Configuration:**
|
|
26
|
+
- shared_buffers, effective_cache_size, work_mem, maintenance_work_mem
|
|
27
|
+
- WAL settings, parallelism settings, planner settings
|
|
28
|
+
- Autovacuum status
|
|
29
|
+
- track_activity_query_size (tells you if queries are truncated in pg_stat_statements)
|
|
30
|
+
- log_min_duration_statement (tells you if slow query logging is enabled and at what threshold)
|
|
31
|
+
- idle_in_transaction_session_timeout, statement_timeout (safety timeouts)
|
|
32
|
+
- track_io_timing (needed for blk_read_time/blk_write_time in query stats)
|
|
33
|
+
|
|
34
|
+
**Cache Performance:**
|
|
35
|
+
- Overall table/index hit ratios
|
|
36
|
+
- Per-table: hit %, disk reads, size (this is key for diagnosis)
|
|
37
|
+
|
|
38
|
+
**Storage:**
|
|
39
|
+
- Database size, WAL size
|
|
40
|
+
- Per-table: total size, data size, index size, row count
|
|
41
|
+
|
|
42
|
+
**Vacuum Health:**
|
|
43
|
+
- Per-table: dead rows, dead %, vacuum count, last vacuum/analyze, XID age
|
|
44
|
+
- Flags: needs_vacuum, needs_freeze
|
|
45
|
+
|
|
46
|
+
**Indexes:**
|
|
47
|
+
- Unused indexes (0 scans) with sizes
|
|
48
|
+
- Invalid indexes (failed builds)
|
|
49
|
+
|
|
50
|
+
**Query Performance (if pg_stat_statements enabled):**
|
|
51
|
+
- Top 100 queries by total execution time
|
|
52
|
+
- Per-query execution: calls, total_min, mean_ms, min_ms, max_ms, stddev_ms
|
|
53
|
+
- Per-query rows: total rows, rows_per_call
|
|
54
|
+
- Per-query planning: total_plan_ms, mean_plan_ms
|
|
55
|
+
- Per-query cache: shared_blks_hit, shared_blks_read, shared_blks_dirtied, shared_blks_written, cache_hit_pct
|
|
56
|
+
- Per-query temp: temp_blks_read, temp_blks_written
|
|
57
|
+
- Per-query I/O timing: blk_read_time_ms, blk_write_time_ms (requires track_io_timing=on)
|
|
58
|
+
- Per-query WAL: wal_records, wal_bytes
|
|
59
|
+
- Per-query local blocks: local_blks_hit, local_blks_read (for temp tables)
|
|
60
|
+
- Temp file stats (cumulative since stats reset, NOT current disk usage)
|
|
61
|
+
|
|
62
|
+
**Logs & Active Issues:**
|
|
63
|
+
- `recent_logs`: Raw unfiltered logs (1000 lines) - parse these yourself, look for errors, warnings, patterns
|
|
64
|
+
- `recent_errors`: Filtered error-level logs (legacy, for quick reference)
|
|
65
|
+
- `long_running_queries`: Queries running >5s at time of collection
|
|
66
|
+
- `blocked_queries`: Queries waiting on locks
|
|
67
|
+
- `cluster_logs`: HA cluster events (Patroni)
|
|
68
|
+
|
|
69
|
+
**Important:** Always analyze the raw `recent_logs` array thoroughly. This is 1000 lines of unfiltered database output — treat it as a goldmine.
|
|
70
|
+
|
|
71
|
+
**Log analysis checklist — go through ALL of these:**
|
|
72
|
+
|
|
73
|
+
1. **Error/Fatal/Panic messages**: Count them, categorize them, quote the exact messages
|
|
74
|
+
- `ERROR: deadlock detected` → cross-reference with deadlock count in database_stats
|
|
75
|
+
- `FATAL: too many connections` → cross-reference with connection usage
|
|
76
|
+
- `ERROR: canceling statement due to statement timeout` → which queries are timing out?
|
|
77
|
+
- `FATAL: out of shared memory` → shared_buffers or lock table exhaustion
|
|
78
|
+
- `ERROR: could not extend file` → disk space issue
|
|
79
|
+
- `PANIC: ...` → database crash, investigate immediately
|
|
80
|
+
|
|
81
|
+
2. **Slow query log entries** (if `log_min_duration_statement` is set):
|
|
82
|
+
- Count how many slow queries appear
|
|
83
|
+
- Identify which tables/queries are mentioned most often
|
|
84
|
+
- Cross-reference with top_queries — the same patterns should appear in both
|
|
85
|
+
- Note the actual durations logged vs mean_ms from pg_stat_statements
|
|
86
|
+
|
|
87
|
+
3. **Autovacuum activity**:
|
|
88
|
+
- `LOG: automatic vacuum of table` → is autovacuum running? How often?
|
|
89
|
+
- `LOG: automatic analyze of table` → statistics being updated
|
|
90
|
+
- `WARNING: oldest xmin is far in the past` → XID wraparound risk
|
|
91
|
+
- Absence of autovacuum entries with high dead rows → autovacuum may be blocked or misconfigured
|
|
92
|
+
|
|
93
|
+
4. **Checkpoint activity**:
|
|
94
|
+
- `LOG: checkpoint starting` / `LOG: checkpoint complete` → how frequent?
|
|
95
|
+
- `checkpoint complete: wrote X buffers (Y%)` → high Y% means lots of dirty data
|
|
96
|
+
- Time between checkpoints — if < 5 minutes, write load is high
|
|
97
|
+
- `checkpoints are occurring too frequently` → increase max_wal_size
|
|
98
|
+
|
|
99
|
+
5. **Connection patterns**:
|
|
100
|
+
- `LOG: connection received` / `LOG: connection authorized` → connection rate
|
|
101
|
+
- `LOG: disconnection` → normal or unexpected? Check session duration
|
|
102
|
+
- `FATAL: remaining connection slots are reserved` → max_connections hit
|
|
103
|
+
- `FATAL: password authentication failed` → unauthorized access attempts
|
|
104
|
+
|
|
105
|
+
6. **Replication messages**:
|
|
106
|
+
- `LOG: started streaming WAL` → replica connected
|
|
107
|
+
- `ERROR: requested WAL segment has already been removed` → replica too far behind
|
|
108
|
+
- `FATAL: could not receive data from WAL stream` → replication broken
|
|
109
|
+
|
|
110
|
+
7. **Temporal patterns**:
|
|
111
|
+
- Are errors clustered in time? (burst vs steady)
|
|
112
|
+
- Do slow queries correlate with checkpoint times?
|
|
113
|
+
- Is there a pattern suggesting cron jobs or batch processing?
|
|
114
|
+
|
|
115
|
+
State what you found with specifics: "Analyzed 1000 log lines covering 2024-01-15 14:00 to 15:30. Found: 23 slow query warnings (all SELECT on UserSession table, 200-800ms), 4 autovacuum runs, 2 checkpoints (normal interval), 0 errors. The slow queries correlate with the UserSession table's 76% cache hit rate."
|
|
116
|
+
|
|
117
|
+
### Log Interpretation When Only Logs Are Available
|
|
118
|
+
|
|
119
|
+
When `collection_status.database_query` failed and you only have logs:
|
|
120
|
+
|
|
121
|
+
**Startup vs steady-state logs:**
|
|
122
|
+
- `LOG: database system is ready to accept connections` — normal startup, NOT evidence of a crash
|
|
123
|
+
- `LOG: started streaming WAL` — normal replication, NOT an error
|
|
124
|
+
- `LOG: checkpoint starting` / `LOG: checkpoint complete` — routine operation
|
|
125
|
+
- `FATAL: the database system is starting up` — transient during restarts, NOT a persistent problem
|
|
126
|
+
|
|
127
|
+
**What you CAN say from logs alone:**
|
|
128
|
+
- Whether errors or warnings are present and their frequency
|
|
129
|
+
- Whether the database recently restarted (and that this is normal during deploys)
|
|
130
|
+
- Whether there are connection refused errors (possible saturation or startup)
|
|
131
|
+
|
|
132
|
+
**What you CANNOT say from logs alone:**
|
|
133
|
+
- Whether the database is performing well or poorly
|
|
134
|
+
- Whether cache hit ratios are good
|
|
135
|
+
- Whether vacuum is behind
|
|
136
|
+
- Whether queries are slow
|
|
137
|
+
- Any tuning recommendations
|
|
138
|
+
|
|
139
|
+
If only logs are available, explicitly state: "No performance conclusions possible — database metrics were not collected."
|
|
140
|
+
|
|
141
|
+
**Active Issues:**
|
|
142
|
+
- Long-running queries (>5s)
|
|
143
|
+
- Idle in transaction (>30s)
|
|
144
|
+
- Blocked queries (waiting on locks)
|
|
145
|
+
- Lock contention details
|
|
146
|
+
|
|
147
|
+
**Infrastructure (7d + 24h)** — show both windows so trends can be compared:
|
|
148
|
+
|
|
149
|
+
**7-Day Trends**
|
|
150
|
+
| Metric | Current | Avg | Min | Max | Trend |
|
|
151
|
+
|--------|---------|-----|-----|-----|-------|
|
|
152
|
+
| CPU | 0.02 vCPU | 0.02 | 0.00 | 0.18 | stable |
|
|
153
|
+
| Memory | 320 MB | 290 MB | 240 MB | 380 MB | stable |
|
|
154
|
+
| Disk | 4.2 GB | 4.1 GB | 3.9 GB | 4.3 GB | increasing (+8%) |
|
|
155
|
+
|
|
156
|
+
**Last 24 Hours**
|
|
157
|
+
| Metric | Current | Avg | Min | Max | Trend |
|
|
158
|
+
|--------|---------|-----|-----|-----|-------|
|
|
159
|
+
| CPU | 0.04 vCPU | 0.02 | 0.00 | 0.18 | stable |
|
|
160
|
+
| Memory | 320 MB | 295 MB | 270 MB | 340 MB | stable |
|
|
161
|
+
| Disk | 4.2 GB | 4.15 GB | 4.1 GB | 4.2 GB | stable |
|
|
162
|
+
|
|
163
|
+
Compare: "Disk growing slowly over 7d but stable over 24h → gradual data growth, not an acute event."
|
|
164
|
+
|
|
165
|
+
Do NOT show cpu_limit/memory_limit columns or utilization %. Railway auto-scales — these limits are just the ceiling. See [analyze-db.md](analyze-db.md) autoscale rules.
|
|
166
|
+
|
|
167
|
+
**Replication / HA (if applicable):**
|
|
168
|
+
- Replication status
|
|
169
|
+
- HA cluster status (Patroni)
|
|
170
|
+
- Background writer stats
|
|
171
|
+
- WAL archiver status
|
|
172
|
+
|
|
173
|
+
## PostgreSQL Tuning Knowledge
|
|
174
|
+
|
|
175
|
+
Use this to reason about configuration issues:
|
|
176
|
+
|
|
177
|
+
### Memory Parameters
|
|
178
|
+
|
|
179
|
+
| Parameter | Default | Target | What It Does |
|
|
180
|
+
|-----------|---------|--------|--------------|
|
|
181
|
+
| `shared_buffers` | 128MB | 25% RAM | The database's main cache. Pages read from disk go here. Too small = constant disk I/O. |
|
|
182
|
+
| `effective_cache_size` | 4GB | 75% RAM | NOT memory allocation - a hint to the planner about OS cache. Too low = planner avoids indexes. |
|
|
183
|
+
| `work_mem` | 4MB | 16-64MB | Memory per sort/hash/join operation. Too low = temp files on disk. Caution: multiplied by concurrent operations. |
|
|
184
|
+
| `maintenance_work_mem` | 64MB | 256MB-1GB | Memory for VACUUM, CREATE INDEX. Higher = faster maintenance. |
|
|
185
|
+
|
|
186
|
+
### Tuning Formulas
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
shared_buffers = RAM × 0.25 (max 40%)
|
|
190
|
+
1GB RAM → 256MB
|
|
191
|
+
4GB RAM → 1GB
|
|
192
|
+
16GB RAM → 4GB
|
|
193
|
+
|
|
194
|
+
work_mem = (RAM / max_connections) / 4
|
|
195
|
+
4GB RAM, 100 conns → 10MB
|
|
196
|
+
8GB RAM, 200 conns → 10MB
|
|
197
|
+
|
|
198
|
+
effective_cache_size = RAM × 0.75
|
|
199
|
+
4GB RAM → 3GB
|
|
200
|
+
16GB RAM → 12GB
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Settings Requiring Restart vs Immediate
|
|
204
|
+
|
|
205
|
+
**Restart required:**
|
|
206
|
+
- shared_buffers
|
|
207
|
+
- max_connections
|
|
208
|
+
- max_parallel_workers
|
|
209
|
+
|
|
210
|
+
**Immediate (SIGHUP):**
|
|
211
|
+
- work_mem
|
|
212
|
+
- effective_cache_size
|
|
213
|
+
- random_page_cost
|
|
214
|
+
- checkpoint_completion_target
|
|
215
|
+
|
|
216
|
+
### SSD vs HDD
|
|
217
|
+
|
|
218
|
+
Railway uses SSDs. If `random_page_cost = 4.0` (HDD default), the planner thinks random reads are 4x more expensive than sequential - it avoids index scans. Set to 1.1-2.0 for SSDs.
|
|
219
|
+
|
|
220
|
+
### Railway auto-scales vertically
|
|
221
|
+
|
|
222
|
+
See [analyze-db.md](analyze-db.md) for full autoscale rules. For PostgreSQL specifically:
|
|
223
|
+
|
|
224
|
+
- Tune parameters relative to the **current** RAM from `metrics_history.memory.current`, not `memory_limit`.
|
|
225
|
+
- If shared_buffers is undersized relative to current RAM, recommend increasing it to 25% of current RAM.
|
|
226
|
+
- If the working set far exceeds what 25% of current RAM can hold, note this as a limitation of the current memory footprint — but do NOT tell the user to increase RAM. The platform handles that automatically.
|
|
227
|
+
|
|
228
|
+
## Thresholds for Reasoning
|
|
229
|
+
|
|
230
|
+
| Metric | Healthy | Warning | Critical |
|
|
231
|
+
|--------|---------|---------|----------|
|
|
232
|
+
| Cache hit ratio | >99% | 95-99% | <95% |
|
|
233
|
+
| Per-table cache hit | >95% | 80-95% | <80% with high reads |
|
|
234
|
+
| Connection usage | <70% | 70-90% | >90% |
|
|
235
|
+
| Disk usage | <70% | 70-85% | >85% |
|
|
236
|
+
| Dead rows % | <5% | 5-20% | >20% |
|
|
237
|
+
| XID age | <100M | 100-150M | >150M (emergency at 2B) |
|
|
238
|
+
|
|
239
|
+
### Vacuum Priority Matrix
|
|
240
|
+
|
|
241
|
+
Dead row percentage alone doesn't determine urgency. Use this matrix:
|
|
242
|
+
|
|
243
|
+
| Table Size | Dead Rows | Priority |
|
|
244
|
+
|------------|-----------|----------|
|
|
245
|
+
| > 100 MB | > 10,000 | High - real bloat affecting performance |
|
|
246
|
+
| > 50 MB | > 5,000 | Medium - worth addressing |
|
|
247
|
+
| < 10 MB | Any | Low - negligible impact, ignore |
|
|
248
|
+
| Any | < 1,000 | Low - autovacuum will handle it |
|
|
249
|
+
|
|
250
|
+
A 1 MB table with 25% dead rows has ~250 KB of bloat. Not worth mentioning as "critical".
|
|
251
|
+
|
|
252
|
+
## Applying Fixes
|
|
253
|
+
|
|
254
|
+
When recommending changes, include the actual SQL and **always explain side effects** — especially for settings that add overhead or change behavior.
|
|
255
|
+
|
|
256
|
+
```sql
|
|
257
|
+
-- Memory tuning (example for 4GB RAM)
|
|
258
|
+
ALTER SYSTEM SET shared_buffers = '1GB';
|
|
259
|
+
ALTER SYSTEM SET effective_cache_size = '3GB';
|
|
260
|
+
ALTER SYSTEM SET work_mem = '32MB';
|
|
261
|
+
ALTER SYSTEM SET random_page_cost = 1.5;
|
|
262
|
+
SELECT pg_reload_conf();
|
|
263
|
+
-- Note: shared_buffers requires restart
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
```sql
|
|
267
|
+
-- Vacuum specific tables
|
|
268
|
+
VACUUM ANALYZE "TableName";
|
|
269
|
+
|
|
270
|
+
-- Emergency XID freeze
|
|
271
|
+
VACUUM FREEZE "TableName";
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Side effects to document per setting
|
|
275
|
+
|
|
276
|
+
| Setting | Side Effect to Explain |
|
|
277
|
+
|---------|----------------------|
|
|
278
|
+
| `track_io_timing` | Adds a system call (gettimeofday) per block read/write. On most modern systems the overhead is <1%, but on systems with slow clock sources it can be measurable. Worth it for the diagnostic value in pg_stat_statements (blk_read_time, blk_write_time). |
|
|
279
|
+
| `shared_buffers` | Requires restart. Allocates memory at startup — over-allocating can starve OS cache and other processes. |
|
|
280
|
+
| `work_mem` | Multiplied by concurrent operations (sorts, hashes, joins). 64MB × 50 concurrent ops = 3.2 GB. Recommend conservatively. |
|
|
281
|
+
| `log_min_duration_statement` | Logging slow queries adds I/O. A threshold too low (e.g., 100ms) on a high-throughput DB can generate massive log volume. Start at 1000ms. |
|
|
282
|
+
| `idle_in_transaction_session_timeout` / `statement_timeout` | Will kill queries/transactions that exceed the timeout. Existing application code that relies on long-running transactions or queries will break. Warn the user to verify their application can handle this. |
|
|
283
|
+
|
|
284
|
+
## Enabling pg_stat_statements
|
|
285
|
+
|
|
286
|
+
**ONLY suggest this if BOTH conditions are true:**
|
|
287
|
+
1. `pg_stat_statements_installed` is `false` in the JSON output
|
|
288
|
+
2. `top_queries` is empty or missing
|
|
289
|
+
|
|
290
|
+
If these conditions are met, tell the user to run (do NOT execute with Bash):
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
python3 scripts/enable-pg-stats.py --service <name>
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
This may require a brief restart.
|
|
297
|
+
|
|
298
|
+
**If `pg_stat_statements_installed: true` and `top_queries` has data, DO NOT suggest enabling it.**
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## PostgreSQL-Specific Guidance
|
|
303
|
+
|
|
304
|
+
The sections below apply specifically to PostgreSQL analysis via `scripts/analyze-postgres.py`.
|
|
305
|
+
|
|
306
|
+
## How to Think About PostgreSQL Performance
|
|
307
|
+
|
|
308
|
+
### The Core Question
|
|
309
|
+
|
|
310
|
+
When you see a problem, ask: **What is the chain of causation?**
|
|
311
|
+
|
|
312
|
+
Example chain:
|
|
313
|
+
1. Cache hit is 89% (symptom)
|
|
314
|
+
2. Email table has 6% cache hit with 1.19B disk reads (deeper symptom)
|
|
315
|
+
3. Email table is 1.7GB, shared_buffers is 128MB (root cause)
|
|
316
|
+
4. The table is 13x larger than the buffer pool - it will NEVER fit in cache
|
|
317
|
+
5. Every query touching Email forces disk I/O
|
|
318
|
+
|
|
319
|
+
**This reasoning is what you provide. The script gives you the data points - you connect them.**
|
|
320
|
+
|
|
321
|
+
### Patterns to Look For
|
|
322
|
+
|
|
323
|
+
**Memory Starvation Pattern:**
|
|
324
|
+
- Low cache hit + large tables + small shared_buffers = working set doesn't fit
|
|
325
|
+
- High temp files + low work_mem = sorts/hashes spilling to disk
|
|
326
|
+
- These often occur together - both indicate the database needs more memory
|
|
327
|
+
|
|
328
|
+
**Important:** Temp file stats (`temp_files`, `temp_bytes`) are **cumulative since the last stats reset**, not current disk usage. When reporting, say "X GB written to temp files since stats reset" - not "X GB on disk right now".
|
|
329
|
+
|
|
330
|
+
**Vacuum Neglect Pattern:**
|
|
331
|
+
- High dead rows % + "never" vacuum timestamps = autovacuum isn't keeping up
|
|
332
|
+
- Multiple tables with >10% dead rows = systemic issue, not one-off
|
|
333
|
+
- High XID age + vacuum issues = potential wraparound emergency
|
|
334
|
+
|
|
335
|
+
**Important:** Consider **absolute impact**, not just percentage. A tiny table (< 10 MB) with 20% dead rows has negligible impact - vacuuming it reclaims almost nothing. Prioritize tables with BOTH high dead row counts (thousands+) AND meaningful size (tens of MB+). Don't mark small tables as "critical" just because of a high percentage.
|
|
336
|
+
|
|
337
|
+
**Missing Index Pattern:**
|
|
338
|
+
- High seq_scan count + 0 idx_scans on large tables = queries scanning full tables
|
|
339
|
+
- Low cache hit on specific tables + high seq_scans = indexes would help AND reduce I/O
|
|
340
|
+
|
|
341
|
+
**Connection Pressure Pattern:**
|
|
342
|
+
- High connection % + many idle connections = connection pooling needed
|
|
343
|
+
- Old connections (days) + idle_in_transaction = potential connection leaks or stuck transactions
|
|
344
|
+
|
|
345
|
+
### Slow Query Analysis — Go Deep
|
|
346
|
+
|
|
347
|
+
The `top_queries` array is the **most valuable data** for customers. This is where you can give the most actionable, specific advice. Don't skim it — analyze every query in the top 10-15 thoroughly.
|
|
348
|
+
|
|
349
|
+
#### Per-Query Fields and What Each Tells You
|
|
350
|
+
|
|
351
|
+
| Field | What It Means | How to Interpret |
|
|
352
|
+
|-------|---------------|------------------|
|
|
353
|
+
| `calls` | Number of times this query pattern executed | High calls × even small mean_ms = huge cumulative impact. A 5ms query called 10M times = 833 minutes of DB time |
|
|
354
|
+
| `total_min` | Total execution time in minutes | The primary sort key. This is the query's total footprint on the database |
|
|
355
|
+
| `mean_ms` | Average execution time per call | Compare with stddev — if stddev >> mean, the query has wildly variable performance |
|
|
356
|
+
| `min_ms` / `max_ms` | Fastest and slowest execution | A 2ms min with 30,000ms max means the query sometimes hits pathological cases (lock waits, cache misses, bloated tables) |
|
|
357
|
+
| `stddev_ms` | Standard deviation of execution time | High stddev = unpredictable. The query probably performs well when data is cached but terribly when it's not. This is often the query causing random user-visible latency spikes |
|
|
358
|
+
| `rows_per_call` | Average rows returned per execution | 0.01 rows/call means the query usually returns nothing — might be a polling pattern or existence check that could use EXISTS instead. 50,000 rows/call suggests missing pagination or bulk fetch |
|
|
359
|
+
| `mean_plan_ms` | Average planning time | If plan time is >5ms, the planner is spending significant time. Could indicate: too many partitions, complex joins needing better statistics (`ALTER TABLE SET STATISTICS`), or pg_catalog bloat |
|
|
360
|
+
| `cache_hit_pct` | % of blocks found in shared_buffers | <90% = query is constantly going to disk. Cross-reference with the table it touches in `cache_per_table` |
|
|
361
|
+
| `shared_blks_read` | Blocks read from disk (not cache) | This is the raw I/O cost. Each block = 8KB. 1M blocks read = 8GB of disk I/O |
|
|
362
|
+
| `shared_blks_dirtied` | Blocks this query modified | High dirtied blocks = write-heavy query. These blocks will need to be flushed to disk during checkpoints |
|
|
363
|
+
| `shared_blks_written` | Blocks this query had to flush to disk itself | Should be 0 in a healthy system. >0 means the query was forced to do its own I/O because shared_buffers was full of dirty pages — a sign of severe memory pressure |
|
|
364
|
+
| `temp_blks_read` / `temp_blks_written` | Blocks spilled to temp files | Any nonzero value means the query exceeded work_mem. Each block = 8KB. temp_blks_written of 1M = 8GB spilled to disk for sorts/hashes |
|
|
365
|
+
| `blk_read_time_ms` / `blk_write_time_ms` | Time spent on actual disk I/O (requires `track_io_timing`) | If available and high, this tells you exactly how much time was spent waiting on disk vs CPU. If 0, track_io_timing may be off |
|
|
366
|
+
| `wal_records` / `wal_bytes` | WAL generated by this query | High WAL = write-heavy. If one query generates most WAL, it's driving replication lag and checkpoint pressure |
|
|
367
|
+
| `local_blks_hit` / `local_blks_read` | Blocks for temporary tables | If nonzero, query uses temp tables — common in complex CTEs or materialized subqueries |
|
|
368
|
+
|
|
369
|
+
#### Red Flags — What Demands Explanation
|
|
370
|
+
|
|
371
|
+
| Signal | What It Means | Example | What to Tell the Customer |
|
|
372
|
+
|--------|---------------|---------|---------------------------|
|
|
373
|
+
| Low cache_hit_pct (< 90%) | Query hitting disk constantly | `cache_hit_pct: 47.19` | "This query reads X blocks from disk each call. The table it touches (Y) is Z GB but shared_buffers is only W MB — the data physically cannot stay cached" |
|
|
374
|
+
| High temp_blks (any nonzero) | Query spilling sorts/hashes to disk | `temp_blks_written: 39102928` | "This query spills ~X GB to temp files per execution because work_mem (Y MB) is too small for its sort/hash. Each spill means disk I/O instead of memory" |
|
|
375
|
+
| Huge rows_per_call (>1000) | Missing pagination or bulk fetch | `rows_per_call: 12177` | "Each call returns ~12K rows. If this is a user-facing query, it likely needs LIMIT/OFFSET or cursor-based pagination. If it's a batch job, it's expected" |
|
|
376
|
+
| Near-zero rows_per_call with high calls | Polling or existence check pattern | 0.01 rows/call, 500K calls | "This query runs 500K times but almost never finds data. If it's checking for new work, consider LISTEN/NOTIFY instead of polling. If it's an existence check, ensure it uses EXISTS with LIMIT 1" |
|
|
377
|
+
| stddev >> mean | Wildly variable performance | mean=15ms, stddev=2400ms, max=45000ms | "This query averages 15ms but sometimes takes 45 SECONDS. The high stddev means unpredictable latency. Likely causes: lock contention, cache misses on cold data, or table bloat causing variable scan times" |
|
|
378
|
+
| High mean_plan_ms (>5ms) | Expensive query planning | `mean_plan_ms: 23.4` | "The planner spends 23ms just deciding HOW to run this query, before executing it. With X calls, that's Y minutes of pure planning overhead. Consider: PREPARE'd statements, simpler joins, or increasing default_statistics_target for better stats" |
|
|
379
|
+
| shared_blks_written > 0 | Memory pressure forcing query I/O | `shared_blks_written: 50000` | "This query was forced to flush dirty pages to disk itself because shared_buffers was full. This is a sign of severe buffer pool pressure — increase shared_buffers" |
|
|
380
|
+
| High wal_bytes relative to others | Write-heavy query driving replication | `wal_bytes: 5000000000` | "This query generates X GB of WAL, which is Y% of total WAL. It's the primary driver of replication lag and checkpoint I/O" |
|
|
381
|
+
| max_ms >> 10× mean_ms | Pathological worst cases | mean=50ms, max=120000ms | "The worst execution was 2400× slower than average. Investigate: was it blocked by a lock? Did it hit a cold cache after restart? Is there table bloat causing some scans to be much longer?" |
|
|
382
|
+
|
|
383
|
+
#### How to Present Slow Queries
|
|
384
|
+
|
|
385
|
+
**Show the full table first** with all available metrics (the report already includes these columns):
|
|
386
|
+
|
|
387
|
+
```
|
|
388
|
+
| Query (truncated) | Calls | Total (min) | Mean (ms) | Min/Max (ms) | Stddev | Rows/Call | Cache Hit | Temp R/W | Plan (ms) | I/O Time |
|
|
389
|
+
|-------------------|-------|-------------|-----------|--------------|--------|-----------|-----------|----------|-----------|----------|
|
|
390
|
+
| SELECT Email.ccFull... | 78K | 132 | 101 | 0.3/8200 | 340 | 0.05 | 47% | 0/0 | 1.2 | 45000 |
|
|
391
|
+
| SELECT Thread... ORDER BY | 48K | 223 | 279 | 2.1/45000 | 2400 | 12,177 | 98.8% | 0/39M | 0.4 | 800 |
|
|
392
|
+
| SELECT Content... | 1.3K | 12 | 563 | 180/3200 | 420 | 0.65 | 1.8% | 0/0 | 8.3 | 31000 |
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**Then analyze EACH query** — this is the most valuable part. For each of the top 10 queries, explain:
|
|
396
|
+
|
|
397
|
+
1. **What the query does** — identify the tables, the pattern (lookup, join, aggregation, pagination)
|
|
398
|
+
2. **Why it's slow** — connect the specific metrics to a root cause
|
|
399
|
+
3. **The cascading impact** — how this query affects overall database health
|
|
400
|
+
4. **Specific fix** — not generic advice, but targeted to what the metrics show
|
|
401
|
+
|
|
402
|
+
Example deep analysis:
|
|
403
|
+
|
|
404
|
+
> **Query 1: Email.ccFull join** (78K calls, 101ms mean, 132 min total)
|
|
405
|
+
> - **Pattern**: Joins Email → EmailThreadKind → Thread → EmailEntry. ORM-generated N+1 or bulk join.
|
|
406
|
+
> - **Root cause**: 47% cache hit means 53% of blocks come from disk. The Email table is 1.7GB but shared_buffers is 128MB — only 7.5% of this table can be cached at once. Every call displaces other data from cache, creating a cascading eviction problem.
|
|
407
|
+
> - **The stddev of 340ms** with max of 8200ms means some calls take 80× longer — likely when the needed pages were just evicted by another query.
|
|
408
|
+
> - **I/O time of 45,000ms** total confirms this: the query has spent 45 seconds just waiting for disk across all calls.
|
|
409
|
+
> - **rows_per_call = 0.05** means it almost never finds a match — it's doing all this I/O for an existence-check pattern. An `EXISTS()` subquery with proper index could eliminate the full table scan.
|
|
410
|
+
> - **Fix**: (a) Increase shared_buffers to 1GB so the hot portion stays cached. (b) Add index on Email(ccFull, threadId) to avoid the sequential scan. (c) Rewrite as EXISTS if the app only needs presence, not the full row.
|
|
411
|
+
|
|
412
|
+
> **Query 2: Thread pagination** (48K calls, 279ms mean, 223 min total)
|
|
413
|
+
> - **Pattern**: SELECT Thread... ORDER BY with large result set. Pagination query.
|
|
414
|
+
> - **Root cause**: rows_per_call = 12,177 — returning 12K rows per call is a pagination bug (missing LIMIT) or an admin/batch endpoint.
|
|
415
|
+
> - **temp_blks_written = 39M** (312 GB of temp files!) — the ORDER BY creates a sort that exceeds work_mem (4MB), so it spills to disk every single time.
|
|
416
|
+
> - **stddev = 2400ms with max = 45,000ms** — some executions take 45 seconds, likely when disk temp files compete with other I/O.
|
|
417
|
+
> - **Cache hit is 98.8%** — the data itself is cached, but the sort still spills because work_mem is separate from shared_buffers.
|
|
418
|
+
> - **Fix**: (a) Add `LIMIT` if this is user-facing. (b) Create an index matching the ORDER BY clause to eliminate the sort entirely. (c) Increase work_mem to 32-64MB so the sort fits in memory.
|
|
419
|
+
|
|
420
|
+
#### Truncate Long Queries Intelligently
|
|
421
|
+
- Show the table names and key operations (JOIN, WHERE, ORDER BY)
|
|
422
|
+
- Don't dump 2000-character ORM-generated SQL
|
|
423
|
+
- Identify the pattern: "Thread zone assignment lookup" not the full SQL
|
|
424
|
+
- For ORM queries with `$1, $2, ...` parameters, note that the actual values aren't available — the pattern matters more than specific values
|
|
425
|
+
- **Note on query truncation**: pg_stat_statements stores full query text up to `track_activity_query_size` (default 1024 chars). ORM-generated queries often exceed this — if a query ends abruptly, it was truncated by PostgreSQL, not by our script. The JSON output preserves the full text from pg_stat_statements; only the human-readable text report truncates for display
|
|
426
|
+
|
|
427
|
+
#### Query Workload Profile
|
|
428
|
+
|
|
429
|
+
After analyzing individual queries, summarize the overall workload:
|
|
430
|
+
- **Read vs write ratio**: Use tup_returned/tup_fetched vs tup_inserted/tup_updated/tup_deleted from database_stats
|
|
431
|
+
- **Top 3 time consumers**: Which queries dominate total_min? If 3 queries account for 80% of execution time, that's where to focus
|
|
432
|
+
- **Cache pressure sources**: Which queries have the most shared_blks_read? They're driving cache misses for everything else
|
|
433
|
+
- **Temp file culprits**: Which specific queries create temp files? Don't say "increase work_mem" generically — say "Query X creates Y GB of temp files per day"
|
|
434
|
+
- **WAL generators**: If applicable, which queries generate the most WAL bytes? They're driving replication lag
|
|
435
|
+
|
|
436
|
+
### Correlate Across Sections
|
|
437
|
+
|
|
438
|
+
The script collects many data points. Look for correlations:
|
|
439
|
+
|
|
440
|
+
| If you see... | Check also... | Because... |
|
|
441
|
+
|---------------|---------------|------------|
|
|
442
|
+
| Low table cache hit | per-table cache rates, table sizes vs shared_buffers | One large table may be thrashing the cache |
|
|
443
|
+
| High temp files | work_mem value, top queries | Specific queries may be the culprits |
|
|
444
|
+
| Dead rows building up | vacuum health, XID age | Autovacuum may be blocked or misconfigured |
|
|
445
|
+
| Seq scans on large tables | unused indexes, index hit rates | May have indexes but planner isn't using them |
|
|
446
|
+
| High connection usage | connection age, idle_in_transaction | May be leaks, not actual load |
|
|
447
|
+
|
|
448
|
+
### Synthesize Insights the Script Can't
|
|
449
|
+
|
|
450
|
+
The script flags individual issues. You should:
|
|
451
|
+
|
|
452
|
+
1. **Identify the PRIMARY bottleneck** - What's the #1 thing hurting performance right now?
|
|
453
|
+
2. **Explain cascading effects** - How does one problem cause others?
|
|
454
|
+
3. **Prioritize fixes** - What should they do first, second, third?
|
|
455
|
+
4. **Warn about risks** - What happens if they don't fix this?
|
|
456
|
+
|
|
457
|
+
**Important:** Synthesis is prose that EXPLAINS the data tables you already showed. Don't hide data in prose - the tables make it visible, the prose connects the dots.
|
|
458
|
+
|
|
459
|
+
Example flow:
|
|
460
|
+
1. Show config table: `shared_buffers = 128 MB` vs recommended `1 GB`
|
|
461
|
+
2. Show cache table: `Email` table at 6% cache hit with 1.19B disk reads
|
|
462
|
+
3. THEN explain: "Your buffer pool (128 MB) is 13x smaller than your Email table (1.7 GB). This single table is dragging down your overall 89% cache hit rate."
|
|
463
|
+
|
|
464
|
+
The user sees the data, understands the relationship, then gets the explanation. Don't make them trust your conclusions without seeing the evidence first.
|
|
465
|
+
|
|
466
|
+
## Common Errors to Avoid (PostgreSQL-Specific)
|
|
467
|
+
|
|
468
|
+
- Saying "enable pg_stat_statements" when `pg_stat_statements_installed: true` and `top_queries` has data
|
|
469
|
+
- Misreporting connection usage (check `percent` field, not just `current`)
|
|
470
|
+
- Ignoring the `oldest_connections` details when flagging old connections
|
|
471
|
+
- Saying "746 GB of temp files on disk" when temp_bytes is cumulative since stats reset
|
|
472
|
+
- Marking tiny tables (< 10 MB) as "critical" for vacuum just because of high dead row percentage
|
|
473
|
+
- Listing slow queries by total_time only without analyzing cache_hit_pct, temp_blks, and rows returned
|
|
474
|
+
- Dumping full ORM-generated SQL instead of summarizing the query pattern
|
|
475
|
+
|
|
476
|
+
## Validated against
|
|
477
|
+
|
|
478
|
+
- PostgreSQL system views: pg_stat_activity, pg_stat_statements, pg_statio_user_tables, pg_stat_user_tables
|
|
479
|
+
- Patroni REST API for HA clusters
|