agileflow 4.0.0-alpha.2 → 4.0.0-alpha.21
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/CHANGELOG.md +51 -0
- package/content/plugins/accessibility/plugin.yaml +14 -0
- package/content/plugins/accessibility/skills/agileflow-accessibility/SKILL.md +392 -0
- package/content/plugins/accessibility/skills/agileflow-accessibility/references/aria-patterns.md +528 -0
- package/content/plugins/accessibility/skills/agileflow-accessibility/references/testing-checklist.md +457 -0
- package/content/plugins/accessibility/skills/agileflow-accessibility/references/wcag-guide.md +683 -0
- package/content/plugins/accessibility/skills/agileflow-accessibility/workflows/audit-page.md +310 -0
- package/content/plugins/accessibility/skills/agileflow-accessibility/workflows/implement-accessible-component.md +479 -0
- package/content/plugins/ads/agents/ads-audit-budget.md +185 -0
- package/content/plugins/ads/agents/ads-audit-compliance.md +171 -0
- package/content/plugins/ads/agents/ads-audit-creative.md +168 -0
- package/content/plugins/ads/agents/ads-audit-google.md +227 -0
- package/content/plugins/ads/agents/ads-audit-meta.md +184 -0
- package/content/plugins/ads/agents/ads-audit-tracking.md +205 -0
- package/content/plugins/ads/agents/ads-consensus.md +410 -0
- package/content/plugins/ads/agents/ads-generate.md +152 -0
- package/content/plugins/ads/agents/ads-performance-tracker.md +212 -0
- package/content/plugins/ads/plugin.yaml +23 -4
- package/content/plugins/ads/skills/agileflow-ads/SKILL.md +218 -0
- package/content/plugins/ads/skills/agileflow-ads/references/ad-copy-formula-guide.md +131 -0
- package/content/plugins/ads/skills/agileflow-ads/references/audience-targeting-guide.md +137 -0
- package/content/plugins/ads/skills/agileflow-ads/references/bid-strategy-guide.md +115 -0
- package/content/plugins/ads/skills/agileflow-ads/references/platform-benchmarks.md +100 -0
- package/content/plugins/ads/skills/agileflow-ads/workflows/audit.md +118 -0
- package/content/plugins/ads/skills/agileflow-ads/workflows/generate.md +84 -0
- package/content/plugins/audit/agents/a11y-analyzer-aria.md +173 -0
- package/content/plugins/audit/agents/a11y-analyzer-forms.md +173 -0
- package/content/plugins/audit/agents/a11y-analyzer-keyboard.md +183 -0
- package/content/plugins/audit/agents/a11y-analyzer-semantic.md +169 -0
- package/content/plugins/audit/agents/a11y-analyzer-visual.md +172 -0
- package/content/plugins/audit/agents/a11y-consensus.md +249 -0
- package/content/plugins/audit/agents/accessibility.md +558 -0
- package/content/plugins/audit/agents/api-quality-analyzer-conventions.md +156 -0
- package/content/plugins/audit/agents/api-quality-analyzer-docs.md +184 -0
- package/content/plugins/audit/agents/api-quality-analyzer-errors.md +191 -0
- package/content/plugins/audit/agents/api-quality-analyzer-pagination.md +179 -0
- package/content/plugins/audit/agents/api-quality-analyzer-versioning.md +150 -0
- package/content/plugins/audit/agents/api-quality-consensus.md +217 -0
- package/content/plugins/audit/agents/api-validator.md +191 -0
- package/content/plugins/audit/agents/arch-analyzer-circular.md +156 -0
- package/content/plugins/audit/agents/arch-analyzer-complexity.md +193 -0
- package/content/plugins/audit/agents/arch-analyzer-coupling.md +152 -0
- package/content/plugins/audit/agents/arch-analyzer-layering.md +160 -0
- package/content/plugins/audit/agents/arch-analyzer-patterns.md +210 -0
- package/content/plugins/audit/agents/arch-consensus.md +228 -0
- package/content/plugins/audit/agents/browser-qa.md +342 -0
- package/content/plugins/audit/agents/code-reviewer.md +298 -0
- package/content/plugins/audit/agents/completeness-analyzer-api.md +199 -0
- package/content/plugins/audit/agents/completeness-analyzer-conditional.md +211 -0
- package/content/plugins/audit/agents/completeness-analyzer-handlers.md +166 -0
- package/content/plugins/audit/agents/completeness-analyzer-imports.md +165 -0
- package/content/plugins/audit/agents/completeness-analyzer-routes.md +190 -0
- package/content/plugins/audit/agents/completeness-analyzer-state.md +196 -0
- package/content/plugins/audit/agents/completeness-analyzer-stubs.md +206 -0
- package/content/plugins/audit/agents/completeness-consensus.md +295 -0
- package/content/plugins/audit/agents/error-analyzer.md +213 -0
- package/content/plugins/audit/agents/flow-analyzer-authorization.md +182 -0
- package/content/plugins/audit/agents/flow-analyzer-discovery.md +174 -0
- package/content/plugins/audit/agents/flow-analyzer-errors.md +186 -0
- package/content/plugins/audit/agents/flow-analyzer-feedback.md +185 -0
- package/content/plugins/audit/agents/flow-analyzer-navigation.md +177 -0
- package/content/plugins/audit/agents/flow-analyzer-persistence.md +193 -0
- package/content/plugins/audit/agents/flow-analyzer-wiring.md +169 -0
- package/content/plugins/audit/agents/flow-consensus.md +237 -0
- package/content/plugins/audit/agents/legal-analyzer-a11y.md +114 -0
- package/content/plugins/audit/agents/legal-analyzer-ai.md +121 -0
- package/content/plugins/audit/agents/legal-analyzer-consumer.md +114 -0
- package/content/plugins/audit/agents/legal-analyzer-content.md +117 -0
- package/content/plugins/audit/agents/legal-analyzer-international.md +119 -0
- package/content/plugins/audit/agents/legal-analyzer-licensing.md +119 -0
- package/content/plugins/audit/agents/legal-analyzer-privacy.md +112 -0
- package/content/plugins/audit/agents/legal-analyzer-security.md +116 -0
- package/content/plugins/audit/agents/legal-analyzer-terms.md +115 -0
- package/content/plugins/audit/agents/legal-consensus.md +250 -0
- package/content/plugins/audit/agents/logic-analyzer-edge.md +179 -0
- package/content/plugins/audit/agents/logic-analyzer-flow.md +264 -0
- package/content/plugins/audit/agents/logic-analyzer-invariant.md +215 -0
- package/content/plugins/audit/agents/logic-analyzer-race.md +280 -0
- package/content/plugins/audit/agents/logic-analyzer-type.md +227 -0
- package/content/plugins/audit/agents/logic-consensus.md +259 -0
- package/content/plugins/audit/agents/perf-analyzer-assets.md +182 -0
- package/content/plugins/audit/agents/perf-analyzer-bundle.md +173 -0
- package/content/plugins/audit/agents/perf-analyzer-caching.md +170 -0
- package/content/plugins/audit/agents/perf-analyzer-compute.md +173 -0
- package/content/plugins/audit/agents/perf-analyzer-memory.md +193 -0
- package/content/plugins/audit/agents/perf-analyzer-network.md +165 -0
- package/content/plugins/audit/agents/perf-analyzer-queries.md +162 -0
- package/content/plugins/audit/agents/perf-analyzer-rendering.md +168 -0
- package/content/plugins/audit/agents/perf-consensus.md +287 -0
- package/content/plugins/audit/agents/qa.md +820 -0
- package/content/plugins/audit/agents/quality-analyzer-comments.md +159 -0
- package/content/plugins/audit/agents/quality-analyzer-duplication.md +184 -0
- package/content/plugins/audit/agents/quality-analyzer-naming.md +160 -0
- package/content/plugins/audit/agents/quality-consensus.md +241 -0
- package/content/plugins/audit/agents/schema-validator.md +473 -0
- package/content/plugins/audit/agents/security-analyzer-api.md +210 -0
- package/content/plugins/audit/agents/security-analyzer-auth.md +169 -0
- package/content/plugins/audit/agents/security-analyzer-authz.md +180 -0
- package/content/plugins/audit/agents/security-analyzer-deps.md +153 -0
- package/content/plugins/audit/agents/security-analyzer-infra.md +184 -0
- package/content/plugins/audit/agents/security-analyzer-injection.md +155 -0
- package/content/plugins/audit/agents/security-analyzer-input.md +201 -0
- package/content/plugins/audit/agents/security-analyzer-secrets.md +183 -0
- package/content/plugins/audit/agents/security-consensus.md +283 -0
- package/content/plugins/audit/agents/test-analyzer-assertions.md +188 -0
- package/content/plugins/audit/agents/test-analyzer-coverage.md +189 -0
- package/content/plugins/audit/agents/test-analyzer-fragility.md +193 -0
- package/content/plugins/audit/agents/test-analyzer-integration.md +161 -0
- package/content/plugins/audit/agents/test-analyzer-maintenance.md +180 -0
- package/content/plugins/audit/agents/test-analyzer-mocking.md +188 -0
- package/content/plugins/audit/agents/test-analyzer-patterns.md +196 -0
- package/content/plugins/audit/agents/test-analyzer-structure.md +184 -0
- package/content/plugins/audit/agents/test-consensus.md +301 -0
- package/content/plugins/audit/agents/testing.md +561 -0
- package/content/plugins/audit/agents/ui-validator.md +344 -0
- package/content/plugins/audit/plugin.yaml +186 -5
- package/content/plugins/audit/skills/agileflow-audit/SKILL.md +113 -0
- package/content/plugins/audit/skills/agileflow-audit/references/audit-depth-guide.md +151 -0
- package/content/plugins/audit/skills/agileflow-audit/references/dependency-risk-guide.md +139 -0
- package/content/plugins/audit/skills/agileflow-audit/references/owasp-top10.md +120 -0
- package/content/plugins/audit/skills/agileflow-audit/references/performance-budget-guide.md +143 -0
- package/content/plugins/audit/skills/agileflow-audit/references/wcag-criteria.md +117 -0
- package/content/plugins/audit/skills/agileflow-audit/workflows/run-audit.md +52 -0
- package/content/plugins/audit/skills/agileflow-audit/workflows/tdd.md +66 -0
- package/content/plugins/core/agents/adr-writer.md +521 -0
- package/content/plugins/core/agents/epic-planner.md +520 -0
- package/content/plugins/core/agents/mentor.md +709 -0
- package/content/plugins/core/agents/orchestrator.md +776 -0
- package/content/plugins/core/agents/team-coordinator.md +334 -0
- package/content/plugins/core/agents/team-lead.md +181 -0
- package/content/plugins/core/agents/workspace-orchestrator.md +146 -0
- package/content/plugins/core/hooks/context-loader.js +31 -4
- package/content/plugins/core/hooks/damage-control-bash.js +10 -2
- package/content/plugins/core/hooks/damage-control-edit.js +4 -1
- package/content/plugins/core/hooks/damage-control-patterns.yaml +1 -1
- package/content/plugins/core/hooks/damage-control-write.js +4 -1
- package/content/plugins/core/hooks/{pre-compact-state.js → post-compact-state.js} +25 -8
- package/content/plugins/core/hooks/preferences-injector.js +352 -0
- package/content/plugins/core/plugin.yaml +24 -28
- package/content/plugins/core/skills/agileflow-adr/SKILL.md +34 -8
- package/content/plugins/core/skills/agileflow-adr/references/madr-format-guide.md +86 -0
- package/content/plugins/core/skills/agileflow-adr/workflows/write-adr.md +57 -0
- package/content/plugins/core/skills/agileflow-babysit-mentor/SKILL.md +94 -27
- package/content/plugins/core/skills/agileflow-babysit-mentor/references/mentor-decision-guide.md +81 -0
- package/content/plugins/core/skills/agileflow-babysit-mentor/workflows/mentor-session.md +79 -0
- package/content/plugins/core/skills/agileflow-epic-planner/SKILL.md +37 -7
- package/content/plugins/core/skills/agileflow-epic-planner/references/epic-sizing-guide.md +81 -0
- package/content/plugins/core/skills/agileflow-epic-planner/workflows/plan-epic.md +55 -0
- package/content/plugins/core/skills/agileflow-status-updater/SKILL.md +36 -20
- package/content/plugins/core/skills/agileflow-status-updater/references/status-transitions.md +89 -0
- package/content/plugins/core/skills/agileflow-status-updater/workflows/update-status.md +56 -0
- package/content/plugins/core/skills/agileflow-story-writer/SKILL.md +39 -114
- package/content/plugins/core/skills/agileflow-story-writer/references/estimation-reference.md +36 -0
- package/content/plugins/core/skills/agileflow-story-writer/references/story-template.md +92 -0
- package/content/plugins/core/skills/agileflow-story-writer/workflows/write-story.md +138 -0
- package/content/plugins/council/agents/council-advocate.md +223 -0
- package/content/plugins/council/agents/council-analyst.md +278 -0
- package/content/plugins/council/agents/council-compounder.md +204 -0
- package/content/plugins/council/agents/council-contrarian.md +217 -0
- package/content/plugins/council/agents/council-moonshot.md +217 -0
- package/content/plugins/council/agents/council-optimist.md +185 -0
- package/content/plugins/council/agents/council-revenue.md +200 -0
- package/content/plugins/council/agents/council-technical.md +218 -0
- package/content/plugins/council/agents/multi-expert.md +334 -0
- package/content/plugins/council/plugin.yaml +23 -4
- package/content/plugins/council/skills/agileflow-council/SKILL.md +102 -0
- package/content/plugins/council/skills/agileflow-council/references/decision-log-template.md +109 -0
- package/content/plugins/council/skills/agileflow-council/references/perspective-guide.md +104 -0
- package/content/plugins/council/skills/agileflow-council/references/when-to-convene-guide.md +112 -0
- package/content/plugins/council/skills/agileflow-council/workflows/convene.md +73 -0
- package/content/plugins/council/skills/agileflow-council/workflows/multi-expert.md +75 -0
- package/content/plugins/database/plugin.yaml +14 -0
- package/content/plugins/database/skills/agileflow-database/SKILL.md +284 -0
- package/content/plugins/database/skills/agileflow-database/references/indexing-guide.md +313 -0
- package/content/plugins/database/skills/agileflow-database/references/migration-guide.md +328 -0
- package/content/plugins/database/skills/agileflow-database/references/schema-design-guide.md +467 -0
- package/content/plugins/database/skills/agileflow-database/workflows/design-schema.md +213 -0
- package/content/plugins/database/skills/agileflow-database/workflows/optimize-query.md +253 -0
- package/content/plugins/debugging/plugin.yaml +14 -0
- package/content/plugins/debugging/skills/agileflow-debug/SKILL.md +236 -0
- package/content/plugins/debugging/skills/agileflow-debug/references/common-patterns.md +350 -0
- package/content/plugins/debugging/skills/agileflow-debug/references/debugging-strategies.md +328 -0
- package/content/plugins/debugging/skills/agileflow-debug/workflows/debug-issue.md +187 -0
- package/content/plugins/debugging/skills/agileflow-debug/workflows/reproduce-bug.md +194 -0
- package/content/plugins/delivery/agents/ci.md +547 -0
- package/content/plugins/delivery/agents/devops.md +789 -0
- package/content/plugins/delivery/plugin.yaml +19 -0
- package/content/plugins/delivery/skills/agileflow-delivery/SKILL.md +111 -0
- package/content/plugins/delivery/skills/agileflow-delivery/references/changelog-format-guide.md +133 -0
- package/content/plugins/delivery/skills/agileflow-delivery/references/ci-pipeline-guide.md +158 -0
- package/content/plugins/delivery/skills/agileflow-delivery/references/pr-checklist-guide.md +133 -0
- package/content/plugins/delivery/skills/agileflow-delivery/references/release-checklist.md +142 -0
- package/content/plugins/delivery/skills/agileflow-delivery/workflows/changelog.md +72 -0
- package/content/plugins/delivery/skills/agileflow-delivery/workflows/deploy.md +74 -0
- package/content/plugins/delivery/skills/agileflow-delivery/workflows/pr.md +75 -0
- package/content/plugins/docs/agents/documentation.md +544 -0
- package/content/plugins/docs/agents/readme-updater.md +640 -0
- package/content/plugins/docs/plugin.yaml +19 -0
- package/content/plugins/docs/skills/agileflow-docs/SKILL.md +106 -0
- package/content/plugins/docs/skills/agileflow-docs/references/api-doc-template.md +167 -0
- package/content/plugins/docs/skills/agileflow-docs/references/doc-types-guide.md +141 -0
- package/content/plugins/docs/skills/agileflow-docs/references/readme-template.md +156 -0
- package/content/plugins/docs/skills/agileflow-docs/workflows/readme-sync.md +57 -0
- package/content/plugins/docs/skills/agileflow-docs/workflows/sync.md +64 -0
- package/content/plugins/engineering/agents/api.md +718 -0
- package/content/plugins/engineering/agents/codebase-query.md +285 -0
- package/content/plugins/engineering/agents/compliance.md +559 -0
- package/content/plugins/engineering/agents/database.md +644 -0
- package/content/plugins/engineering/agents/integrations.md +644 -0
- package/content/plugins/engineering/agents/mobile.md +552 -0
- package/content/plugins/engineering/agents/monitoring.md +585 -0
- package/content/plugins/engineering/agents/performance.md +529 -0
- package/content/plugins/engineering/agents/refactor.md +592 -0
- package/content/plugins/engineering/agents/security.md +524 -0
- package/content/plugins/engineering/agents/ui.md +1336 -0
- package/content/plugins/engineering/plugin.yaml +37 -0
- package/content/plugins/engineering/skills/agileflow-engineering/SKILL.md +127 -0
- package/content/plugins/engineering/skills/agileflow-engineering/references/code-review-guide.md +126 -0
- package/content/plugins/engineering/skills/agileflow-engineering/references/domain-routing-guide.md +89 -0
- package/content/plugins/engineering/skills/agileflow-engineering/references/refactoring-guide.md +136 -0
- package/content/plugins/engineering/skills/agileflow-engineering/workflows/diagnose.md +63 -0
- package/content/plugins/engineering/skills/agileflow-engineering/workflows/impact.md +60 -0
- package/content/plugins/ideation/agents/brainstorm-analyzer-features.md +179 -0
- package/content/plugins/ideation/agents/brainstorm-analyzer-growth.md +169 -0
- package/content/plugins/ideation/agents/brainstorm-analyzer-integration.md +181 -0
- package/content/plugins/ideation/agents/brainstorm-analyzer-market.md +150 -0
- package/content/plugins/ideation/agents/brainstorm-analyzer-ux.md +180 -0
- package/content/plugins/ideation/agents/brainstorm-consensus.md +245 -0
- package/content/plugins/ideation/agents/design.md +568 -0
- package/content/plugins/ideation/agents/product.md +582 -0
- package/content/plugins/ideation/plugin.yaml +31 -0
- package/content/plugins/ideation/skills/agileflow-ideation/SKILL.md +109 -0
- package/content/plugins/ideation/skills/agileflow-ideation/references/brainstorm-techniques.md +138 -0
- package/content/plugins/ideation/skills/agileflow-ideation/references/competitive-analysis-template.md +148 -0
- package/content/plugins/ideation/skills/agileflow-ideation/references/feature-prioritization-guide.md +147 -0
- package/content/plugins/ideation/skills/agileflow-ideation/references/user-story-patterns.md +152 -0
- package/content/plugins/ideation/skills/agileflow-ideation/workflows/features.md +65 -0
- package/content/plugins/ideation/skills/agileflow-ideation/workflows/ideate.md +54 -0
- package/content/plugins/migration/agents/datamigration.md +757 -0
- package/content/plugins/migration/plugin.yaml +17 -0
- package/content/plugins/migration/skills/agileflow-migration/SKILL.md +106 -0
- package/content/plugins/migration/skills/agileflow-migration/references/data-validation-checklist.md +154 -0
- package/content/plugins/migration/skills/agileflow-migration/references/migration-patterns.md +209 -0
- package/content/plugins/migration/skills/agileflow-migration/references/rollback-playbook.md +171 -0
- package/content/plugins/migration/skills/agileflow-migration/references/version-compatibility-matrix.md +155 -0
- package/content/plugins/migration/skills/agileflow-migration/workflows/plan.md +73 -0
- package/content/plugins/migration/skills/agileflow-migration/workflows/validate.md +71 -0
- package/content/plugins/performance/plugin.yaml +14 -0
- package/content/plugins/performance/skills/agileflow-performance/SKILL.md +224 -0
- package/content/plugins/performance/skills/agileflow-performance/references/optimization-patterns.md +554 -0
- package/content/plugins/performance/skills/agileflow-performance/references/profiling-guide.md +383 -0
- package/content/plugins/performance/skills/agileflow-performance/references/web-vitals-guide.md +360 -0
- package/content/plugins/performance/skills/agileflow-performance/workflows/improve-web-vitals.md +344 -0
- package/content/plugins/performance/skills/agileflow-performance/workflows/profile-and-fix.md +254 -0
- package/content/plugins/planning/agents/analytics.md +670 -0
- package/content/plugins/planning/agents/rlm-subcore.md +215 -0
- package/content/plugins/planning/plugin.yaml +19 -0
- package/content/plugins/planning/skills/agileflow-planning/SKILL.md +111 -0
- package/content/plugins/planning/skills/agileflow-planning/references/estimation-guide.md +114 -0
- package/content/plugins/planning/skills/agileflow-planning/references/rpi-workflow.md +119 -0
- package/content/plugins/planning/skills/agileflow-planning/references/sprint-planning-guide.md +145 -0
- package/content/plugins/planning/skills/agileflow-planning/workflows/impact.md +63 -0
- package/content/plugins/planning/skills/agileflow-planning/workflows/rpi.md +104 -0
- package/content/plugins/psychology/plugin.yaml +14 -0
- package/content/plugins/psychology/skills/agileflow-retention/SKILL.md +252 -0
- package/content/plugins/psychology/skills/agileflow-retention/references/competitor-analysis.md +240 -0
- package/content/plugins/psychology/skills/agileflow-retention/references/psychology-models.md +349 -0
- package/content/plugins/psychology/skills/agileflow-retention/references/retention-patterns.md +279 -0
- package/content/plugins/psychology/skills/agileflow-retention/workflows/design-retention-feature.md +287 -0
- package/content/plugins/psychology/skills/agileflow-retention/workflows/retention-audit.md +259 -0
- package/content/plugins/refactoring/plugin.yaml +14 -0
- package/content/plugins/refactoring/skills/agileflow-refactor/SKILL.md +235 -0
- package/content/plugins/refactoring/skills/agileflow-refactor/references/refactoring-patterns.md +405 -0
- package/content/plugins/refactoring/skills/agileflow-refactor/references/safety-checks.md +177 -0
- package/content/plugins/refactoring/skills/agileflow-refactor/workflows/extract-module.md +226 -0
- package/content/plugins/refactoring/skills/agileflow-refactor/workflows/safe-refactor.md +169 -0
- package/content/plugins/research/agents/research.md +503 -0
- package/content/plugins/research/plugin.yaml +17 -0
- package/content/plugins/research/skills/agileflow-research/SKILL.md +110 -0
- package/content/plugins/research/skills/agileflow-research/references/knowledge-decay-guide.md +121 -0
- package/content/plugins/research/skills/agileflow-research/references/research-prompt-guide.md +141 -0
- package/content/plugins/research/skills/agileflow-research/references/synthesis-template.md +154 -0
- package/content/plugins/research/skills/agileflow-research/workflows/analyze.md +60 -0
- package/content/plugins/research/skills/agileflow-research/workflows/ask.md +64 -0
- package/content/plugins/research/skills/agileflow-research/workflows/import.md +66 -0
- package/content/plugins/research/skills/agileflow-research/workflows/synthesize.md +66 -0
- package/content/plugins/reviews/plugin.yaml +14 -0
- package/content/plugins/reviews/skills/agileflow-pr-reviewer/SKILL.md +241 -0
- package/content/plugins/reviews/skills/agileflow-pr-reviewer/references/review-checklist.md +200 -0
- package/content/plugins/reviews/skills/agileflow-pr-reviewer/references/security-patterns.md +328 -0
- package/content/plugins/reviews/skills/agileflow-pr-reviewer/workflows/review-pr.md +153 -0
- package/content/plugins/reviews/skills/agileflow-pr-reviewer/workflows/security-review.md +177 -0
- package/content/plugins/seo/agents/seo-analyzer-content.md +169 -0
- package/content/plugins/seo/agents/seo-analyzer-images.md +198 -0
- package/content/plugins/seo/agents/seo-analyzer-performance.md +217 -0
- package/content/plugins/seo/agents/seo-analyzer-schema.md +184 -0
- package/content/plugins/seo/agents/seo-analyzer-sitemap.md +177 -0
- package/content/plugins/seo/agents/seo-analyzer-technical.md +151 -0
- package/content/plugins/seo/agents/seo-consensus.md +304 -0
- package/content/plugins/seo/plugin.yaml +19 -4
- package/content/plugins/seo/skills/agileflow-seo/SKILL.md +188 -0
- package/content/plugins/seo/skills/agileflow-seo/references/cwv-thresholds.md +110 -0
- package/content/plugins/seo/skills/agileflow-seo/references/eeat-framework.md +144 -0
- package/content/plugins/seo/skills/agileflow-seo/references/keyword-research-guide.md +125 -0
- package/content/plugins/seo/skills/agileflow-seo/references/schema-types.md +139 -0
- package/content/plugins/seo/skills/agileflow-seo/references/technical-seo-checklist.md +139 -0
- package/content/plugins/seo/skills/agileflow-seo/workflows/audit.md +98 -0
- package/content/plugins/seo/skills/agileflow-seo/workflows/page.md +118 -0
- package/content/plugins/testing/plugin.yaml +16 -0
- package/content/plugins/testing/skills/agileflow-test-writer/SKILL.md +260 -0
- package/content/plugins/testing/skills/agileflow-test-writer/references/coverage-targets.md +239 -0
- package/content/plugins/testing/skills/agileflow-test-writer/references/test-patterns.md +420 -0
- package/content/plugins/testing/skills/agileflow-test-writer/workflows/add-coverage.md +154 -0
- package/content/plugins/testing/skills/agileflow-test-writer/workflows/write-tests-from-ac.md +225 -0
- package/package.json +2 -2
- package/src/cli/commands/doctor.js +818 -30
- package/src/cli/commands/hook.js +17 -14
- package/src/cli/commands/launch.js +1454 -0
- package/src/cli/commands/learn.js +149 -0
- package/src/cli/commands/plugins.js +113 -0
- package/src/cli/commands/setup.js +455 -110
- package/src/cli/commands/skills.js +324 -0
- package/src/cli/commands/status.js +8 -10
- package/src/cli/commands/update.js +76 -15
- package/src/cli/index.js +90 -26
- package/src/cli/wizard/babysit-mode-picker.js +192 -0
- package/src/cli/wizard/behaviors-picker.js +208 -54
- package/src/cli/wizard/ide-picker.js +40 -28
- package/src/cli/wizard/install-scope-picker.js +57 -0
- package/src/cli/wizard/launch-alias-picker.js +50 -0
- package/src/cli/wizard/launch-cli-picker.js +129 -0
- package/src/cli/wizard/launch-tmux-picker.js +133 -0
- package/src/cli/wizard/learnings-picker.js +40 -0
- package/src/cli/wizard/plugin-picker.js +47 -16
- package/src/lib/brand.js +116 -0
- package/src/lib/errors.js +120 -0
- package/src/lib/path-check.js +39 -0
- package/src/runtime/config/defaults.js +22 -17
- package/src/runtime/config/loader.js +77 -8
- package/src/runtime/config/schema.json +43 -16
- package/src/runtime/config/writer.js +3 -1
- package/src/runtime/ide/babysit-skill.js +202 -0
- package/src/runtime/ide/capabilities.js +84 -29
- package/src/runtime/ide/claude-code-content.js +177 -0
- package/src/runtime/ide/claude-code-settings.js +67 -29
- package/src/runtime/ide/claude-code-skills.js +47 -32
- package/src/runtime/ide/codex-config.js +295 -0
- package/src/runtime/installer/install.js +252 -24
- package/src/runtime/launch/alias-installer.js +191 -0
- package/src/runtime/launch/cli-resume.js +244 -0
- package/src/runtime/launch/closed-windows.js +338 -0
- package/src/runtime/launch/defaults.js +66 -0
- package/src/runtime/launch/detect-clis.js +69 -0
- package/src/runtime/launch/doctor.js +464 -0
- package/src/runtime/launch/exec-wrapper.js +114 -0
- package/src/runtime/launch/parallel-session.js +247 -0
- package/src/runtime/launch/prefs.js +211 -0
- package/src/runtime/launch/project-prefs.js +234 -0
- package/src/runtime/launch/resolve-cli.js +56 -0
- package/src/runtime/launch/restore.js +152 -0
- package/src/runtime/launch/schema.json +75 -0
- package/src/runtime/launch/session-lifecycle.js +313 -0
- package/src/runtime/launch/session-registry.js +401 -0
- package/src/runtime/launch/spawn.js +103 -0
- package/src/runtime/launch/tabs.js +350 -0
- package/src/runtime/launch/tmux.js +764 -0
- package/src/runtime/launch/worktree.js +260 -0
- package/src/runtime/plugins/registry.js +16 -11
- package/src/runtime/plugins/validator.js +57 -43
- package/src/runtime/skills/learnings.js +308 -0
- package/content/plugins/core/hooks/babysit-mentor-injector.js +0 -55
- package/src/cli/wizard/personalization.js +0 -64
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agileflow-database
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
category: agileflow/database
|
|
5
|
+
description: |
|
|
6
|
+
Use when designing schema, writing migrations, optimizing queries,
|
|
7
|
+
choosing indexes, or diagnosing database performance. Covers relational
|
|
8
|
+
(PostgreSQL, MySQL, SQLite) and common NoSQL patterns (MongoDB, Redis).
|
|
9
|
+
Always migration-safe: reversible, zero-downtime, tested.
|
|
10
|
+
triggers:
|
|
11
|
+
keywords:
|
|
12
|
+
- schema design
|
|
13
|
+
- database
|
|
14
|
+
- migration
|
|
15
|
+
- index
|
|
16
|
+
- query optimization
|
|
17
|
+
- N+1
|
|
18
|
+
- foreign key
|
|
19
|
+
- normalization
|
|
20
|
+
- join
|
|
21
|
+
- slow query
|
|
22
|
+
- EXPLAIN
|
|
23
|
+
- table design
|
|
24
|
+
- relationship
|
|
25
|
+
- one-to-many
|
|
26
|
+
- many-to-many
|
|
27
|
+
- transaction
|
|
28
|
+
- deadlock
|
|
29
|
+
- partitioning
|
|
30
|
+
priority: 50
|
|
31
|
+
exclude:
|
|
32
|
+
- database administrator (role title)
|
|
33
|
+
provides:
|
|
34
|
+
agents: []
|
|
35
|
+
learns:
|
|
36
|
+
enabled: true
|
|
37
|
+
file: _learnings/database.yaml
|
|
38
|
+
maxEntries: 50
|
|
39
|
+
depends:
|
|
40
|
+
skills: []
|
|
41
|
+
plugins: [core]
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
# AgileFlow Database
|
|
45
|
+
|
|
46
|
+
Schema design, migration discipline, query optimization, and indexing strategy — for relational databases (PostgreSQL, MySQL, SQLite) and common NoSQL patterns (MongoDB, Redis). Every change is reversible and zero-downtime by default.
|
|
47
|
+
|
|
48
|
+
## When this skill activates
|
|
49
|
+
|
|
50
|
+
- User needs to design or review a database schema
|
|
51
|
+
- User is writing or reviewing a migration
|
|
52
|
+
- User has a slow query and needs help diagnosing it
|
|
53
|
+
- User asks about indexing strategy — what to index, how to compose indexes
|
|
54
|
+
- User mentions N+1 queries, missing indexes, or EXPLAIN output
|
|
55
|
+
- User needs to model a relationship (one-to-many, many-to-many, hierarchical)
|
|
56
|
+
- User is planning a large table backfill or zero-downtime column change
|
|
57
|
+
- User asks about ACID, transactions, deadlocks, or isolation levels
|
|
58
|
+
|
|
59
|
+
## Opening discovery flow
|
|
60
|
+
|
|
61
|
+
**When invoked without clear context, ask one focused question to understand the goal.**
|
|
62
|
+
|
|
63
|
+
```xml
|
|
64
|
+
<invoke name="AskUserQuestion">
|
|
65
|
+
<parameter name="questions">[
|
|
66
|
+
{
|
|
67
|
+
"question": "What database work do you need help with?",
|
|
68
|
+
"header": "Database task",
|
|
69
|
+
"multiSelect": false,
|
|
70
|
+
"options": [
|
|
71
|
+
{"label": "Design a new schema or model a relationship (Recommended starting point)", "description": "Entity identification, normalization, column types, naming conventions, and relationship patterns"},
|
|
72
|
+
{"label": "Write or review a migration", "description": "Reversible up/down, zero-downtime patterns, lock avoidance, backfill strategy"},
|
|
73
|
+
{"label": "Optimize a slow query", "description": "Paste the query and EXPLAIN ANALYZE output — I'll diagnose and fix it"},
|
|
74
|
+
{"label": "Plan an indexing strategy", "description": "Which columns to index, composite index column order, partial indexes, covering indexes"},
|
|
75
|
+
{"label": "Diagnose a production database problem", "description": "Deadlocks, replication lag, bloat, long-running transactions, connection exhaustion"}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"question": "Which database are you using?",
|
|
80
|
+
"header": "Database engine",
|
|
81
|
+
"multiSelect": false,
|
|
82
|
+
"options": [
|
|
83
|
+
{"label": "PostgreSQL", "description": "Full feature set: JSONB, GIN/GiST indexes, CTEs, partitioning, LISTEN/NOTIFY"},
|
|
84
|
+
{"label": "MySQL / MariaDB", "description": "InnoDB engine, JSON columns, generated columns"},
|
|
85
|
+
{"label": "SQLite", "description": "Embedded, file-based — great for local-first or edge deployments"},
|
|
86
|
+
{"label": "MongoDB", "description": "Document store — schema validation, aggregation pipeline, Atlas Search"},
|
|
87
|
+
{"label": "Redis", "description": "Key-value / data structure store — caching, pub/sub, sorted sets"},
|
|
88
|
+
{"label": "Not sure / multiple", "description": "Tell me your stack and I'll adapt"}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
]</parameter>
|
|
92
|
+
</invoke>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Route based on answers:**
|
|
96
|
+
|
|
97
|
+
| Task | Next action |
|
|
98
|
+
| ------------------------- | ------------------------------------------------ |
|
|
99
|
+
| Schema design | Follow `workflows/design-schema.md` |
|
|
100
|
+
| Migration | Follow `workflows/write-migration.md` (inline) |
|
|
101
|
+
| Slow query / optimization | Follow `workflows/optimize-query.md` |
|
|
102
|
+
| Indexing strategy | Load `references/indexing-guide.md` |
|
|
103
|
+
| Production diagnosis | Ask for symptoms, error logs, and EXPLAIN output |
|
|
104
|
+
|
|
105
|
+
## ACID and transaction fundamentals
|
|
106
|
+
|
|
107
|
+
Every database operation that touches more than one row should be wrapped in a transaction. Know what you're getting:
|
|
108
|
+
|
|
109
|
+
| Property | Meaning |
|
|
110
|
+
| ----------- | -------------------------------------------------------------------- |
|
|
111
|
+
| Atomicity | All operations in the transaction succeed or all are rolled back |
|
|
112
|
+
| Consistency | Data moves from one valid state to another — constraints always hold |
|
|
113
|
+
| Isolation | Concurrent transactions don't see each other's partial writes |
|
|
114
|
+
| Durability | Committed transactions survive crashes |
|
|
115
|
+
|
|
116
|
+
### Isolation levels (PostgreSQL)
|
|
117
|
+
|
|
118
|
+
| Level | Dirty read | Non-repeatable read | Phantom read | Use when |
|
|
119
|
+
| --------------- | ---------- | ------------------- | ------------ | ------------------------------------------- |
|
|
120
|
+
| Read Committed | No | Yes | Yes | Default — fine for most OLTP |
|
|
121
|
+
| Repeatable Read | No | No | No (PG) | Reports that must be consistent across rows |
|
|
122
|
+
| Serializable | No | No | No | Financial operations, inventory deduction |
|
|
123
|
+
|
|
124
|
+
## Normalization vs denormalization decision
|
|
125
|
+
|
|
126
|
+
**Normalize for writes, denormalize for reads.**
|
|
127
|
+
|
|
128
|
+
| Situation | Approach |
|
|
129
|
+
| ------------------------------------------------------- | -------------------------------------------------------- |
|
|
130
|
+
| OLTP: frequent inserts/updates, data integrity critical | Normalize to 3NF |
|
|
131
|
+
| OLAP / reporting: reads dominate, aggregations needed | Denormalize into a reporting table or materialized view |
|
|
132
|
+
| Mixed: primary OLTP with some reporting | Normalize primary tables, add read-model tables or views |
|
|
133
|
+
| Event-sourced system | Events table normalized; projections denormalized |
|
|
134
|
+
|
|
135
|
+
**Signs you've over-normalized:**
|
|
136
|
+
|
|
137
|
+
- Every read requires 5+ JOINs
|
|
138
|
+
- Query planning time exceeds execution time
|
|
139
|
+
- Application code reconstructs a single object from 8 round-trips
|
|
140
|
+
|
|
141
|
+
**Signs you've under-normalized:**
|
|
142
|
+
|
|
143
|
+
- The same value appears in 1,000 rows and you update it in one place — then find 200 rows still have the old value
|
|
144
|
+
- You can't enforce a constraint without an application-level check
|
|
145
|
+
|
|
146
|
+
## Migration discipline
|
|
147
|
+
|
|
148
|
+
Every migration must be reversible. Every destructive operation requires a multi-step deployment plan.
|
|
149
|
+
|
|
150
|
+
### The golden rules
|
|
151
|
+
|
|
152
|
+
1. **Always write `down`** — even if you think you'll never roll back
|
|
153
|
+
2. **Never lose data in `down`** — rename instead of drop, or restore from backup column
|
|
154
|
+
3. **Test `down` in staging first** — broken rollbacks discovered in production are disasters
|
|
155
|
+
4. **One logical change per migration** — column add, index add, constraint add are separate files
|
|
156
|
+
5. **Never seed production data in migrations** — use seeds or a separate idempotent script
|
|
157
|
+
|
|
158
|
+
### Zero-downtime patterns
|
|
159
|
+
|
|
160
|
+
| Change | Safe approach |
|
|
161
|
+
| ---------------------- | --------------------------------------------------------------------------- |
|
|
162
|
+
| Add nullable column | One migration — always safe |
|
|
163
|
+
| Add NOT NULL column | Add nullable → backfill → add default → add constraint (3 migrations) |
|
|
164
|
+
| Add index | `CREATE INDEX CONCURRENTLY` — non-blocking in PostgreSQL |
|
|
165
|
+
| Rename column | Add new → backfill → update app → drop old (3 deploys) |
|
|
166
|
+
| Remove column | Stop using in code → deploy → then drop (2 deploys) |
|
|
167
|
+
| Change column type | Add new → trigger/backfill → switch app → drop old |
|
|
168
|
+
| Large table backfill | Batch by PK in chunks of 1,000–10,000, sleep between batches |
|
|
169
|
+
| Add FK constraint (PG) | Add `NOT VALID` → `VALIDATE CONSTRAINT` separately (avoids full table lock) |
|
|
170
|
+
|
|
171
|
+
## Query performance principles
|
|
172
|
+
|
|
173
|
+
### The N+1 problem
|
|
174
|
+
|
|
175
|
+
N+1 happens when you fetch a list of N records, then issue one query per record to fetch related data. The fix is always eager loading or a JOIN.
|
|
176
|
+
|
|
177
|
+
```sql
|
|
178
|
+
-- Bad: 1 query for orders + N queries for each order's user
|
|
179
|
+
SELECT * FROM orders;
|
|
180
|
+
-- then for each order: SELECT * FROM users WHERE id = $1
|
|
181
|
+
|
|
182
|
+
-- Good: one query with a JOIN
|
|
183
|
+
SELECT o.*, u.name, u.email
|
|
184
|
+
FROM orders o
|
|
185
|
+
JOIN users u ON u.id = o.user_id
|
|
186
|
+
WHERE o.status = 'pending';
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Reading EXPLAIN ANALYZE
|
|
190
|
+
|
|
191
|
+
```sql
|
|
192
|
+
EXPLAIN ANALYZE SELECT * FROM orders WHERE user_id = 42 AND status = 'pending';
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Key nodes to recognize:
|
|
196
|
+
|
|
197
|
+
| Node | Meaning | Action if unexpected |
|
|
198
|
+
| ---------------- | ------------------------------------------------------------------- | --------------------------------- |
|
|
199
|
+
| Seq Scan | Full table scan — no index used | Add index if table is large |
|
|
200
|
+
| Index Scan | Index used, then row fetched from heap | Normal — check rows estimate |
|
|
201
|
+
| Index Only Scan | Covering index — no heap fetch needed | Best possible |
|
|
202
|
+
| Bitmap Heap Scan | Index used for range, rows fetched in batches | Normal for range queries |
|
|
203
|
+
| Hash Join | In-memory hash of smaller table, probe with larger | Fine; bad if hash batches to disk |
|
|
204
|
+
| Nested Loop | For each outer row, loop inner — fine for small sets, bad for large | Check row estimates |
|
|
205
|
+
|
|
206
|
+
**Cost anatomy:** `cost=0.00..432.10 rows=1 width=256`
|
|
207
|
+
|
|
208
|
+
- First number: startup cost (before first row)
|
|
209
|
+
- Second number: total cost (all rows)
|
|
210
|
+
- Rows: planner estimate — compare to `actual rows` for stale stats
|
|
211
|
+
|
|
212
|
+
If `actual rows` >> `rows estimate`, run `ANALYZE table_name` to refresh statistics.
|
|
213
|
+
|
|
214
|
+
## Common schema anti-patterns
|
|
215
|
+
|
|
216
|
+
| Anti-pattern | Problem | Fix |
|
|
217
|
+
| ---------------------------------- | ------------------------------------------------- | ------------------------------------------ |
|
|
218
|
+
| Storing comma-separated IDs | Can't JOIN, can't enforce FK, hard to query | Junction table |
|
|
219
|
+
| Using FLOAT for money | Floating-point precision errors | DECIMAL(19,4) or integer cents |
|
|
220
|
+
| Timestamps without timezone | Ambiguous on DST changes, breaks across regions | TIMESTAMPTZ, store in UTC |
|
|
221
|
+
| VARCHAR(255) everywhere | Magic number — usually meaningless | TEXT for arbitrary, or actual max length |
|
|
222
|
+
| No soft-delete strategy | Hard deletes break audit trails and FK references | deleted_at TIMESTAMPTZ NULL |
|
|
223
|
+
| Indexing every column | Slows writes, bloats storage, confuses planner | Index only WHERE / JOIN / ORDER BY columns |
|
|
224
|
+
| God table (100+ columns) | Hard to reason about, locks contend | Vertical split, 1-to-1 related tables |
|
|
225
|
+
| Polymorphic FK without constraints | No referential integrity possible | STI, CTI, or separate FK per type |
|
|
226
|
+
|
|
227
|
+
## Self-improving learnings
|
|
228
|
+
|
|
229
|
+
`_learnings/database.yaml` records:
|
|
230
|
+
|
|
231
|
+
- Database engine(s) and version in use
|
|
232
|
+
- ORM or query builder (Prisma, Drizzle, Knex, SQLAlchemy, GORM, ActiveRecord)
|
|
233
|
+
- Migration tool (Flyway, Liquibase, Rails migrations, Alembic, Prisma Migrate)
|
|
234
|
+
- Naming conventions the team uses (if non-standard)
|
|
235
|
+
- Whether the team uses UUID or BIGSERIAL for primary keys
|
|
236
|
+
- Partitioning strategy (if any)
|
|
237
|
+
- Connection pooling setup (PgBouncer, RDS Proxy, Prisma connection limit)
|
|
238
|
+
|
|
239
|
+
Apply on invocation; update on correction.
|
|
240
|
+
|
|
241
|
+
## Quality checklist
|
|
242
|
+
|
|
243
|
+
Before delivering any schema or migration:
|
|
244
|
+
|
|
245
|
+
- [ ] Every table has a primary key
|
|
246
|
+
- [ ] All foreign keys have corresponding indexes
|
|
247
|
+
- [ ] Timestamps use TIMESTAMPTZ (not TIMESTAMP), stored in UTC
|
|
248
|
+
- [ ] Money values use DECIMAL or integer cents — no FLOAT
|
|
249
|
+
- [ ] Migration has both `up` and `down`
|
|
250
|
+
- [ ] Zero-downtime pattern applied for any destructive change
|
|
251
|
+
- [ ] Large table changes use CONCURRENTLY or batch approach
|
|
252
|
+
- [ ] Constraints named explicitly (easier to reference in errors and rollbacks)
|
|
253
|
+
- [ ] New indexes created CONCURRENTLY in PostgreSQL
|
|
254
|
+
- [ ] EXPLAIN ANALYZE reviewed for any query expected to run at scale
|
|
255
|
+
|
|
256
|
+
## Integration
|
|
257
|
+
|
|
258
|
+
- **agileflow-test-writer** — generate tests for migration scripts, data access layers, and repository functions; DB changes without tests are untested contracts
|
|
259
|
+
- **agileflow-story-writer** — acceptance criteria for data-model changes drive schema decisions; always read the AC before designing the schema
|
|
260
|
+
- **agileflow-adr** — document significant schema decisions (UUID vs BIGSERIAL, multi-tenancy strategy, soft-delete vs hard-delete) before implementing
|
|
261
|
+
- **agileflow-migration** — use for zero-downtime schema migrations, large backfills, and framework-level ORM upgrades; database handles design, migration handles execution
|
|
262
|
+
- **agileflow-engineering** — engineering owns the feature; database is the specialist for the storage layer; coordinate so schema and API land together
|
|
263
|
+
- **agileflow-performance** — query optimisation, index analysis, and connection pool tuning overlap between both skills; use database for schema-level fixes, performance for application-level profiling
|
|
264
|
+
- **agileflow-audit** — the query performance and security dimensions of the audit surface DB issues; database fixes what the audit finds
|
|
265
|
+
- **agileflow-refactor** — when a schema has grown organically and needs restructuring (column renames, table splits, normalisation), coordinate with refactor for the application-layer changes
|
|
266
|
+
|
|
267
|
+
## References
|
|
268
|
+
|
|
269
|
+
Load these files when you need deeper context:
|
|
270
|
+
|
|
271
|
+
| File | When to load |
|
|
272
|
+
| ----------------------------------- | --------------------------------------------------------------------------- |
|
|
273
|
+
| `references/schema-design-guide.md` | Full normalization rules, naming conventions, column types, common patterns |
|
|
274
|
+
| `references/indexing-guide.md` | Index types, composite index ordering, when indexes hurt, maintenance |
|
|
275
|
+
| `references/migration-guide.md` | Reversibility rules, zero-downtime patterns, PostgreSQL-specific safety |
|
|
276
|
+
|
|
277
|
+
## Workflows
|
|
278
|
+
|
|
279
|
+
Follow these step-by-step when the user initiates the matching action:
|
|
280
|
+
|
|
281
|
+
| File | When to follow |
|
|
282
|
+
| ----------------------------- | --------------------------------------------------------------------- |
|
|
283
|
+
| `workflows/design-schema.md` | User needs to design a new schema or model entities from requirements |
|
|
284
|
+
| `workflows/optimize-query.md` | User has a slow query and needs diagnosis and a fix |
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# Indexing Guide
|
|
2
|
+
|
|
3
|
+
A practical reference for choosing, designing, and maintaining database indexes — primarily PostgreSQL, with notes for MySQL and MongoDB where behavior differs.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## When Indexes Help
|
|
8
|
+
|
|
9
|
+
An index is only worth its write overhead if it meaningfully reduces the rows the planner must examine. Index when:
|
|
10
|
+
|
|
11
|
+
- A column appears in `WHERE` clauses on large tables
|
|
12
|
+
- A column is used in `JOIN` conditions (foreign keys almost always need indexes)
|
|
13
|
+
- A column drives `ORDER BY` or `GROUP BY` on large result sets
|
|
14
|
+
- A query must enforce `UNIQUE` or `PRIMARY KEY` (indexes are automatic for these)
|
|
15
|
+
- A covering index can eliminate a heap fetch entirely
|
|
16
|
+
|
|
17
|
+
**Rule of thumb:** if a query returns less than ~5% of rows, an index scan is faster than a sequential scan. Above that, the planner may prefer sequential scan even with an index.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Index Types (PostgreSQL)
|
|
22
|
+
|
|
23
|
+
| Type | Operators | Use case |
|
|
24
|
+
| ------- | ---------------------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| B-tree | =, <, <=, >, >=, BETWEEN, LIKE 'prefix%' | Default — general purpose, ORDER BY, range queries |
|
|
26
|
+
| Hash | = only | Equality lookups only; slightly faster than B-tree for = but not maintained across WAL before PG 10 |
|
|
27
|
+
| GIN | @>, <@, &&, @@ | JSONB, arrays, full-text search (tsvector), pg_trgm trigrams |
|
|
28
|
+
| GiST | Geometric, range, PostGIS | Geometric queries, PostGIS geography, fuzzy text (pg_trgm) |
|
|
29
|
+
| BRIN | Range on ordered data | Very large append-only tables (time-series, logs) — tiny index, approximate |
|
|
30
|
+
| SP-GiST | Partitioned non-balanced trees | Points, ranges, network addresses |
|
|
31
|
+
|
|
32
|
+
**When to choose GIN over GiST for text search:**
|
|
33
|
+
|
|
34
|
+
- GIN: faster reads, slower writes, larger index — good for mostly-read data
|
|
35
|
+
- GiST: faster writes, slower reads — good for frequently-updated data
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Composite Indexes
|
|
40
|
+
|
|
41
|
+
Column order in a composite index determines which queries it can serve. The index can serve queries that use a prefix of the column list.
|
|
42
|
+
|
|
43
|
+
```sql
|
|
44
|
+
-- Index on (user_id, status, created_at)
|
|
45
|
+
CREATE INDEX idx_orders_user_status_created ON orders (user_id, status, created_at);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This index can serve:
|
|
49
|
+
|
|
50
|
+
- `WHERE user_id = 1`
|
|
51
|
+
- `WHERE user_id = 1 AND status = 'pending'`
|
|
52
|
+
- `WHERE user_id = 1 AND status = 'pending' AND created_at > '2024-01-01'`
|
|
53
|
+
|
|
54
|
+
This index CANNOT efficiently serve:
|
|
55
|
+
|
|
56
|
+
- `WHERE status = 'pending'` (leading column missing)
|
|
57
|
+
- `WHERE created_at > '2024-01-01'` (leading columns missing)
|
|
58
|
+
|
|
59
|
+
### Column Ordering Rules
|
|
60
|
+
|
|
61
|
+
1. **Equality predicates first** — columns used with `=` before range columns
|
|
62
|
+
2. **Most selective equality column first** — put the column that filters most rows ahead of others
|
|
63
|
+
3. **Range predicates last** — `<`, `>`, `BETWEEN`, `LIKE 'prefix%'`
|
|
64
|
+
4. **ORDER BY columns can follow** — if sort direction matches index direction
|
|
65
|
+
|
|
66
|
+
```sql
|
|
67
|
+
-- Query: WHERE status = 'active' AND created_at > '2024-01-01' ORDER BY created_at
|
|
68
|
+
|
|
69
|
+
-- Good: equality first, then range
|
|
70
|
+
CREATE INDEX idx_users_status_created ON users (status, created_at);
|
|
71
|
+
|
|
72
|
+
-- Bad: range first blocks using the equality column from the index efficiently
|
|
73
|
+
CREATE INDEX idx_users_created_status ON users (created_at, status);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Partial Indexes
|
|
79
|
+
|
|
80
|
+
A partial index indexes only the rows matching a WHERE condition. Smaller index, faster scans, lower write overhead.
|
|
81
|
+
|
|
82
|
+
```sql
|
|
83
|
+
-- Index only active users (not soft-deleted)
|
|
84
|
+
CREATE INDEX idx_users_email_active ON users (email) WHERE deleted_at IS NULL;
|
|
85
|
+
|
|
86
|
+
-- Index only pending orders (status is low-cardinality but subset is small)
|
|
87
|
+
CREATE INDEX idx_orders_pending ON orders (created_at) WHERE status = 'pending';
|
|
88
|
+
|
|
89
|
+
-- Index only unverified emails (temporary state — small subset)
|
|
90
|
+
CREATE INDEX idx_users_unverified ON users (email) WHERE email_verified_at IS NULL;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
The query must include the same WHERE condition for the planner to use the partial index:
|
|
94
|
+
|
|
95
|
+
```sql
|
|
96
|
+
-- Uses the partial index
|
|
97
|
+
SELECT * FROM users WHERE email = $1 AND deleted_at IS NULL;
|
|
98
|
+
|
|
99
|
+
-- Does NOT use the partial index (missing the condition)
|
|
100
|
+
SELECT * FROM users WHERE email = $1;
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Covering Indexes (Index-Only Scans)
|
|
106
|
+
|
|
107
|
+
A covering index includes all columns the query needs, eliminating the heap fetch. This is the fastest possible index path: `Index Only Scan`.
|
|
108
|
+
|
|
109
|
+
```sql
|
|
110
|
+
-- Query: SELECT email, name FROM users WHERE organization_id = $1
|
|
111
|
+
-- Covering index: include both filter and select columns
|
|
112
|
+
CREATE INDEX idx_users_org_covering ON users (organization_id) INCLUDE (email, name);
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Use `INCLUDE` (PostgreSQL 11+) for non-key columns — they're in the leaf pages but not the B-tree structure, so they don't participate in ordering but are available for index-only scans.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## When Indexes Hurt
|
|
120
|
+
|
|
121
|
+
Don't index everything. Indexes have costs:
|
|
122
|
+
|
|
123
|
+
- Every `INSERT`, `UPDATE`, and `DELETE` must update all indexes on the table
|
|
124
|
+
- Indexes consume disk space (sometimes more than the table itself)
|
|
125
|
+
- Too many indexes confuse the query planner — it may choose the wrong one
|
|
126
|
+
- Indexes on low-cardinality columns (boolean, small ENUMs) often aren't used
|
|
127
|
+
|
|
128
|
+
### Low-cardinality columns
|
|
129
|
+
|
|
130
|
+
A boolean column with 90% `true` values: the planner knows a sequential scan is cheaper for `WHERE is_active = true` (90% of rows anyway). An index only helps if:
|
|
131
|
+
|
|
132
|
+
- Combined with other high-cardinality columns in a composite index
|
|
133
|
+
- Used as a partial index condition, not the filter itself
|
|
134
|
+
|
|
135
|
+
```sql
|
|
136
|
+
-- This standalone index often isn't used
|
|
137
|
+
CREATE INDEX idx_users_is_active ON users (is_active); -- low cardinality
|
|
138
|
+
|
|
139
|
+
-- This composite index is useful
|
|
140
|
+
CREATE INDEX idx_orders_status_user ON orders (status, user_id);
|
|
141
|
+
|
|
142
|
+
-- This partial index is useful
|
|
143
|
+
CREATE INDEX idx_orders_pending_created ON orders (created_at) WHERE status = 'pending';
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Non-Blocking Index Creation
|
|
149
|
+
|
|
150
|
+
Never create an index without CONCURRENTLY on a live table. Standard CREATE INDEX takes an ACCESS SHARE lock that blocks writes.
|
|
151
|
+
|
|
152
|
+
```sql
|
|
153
|
+
-- Blocks writes during index build — NEVER use on live tables
|
|
154
|
+
CREATE INDEX idx_orders_user_id ON orders (user_id);
|
|
155
|
+
|
|
156
|
+
-- Non-blocking — takes longer but doesn't block
|
|
157
|
+
CREATE INDEX CONCURRENTLY idx_orders_user_id ON orders (user_id);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
If CONCURRENTLY fails (e.g., transaction issue), it leaves an INVALID index. Clean up:
|
|
161
|
+
|
|
162
|
+
```sql
|
|
163
|
+
-- Check for invalid indexes
|
|
164
|
+
SELECT indexname, indisvalid FROM pg_indexes
|
|
165
|
+
JOIN pg_class ON pg_class.relname = pg_indexes.indexname
|
|
166
|
+
JOIN pg_index ON pg_index.indexrelid = pg_class.oid
|
|
167
|
+
WHERE indisvalid = false;
|
|
168
|
+
|
|
169
|
+
-- Drop and recreate
|
|
170
|
+
DROP INDEX CONCURRENTLY idx_orders_user_id;
|
|
171
|
+
CREATE INDEX CONCURRENTLY idx_orders_user_id ON orders (user_id);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## EXPLAIN ANALYZE Reference
|
|
177
|
+
|
|
178
|
+
```sql
|
|
179
|
+
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) SELECT ...;
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Node Types
|
|
183
|
+
|
|
184
|
+
| Node | Meaning |
|
|
185
|
+
| ----------------- | ---------------------------------------------------------------------------------------------- |
|
|
186
|
+
| Seq Scan | Full table scan. Fine for small tables; add an index if table is large and filter is selective |
|
|
187
|
+
| Index Scan | Index lookup, then heap fetch for each matching row |
|
|
188
|
+
| Index Only Scan | Covering index — no heap fetch. Best possible for point lookups |
|
|
189
|
+
| Bitmap Index Scan | Builds a bitmap of matching pages, then bulk-fetches (efficient for range) |
|
|
190
|
+
| Bitmap Heap Scan | Fetches pages identified by bitmap — paired with Bitmap Index Scan |
|
|
191
|
+
| Nested Loop | Outer loop drives inner — fine for small row counts on outer side |
|
|
192
|
+
| Hash Join | Hashes smaller table in memory, probes with larger — good default |
|
|
193
|
+
| Merge Join | Sorts both inputs, merges — efficient when both inputs already sorted |
|
|
194
|
+
| Sort | Explicit sort node — see if an index could eliminate it |
|
|
195
|
+
| Hash | Builds an in-memory hash table |
|
|
196
|
+
|
|
197
|
+
### Reading Cost and Rows
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
-> Index Scan using idx_orders_user_id on orders
|
|
201
|
+
(cost=0.43..8.45 rows=1 width=128)
|
|
202
|
+
(actual time=0.032..0.033 rows=1 loops=1)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
- `cost=0.43..8.45`: planner's estimated cost (startup..total) in arbitrary units
|
|
206
|
+
- `rows=1`: planner's row estimate
|
|
207
|
+
- `actual time=0.032..0.033`: real execution time in ms (startup..total)
|
|
208
|
+
- `actual rows=1`: real rows returned
|
|
209
|
+
- `loops=1`: how many times this node ran
|
|
210
|
+
|
|
211
|
+
**Stale statistics warning:** if `actual rows` >> `rows` estimate by 10x or more, run `ANALYZE table_name` to update statistics. The planner makes poor choices with stale stats.
|
|
212
|
+
|
|
213
|
+
### BUFFERS output
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
Buffers: shared hit=142 read=18 dirtied=0 written=0
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
- `hit`: pages found in shared_buffers (fast)
|
|
220
|
+
- `read`: pages read from disk (slow — consider more shared_buffers or caching)
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## Index Maintenance
|
|
225
|
+
|
|
226
|
+
### Finding Unused Indexes
|
|
227
|
+
|
|
228
|
+
```sql
|
|
229
|
+
SELECT
|
|
230
|
+
schemaname,
|
|
231
|
+
tablename,
|
|
232
|
+
indexname,
|
|
233
|
+
idx_scan AS scans,
|
|
234
|
+
pg_size_pretty(pg_relation_size(indexrelid)) AS index_size
|
|
235
|
+
FROM pg_stat_user_indexes
|
|
236
|
+
WHERE idx_scan < 50 -- threshold — adjust to your traffic
|
|
237
|
+
AND indexrelname NOT LIKE '%pkey'
|
|
238
|
+
AND indexrelname NOT LIKE '%unique'
|
|
239
|
+
ORDER BY pg_relation_size(indexrelid) DESC;
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Drop unused indexes after confirming they're truly unused (reset stats after major deployments: `SELECT pg_stat_reset();`).
|
|
243
|
+
|
|
244
|
+
### Finding Tables Doing Excessive Sequential Scans
|
|
245
|
+
|
|
246
|
+
```sql
|
|
247
|
+
SELECT
|
|
248
|
+
relname AS table_name,
|
|
249
|
+
seq_scan,
|
|
250
|
+
seq_tup_read,
|
|
251
|
+
idx_scan,
|
|
252
|
+
n_live_tup AS row_count,
|
|
253
|
+
pg_size_pretty(pg_total_relation_size(relid)) AS total_size
|
|
254
|
+
FROM pg_stat_user_tables
|
|
255
|
+
WHERE seq_scan > idx_scan
|
|
256
|
+
AND n_live_tup > 10000 -- only large tables worth indexing
|
|
257
|
+
ORDER BY seq_tup_read DESC;
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Rebuilding Bloated Indexes
|
|
261
|
+
|
|
262
|
+
Over time, B-tree indexes accumulate dead tuples (bloat) from updates and deletes. Rebuild without blocking:
|
|
263
|
+
|
|
264
|
+
```sql
|
|
265
|
+
REINDEX INDEX CONCURRENTLY idx_orders_user_id;
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Or recreate with a swap (safer for very large indexes):
|
|
269
|
+
|
|
270
|
+
```sql
|
|
271
|
+
CREATE INDEX CONCURRENTLY idx_orders_user_id_new ON orders (user_id);
|
|
272
|
+
-- verify new index is valid
|
|
273
|
+
DROP INDEX CONCURRENTLY idx_orders_user_id;
|
|
274
|
+
ALTER INDEX idx_orders_user_id_new RENAME TO idx_orders_user_id;
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Updating Statistics
|
|
278
|
+
|
|
279
|
+
After bulk data loads or large deletes:
|
|
280
|
+
|
|
281
|
+
```sql
|
|
282
|
+
ANALYZE orders; -- update stats for one table
|
|
283
|
+
ANALYZE; -- update stats for all tables (runs quickly, non-blocking)
|
|
284
|
+
VACUUM ANALYZE orders; -- reclaim dead tuples + update stats
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## MySQL Notes
|
|
290
|
+
|
|
291
|
+
MySQL (InnoDB) index behavior differs from PostgreSQL in key ways:
|
|
292
|
+
|
|
293
|
+
- Clustered index: the primary key IS the table in InnoDB — secondary indexes contain the PK value as the row pointer
|
|
294
|
+
- Covering index: use `EXPLAIN` and look for `Using index` in the Extra column
|
|
295
|
+
- No `CONCURRENTLY`: use `pt-online-schema-change` or `gh-ost` for large table index changes
|
|
296
|
+
- FULLTEXT index: MySQL's built-in full-text search — different from PostgreSQL's `tsvector` approach
|
|
297
|
+
- Hash indexes: only in MEMORY engine — InnoDB uses adaptive hash index internally, not user-configurable
|
|
298
|
+
- Foreign key indexes: MySQL requires an index on the FK column; it creates one automatically if missing
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## Quick Reference
|
|
303
|
+
|
|
304
|
+
| Scenario | Index to create |
|
|
305
|
+
| ---------------------------------------------- | ------------------------------------------------------------- |
|
|
306
|
+
| `WHERE user_id = $1` | `(user_id)` |
|
|
307
|
+
| `WHERE user_id = $1 AND status = 'active'` | `(user_id, status)` — equality both, put more selective first |
|
|
308
|
+
| `WHERE status = 'pending' ORDER BY created_at` | `(status, created_at)` |
|
|
309
|
+
| `WHERE deleted_at IS NULL AND email = $1` | `(email) WHERE deleted_at IS NULL` (partial) |
|
|
310
|
+
| `SELECT id, name FROM users WHERE org_id = $1` | `(org_id) INCLUDE (name)` (covering) |
|
|
311
|
+
| `WHERE payload @> '{"type": "login"}'` (JSONB) | `USING GIN (payload)` |
|
|
312
|
+
| Full-text: `WHERE to_tsvector(body) @@ query` | `USING GIN (to_tsvector('english', body))` |
|
|
313
|
+
| Unique email | `CREATE UNIQUE INDEX` (or `UNIQUE` constraint — same thing) |
|