cfsa-antigravity 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.mjs +324 -0
- package/package.json +34 -0
- package/template/.agent/instructions/commands.md +48 -0
- package/template/.agent/instructions/patterns.md +61 -0
- package/template/.agent/instructions/structure.md +29 -0
- package/template/.agent/instructions/tech-stack.md +43 -0
- package/template/.agent/instructions/workflow.md +41 -0
- package/template/.agent/kit-sync.md +15 -0
- package/template/.agent/rules/boundary-not-placeholder.md +146 -0
- package/template/.agent/rules/completion-checklist.md +48 -0
- package/template/.agent/rules/decision-classification.md +103 -0
- package/template/.agent/rules/extensibility.md +47 -0
- package/template/.agent/rules/question-vs-command.md +81 -0
- package/template/.agent/rules/security-first.md +43 -0
- package/template/.agent/rules/specificity-standards.md +54 -0
- package/template/.agent/rules/tdd-contract-first.md +57 -0
- package/template/.agent/rules/vertical-slices.md +42 -0
- package/template/.agent/skill-library/MANIFEST.md +480 -0
- package/template/.agent/skill-library/README.md +38 -0
- package/template/.agent/skill-library/meta/brand-guidelines/SKILL.md +73 -0
- package/template/.agent/skill-library/meta/claude-code/README.md +9 -0
- package/template/.agent/skill-library/meta/claude-code/agent-development/SKILL.md +415 -0
- package/template/.agent/skill-library/meta/claude-code/hook-development/SKILL.md +712 -0
- package/template/.agent/skill-library/meta/claude-code/plugin-structure/SKILL.md +476 -0
- package/template/.agent/skill-library/meta/git-advanced/SKILL.md +972 -0
- package/template/.agent/skill-library/meta/mcp-builder/SKILL.md +236 -0
- package/template/.agent/skill-library/meta/product-marketing-context/SKILL.md +241 -0
- package/template/.agent/skill-library/meta/regex-patterns/SKILL.md +751 -0
- package/template/.agent/skill-library/meta/tmux-processes/SKILL.md +210 -0
- package/template/.agent/skill-library/meta/using-tmux-for-interactive-commands/SKILL.md +178 -0
- package/template/.agent/skill-library/stack/3d/threejs-pro/SKILL.md +300 -0
- package/template/.agent/skill-library/stack/ai/ai-sdk/SKILL.md +77 -0
- package/template/.agent/skill-library/stack/ai/langchain/SKILL.md +530 -0
- package/template/.agent/skill-library/stack/ai/ollama/SKILL.md +321 -0
- package/template/.agent/skill-library/stack/ai/openai-sdk/SKILL.md +549 -0
- package/template/.agent/skill-library/stack/analytics/google-analytics/SKILL.md +153 -0
- package/template/.agent/skill-library/stack/api/graphql/SKILL.md +1061 -0
- package/template/.agent/skill-library/stack/api/trpc/SKILL.md +576 -0
- package/template/.agent/skill-library/stack/auth/authjs/SKILL.md +569 -0
- package/template/.agent/skill-library/stack/auth/clerk/SKILL.md +590 -0
- package/template/.agent/skill-library/stack/auth/firebase-auth/SKILL.md +734 -0
- package/template/.agent/skill-library/stack/cms/payload-cms/SKILL.md +573 -0
- package/template/.agent/skill-library/stack/cms/shopify/SKILL.md +1193 -0
- package/template/.agent/skill-library/stack/cms/wordpress/SKILL.md +1104 -0
- package/template/.agent/skill-library/stack/css/sass-scss/SKILL.md +1121 -0
- package/template/.agent/skill-library/stack/css/tailwind-css-patterns/SKILL.md +863 -0
- package/template/.agent/skill-library/stack/css/tailwind-design-system/SKILL.md +490 -0
- package/template/.agent/skill-library/stack/css/vanilla-css/SKILL.md +1078 -0
- package/template/.agent/skill-library/stack/databases/clickhouse/SKILL.md +311 -0
- package/template/.agent/skill-library/stack/databases/influxdb/SKILL.md +280 -0
- package/template/.agent/skill-library/stack/databases/lancedb/SKILL.md +415 -0
- package/template/.agent/skill-library/stack/databases/mongodb/SKILL.md +1169 -0
- package/template/.agent/skill-library/stack/databases/neo4j/SKILL.md +839 -0
- package/template/.agent/skill-library/stack/databases/pgvector/SKILL.md +241 -0
- package/template/.agent/skill-library/stack/databases/pinecone/SKILL.md +212 -0
- package/template/.agent/skill-library/stack/databases/postgresql/SKILL.md +658 -0
- package/template/.agent/skill-library/stack/databases/qdrant/SKILL.md +312 -0
- package/template/.agent/skill-library/stack/databases/redis/SKILL.md +1079 -0
- package/template/.agent/skill-library/stack/databases/spacetimedb/SKILL.md +532 -0
- package/template/.agent/skill-library/stack/databases/sqlite/SKILL.md +1132 -0
- package/template/.agent/skill-library/stack/databases/supabase/SKILL.md +640 -0
- package/template/.agent/skill-library/stack/databases/surrealdb-expert/SKILL.md +945 -0
- package/template/.agent/skill-library/stack/databases/timescaledb/SKILL.md +745 -0
- package/template/.agent/skill-library/stack/databases/weaviate/SKILL.md +218 -0
- package/template/.agent/skill-library/stack/devops/github-actions/SKILL.md +554 -0
- package/template/.agent/skill-library/stack/devops/kubernetes/SKILL.md +950 -0
- package/template/.agent/skill-library/stack/devops/nginx/SKILL.md +841 -0
- package/template/.agent/skill-library/stack/devops/terraform/SKILL.md +860 -0
- package/template/.agent/skill-library/stack/email/resend/SKILL.md +391 -0
- package/template/.agent/skill-library/stack/engines/godot/SKILL.md +488 -0
- package/template/.agent/skill-library/stack/extensions/chrome-extension/SKILL.md +375 -0
- package/template/.agent/skill-library/stack/extensions/vscode-extension/SKILL.md +453 -0
- package/template/.agent/skill-library/stack/frameworks/astro-framework/SKILL.md +162 -0
- package/template/.agent/skill-library/stack/frameworks/electron/SKILL.md +1286 -0
- package/template/.agent/skill-library/stack/frameworks/fastapi/SKILL.md +650 -0
- package/template/.agent/skill-library/stack/frameworks/hono/SKILL.md +90 -0
- package/template/.agent/skill-library/stack/frameworks/nestjs/SKILL.md +878 -0
- package/template/.agent/skill-library/stack/frameworks/nextjs/SKILL.md +635 -0
- package/template/.agent/skill-library/stack/frameworks/nuxt/SKILL.md +564 -0
- package/template/.agent/skill-library/stack/frameworks/sveltekit/SKILL.md +614 -0
- package/template/.agent/skill-library/stack/frameworks/tauri/SKILL.md +920 -0
- package/template/.agent/skill-library/stack/gamedev/godot/SKILL.md +1032 -0
- package/template/.agent/skill-library/stack/gamedev/unity/SKILL.md +1175 -0
- package/template/.agent/skill-library/stack/hosting/aws/SKILL.md +467 -0
- package/template/.agent/skill-library/stack/hosting/cloudflare/SKILL.md +201 -0
- package/template/.agent/skill-library/stack/hosting/docker-expert/SKILL.md +409 -0
- package/template/.agent/skill-library/stack/hosting/vercel/SKILL.md +484 -0
- package/template/.agent/skill-library/stack/languages/bash-scripting/SKILL.md +773 -0
- package/template/.agent/skill-library/stack/languages/c-cpp/SKILL.md +712 -0
- package/template/.agent/skill-library/stack/languages/gdscript/SKILL.md +789 -0
- package/template/.agent/skill-library/stack/languages/go/SKILL.md +664 -0
- package/template/.agent/skill-library/stack/languages/java/SKILL.md +778 -0
- package/template/.agent/skill-library/stack/languages/kotlin/SKILL.md +665 -0
- package/template/.agent/skill-library/stack/languages/python/SKILL.md +678 -0
- package/template/.agent/skill-library/stack/languages/rust/SKILL.md +673 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/SKILL.md +141 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/advanced-generics.md +90 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/branded-types.md +57 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/builder-pattern.md +71 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/common-pitfalls.md +135 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/conditional-types.md +27 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/decorators.md +98 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/discriminated-unions.md +62 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/mapped-types.md +53 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/performance-best-practices.md +104 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/template-literal-types.md +49 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/testing-types.md +112 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/type-guards.md +70 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/type-inference.md +101 -0
- package/template/.agent/skill-library/stack/languages/typescript-advanced-patterns/references/utility-types.md +98 -0
- package/template/.agent/skill-library/stack/languages/vanilla-javascript/SKILL.md +803 -0
- package/template/.agent/skill-library/stack/messaging/kafka/SKILL.md +235 -0
- package/template/.agent/skill-library/stack/mobile/expo-react-native/SKILL.md +665 -0
- package/template/.agent/skill-library/stack/mobile/flutter/SKILL.md +316 -0
- package/template/.agent/skill-library/stack/mobile/react-native/SKILL.md +337 -0
- package/template/.agent/skill-library/stack/monitoring/posthog/SKILL.md +396 -0
- package/template/.agent/skill-library/stack/monitoring/sentry/SKILL.md +509 -0
- package/template/.agent/skill-library/stack/observability/datadog/SKILL.md +179 -0
- package/template/.agent/skill-library/stack/observability/distributed-tracing/SKILL.md +140 -0
- package/template/.agent/skill-library/stack/observability/logging-best-practices/SKILL.md +168 -0
- package/template/.agent/skill-library/stack/observability/opentelemetry/SKILL.md +164 -0
- package/template/.agent/skill-library/stack/observability/prometheus-grafana/SKILL.md +246 -0
- package/template/.agent/skill-library/stack/observability/python-observability/SKILL.md +158 -0
- package/template/.agent/skill-library/stack/orm/drizzle-orm/SKILL.md +613 -0
- package/template/.agent/skill-library/stack/orm/prisma/SKILL.md +744 -0
- package/template/.agent/skill-library/stack/payments/lemonsqueezy/SKILL.md +393 -0
- package/template/.agent/skill-library/stack/payments/stripe-integration/SKILL.md +457 -0
- package/template/.agent/skill-library/stack/queue/bullmq/SKILL.md +385 -0
- package/template/.agent/skill-library/stack/queue/inngest/SKILL.md +438 -0
- package/template/.agent/skill-library/stack/realtime/socketio/SKILL.md +595 -0
- package/template/.agent/skill-library/stack/search/elasticsearch/SKILL.md +248 -0
- package/template/.agent/skill-library/stack/search/meilisearch/SKILL.md +385 -0
- package/template/.agent/skill-library/stack/security/crypto-patterns/SKILL.md +437 -0
- package/template/.agent/skill-library/stack/security/csp-cors-headers/SKILL.md +588 -0
- package/template/.agent/skill-library/stack/security/dependency-auditing/SKILL.md +560 -0
- package/template/.agent/skill-library/stack/security/input-sanitization/SKILL.md +430 -0
- package/template/.agent/skill-library/stack/security/owasp-web-security/SKILL.md +421 -0
- package/template/.agent/skill-library/stack/state/tanstack-query/SKILL.md +637 -0
- package/template/.agent/skill-library/stack/state/zustand/SKILL.md +483 -0
- package/template/.agent/skill-library/stack/storage/aws-s3/SKILL.md +415 -0
- package/template/.agent/skill-library/stack/testing/playwright/SKILL.md +641 -0
- package/template/.agent/skill-library/stack/testing/storybook/SKILL.md +923 -0
- package/template/.agent/skill-library/stack/testing/testing-library/SKILL.md +872 -0
- package/template/.agent/skill-library/stack/testing/vitest/SKILL.md +714 -0
- package/template/.agent/skill-library/stack/ui/react-best-practices/SKILL.md +877 -0
- package/template/.agent/skill-library/stack/ui/react-composition-patterns/SKILL.md +1107 -0
- package/template/.agent/skill-library/stack/ui/react-flow/SKILL.md +425 -0
- package/template/.agent/skill-library/stack/ui/shadcn-ui/SKILL.md +703 -0
- package/template/.agent/skill-library/surface/api/api-caching/SKILL.md +458 -0
- package/template/.agent/skill-library/surface/api/api-documentation-openapi/SKILL.md +697 -0
- package/template/.agent/skill-library/surface/api/api-error-handling/SKILL.md +478 -0
- package/template/.agent/skill-library/surface/api/api-security-checklist/SKILL.md +147 -0
- package/template/.agent/skill-library/surface/api/api-versioning/SKILL.md +420 -0
- package/template/.agent/skill-library/surface/api/email-best-practices/SKILL.md +59 -0
- package/template/.agent/skill-library/surface/api/rate-limiting-abuse-protection/SKILL.md +147 -0
- package/template/.agent/skill-library/surface/api/rest-api-design/SKILL.md +478 -0
- package/template/.agent/skill-library/surface/api/webhook-design/SKILL.md +752 -0
- package/template/.agent/skill-library/surface/cli/cli-configuration-management/SKILL.md +445 -0
- package/template/.agent/skill-library/surface/cli/cli-error-diagnostics/SKILL.md +515 -0
- package/template/.agent/skill-library/surface/cli/cli-shell-integration/SKILL.md +479 -0
- package/template/.agent/skill-library/surface/cli/cli-ux-design/SKILL.md +477 -0
- package/template/.agent/skill-library/surface/desktop/desktop-app-distribution/SKILL.md +416 -0
- package/template/.agent/skill-library/surface/desktop/desktop-security-sandboxing/SKILL.md +407 -0
- package/template/.agent/skill-library/surface/desktop/desktop-ux-conventions/SKILL.md +361 -0
- package/template/.agent/skill-library/surface/desktop/native-os-integration/SKILL.md +563 -0
- package/template/.agent/skill-library/surface/extension/browser-extension-patterns/SKILL.md +482 -0
- package/template/.agent/skill-library/surface/extension/plugin-architecture-design/SKILL.md +632 -0
- package/template/.agent/skill-library/surface/extension/vscode-extension-development/SKILL.md +728 -0
- package/template/.agent/skill-library/surface/mobile/app-store-submission/SKILL.md +304 -0
- package/template/.agent/skill-library/surface/mobile/mobile-offline-sync/SKILL.md +443 -0
- package/template/.agent/skill-library/surface/mobile/mobile-responsive-patterns/SKILL.md +432 -0
- package/template/.agent/skill-library/surface/mobile/push-notifications/SKILL.md +495 -0
- package/template/.agent/skill-library/surface/web/accessibility-compliance/SKILL.md +827 -0
- package/template/.agent/skill-library/surface/web/ai-seo/SKILL.md +398 -0
- package/template/.agent/skill-library/surface/web/ai-seo/references/content-patterns.md +285 -0
- package/template/.agent/skill-library/surface/web/ai-seo/references/platform-ranking-factors.md +152 -0
- package/template/.agent/skill-library/surface/web/analytics-tracking/SKILL.md +309 -0
- package/template/.agent/skill-library/surface/web/analytics-tracking/references/event-library.md +260 -0
- package/template/.agent/skill-library/surface/web/analytics-tracking/references/ga4-implementation.md +300 -0
- package/template/.agent/skill-library/surface/web/analytics-tracking/references/gtm-implementation.md +390 -0
- package/template/.agent/skill-library/surface/web/authentication-ui-flows/SKILL.md +530 -0
- package/template/.agent/skill-library/surface/web/dark-mode-theming/SKILL.md +516 -0
- package/template/.agent/skill-library/surface/web/design-reference-data/SKILL.md +105 -0
- package/template/.agent/skill-library/surface/web/design-reference-data/data/charts.csv +26 -0
- package/template/.agent/skill-library/surface/web/design-reference-data/data/colors.csv +97 -0
- package/template/.agent/skill-library/surface/web/design-reference-data/data/landing.csv +31 -0
- package/template/.agent/skill-library/surface/web/design-reference-data/data/styles.csv +59 -0
- package/template/.agent/skill-library/surface/web/design-reference-data/data/typography.csv +58 -0
- package/template/.agent/skill-library/surface/web/design-reference-data/data/ux-guidelines.csv +100 -0
- package/template/.agent/skill-library/surface/web/design-reference-data/scripts/core.py +258 -0
- package/template/.agent/skill-library/surface/web/design-reference-data/scripts/design_system.py +1067 -0
- package/template/.agent/skill-library/surface/web/design-reference-data/scripts/search.py +106 -0
- package/template/.agent/skill-library/surface/web/form-handling-validation/SKILL.md +675 -0
- package/template/.agent/skill-library/surface/web/frontend-design/SKILL.md +1393 -0
- package/template/.agent/skill-library/surface/web/frontend-design/templates/cppn-hero.tsx +299 -0
- package/template/.agent/skill-library/surface/web/frontend-design/templates/wave-hero.tsx +875 -0
- package/template/.agent/skill-library/surface/web/frontend-verification/SKILL.md +111 -0
- package/template/.agent/skill-library/surface/web/frontend-verification/scripts/ux_audit.py +739 -0
- package/template/.agent/skill-library/surface/web/i18n-localization/SKILL.md +154 -0
- package/template/.agent/skill-library/surface/web/offline-first-pwa/SKILL.md +657 -0
- package/template/.agent/skill-library/surface/web/page-cro/SKILL.md +182 -0
- package/template/.agent/skill-library/surface/web/page-cro/references/experiments.md +248 -0
- package/template/.agent/skill-library/surface/web/programmatic-seo/SKILL.md +238 -0
- package/template/.agent/skill-library/surface/web/programmatic-seo/references/playbooks.md +308 -0
- package/template/.agent/skill-library/surface/web/schema-markup/SKILL.md +179 -0
- package/template/.agent/skill-library/surface/web/schema-markup/references/schema-examples.md +398 -0
- package/template/.agent/skill-library/surface/web/seo-audit/SKILL.md +394 -0
- package/template/.agent/skill-library/surface/web/seo-audit/references/ai-writing-detection.md +200 -0
- package/template/.agent/skill-library/surface/web/web-performance-optimization/SKILL.md +646 -0
- package/template/.agent/skill-library/surface/web/web-scraping/SKILL.md +58 -0
- package/template/.agent/skills/accessibility/SKILL.md +522 -0
- package/template/.agent/skills/accessibility/references/WCAG.md +162 -0
- package/template/.agent/skills/adversarial-review/SKILL.md +90 -0
- package/template/.agent/skills/antigravity-workflows/SKILL.md +81 -0
- package/template/.agent/skills/antigravity-workflows/resources/implementation-playbook.md +36 -0
- package/template/.agent/skills/api-design-principles/SKILL.md +37 -0
- package/template/.agent/skills/api-design-principles/assets/api-design-checklist.md +155 -0
- package/template/.agent/skills/api-design-principles/assets/rest-api-template.py +182 -0
- package/template/.agent/skills/api-design-principles/references/graphql-schema-design.md +583 -0
- package/template/.agent/skills/api-design-principles/references/rest-best-practices.md +408 -0
- package/template/.agent/skills/api-design-principles/resources/implementation-playbook.md +513 -0
- package/template/.agent/skills/api-versioning/SKILL.md +420 -0
- package/template/.agent/skills/architecture-mapping/SKILL.md +219 -0
- package/template/.agent/skills/bootstrap-agents/SKILL.md +259 -0
- package/template/.agent/skills/brainstorming/SKILL.md +236 -0
- package/template/.agent/skills/brand-guidelines/SKILL.md +44 -0
- package/template/.agent/skills/clean-code/SKILL.md +94 -0
- package/template/.agent/skills/code-review-pro/SKILL.md +152 -0
- package/template/.agent/skills/concise-planning/SKILL.md +68 -0
- package/template/.agent/skills/cross-layer-consistency/SKILL.md +117 -0
- package/template/.agent/skills/database-schema-design/SKILL.md +429 -0
- package/template/.agent/skills/deployment-procedures/SKILL.md +241 -0
- package/template/.agent/skills/design-anti-cliche/SKILL.md +159 -0
- package/template/.agent/skills/design-direction/SKILL.md +45 -0
- package/template/.agent/skills/error-handling-patterns/SKILL.md +721 -0
- package/template/.agent/skills/find-skills/SKILL.md +145 -0
- package/template/.agent/skills/git-advanced/SKILL.md +972 -0
- package/template/.agent/skills/git-workflow/SKILL.md +420 -0
- package/template/.agent/skills/idea-extraction/SKILL.md +271 -0
- package/template/.agent/skills/logging-best-practices/SKILL.md +851 -0
- package/template/.agent/skills/migration-management/SKILL.md +384 -0
- package/template/.agent/skills/minimalist-surgical-development/SKILL.md +69 -0
- package/template/.agent/skills/parallel-agents/SKILL.md +165 -0
- package/template/.agent/skills/parallel-debugging/SKILL.md +135 -0
- package/template/.agent/skills/parallel-feature-development/SKILL.md +166 -0
- package/template/.agent/skills/performance-budgeting/SKILL.md +144 -0
- package/template/.agent/skills/pipeline-rubrics/SKILL.md +51 -0
- package/template/.agent/skills/pipeline-rubrics/references/architecture-rubric.md +19 -0
- package/template/.agent/skills/pipeline-rubrics/references/be-rubric.md +21 -0
- package/template/.agent/skills/pipeline-rubrics/references/fe-rubric.md +20 -0
- package/template/.agent/skills/pipeline-rubrics/references/ia-rubric.md +19 -0
- package/template/.agent/skills/pipeline-rubrics/references/scoring.md +28 -0
- package/template/.agent/skills/pipeline-rubrics/references/vision-rubric.md +11 -0
- package/template/.agent/skills/prd-templates/SKILL.md +88 -0
- package/template/.agent/skills/prd-templates/references/architecture-design-template.md +88 -0
- package/template/.agent/skills/prd-templates/references/be-spec-template.md +101 -0
- package/template/.agent/skills/prd-templates/references/data-placement-template.md +74 -0
- package/template/.agent/skills/prd-templates/references/decomposition-templates.md +211 -0
- package/template/.agent/skills/prd-templates/references/design-system-decisions.md +198 -0
- package/template/.agent/skills/prd-templates/references/engineering-standards-template.md +124 -0
- package/template/.agent/skills/prd-templates/references/fe-classification-procedures.md +47 -0
- package/template/.agent/skills/prd-templates/references/fe-spec-template.md +84 -0
- package/template/.agent/skills/prd-templates/references/infrastructure-report-template.md +71 -0
- package/template/.agent/skills/prd-templates/references/operational-templates.md +116 -0
- package/template/.agent/skills/prd-templates/references/placeholder-guard-template.md +21 -0
- package/template/.agent/skills/prd-templates/references/surface-model.md +61 -0
- package/template/.agent/skills/prd-templates/references/vision-template.md +66 -0
- package/template/.agent/skills/prompt-engineer/README.md +659 -0
- package/template/.agent/skills/prompt-engineer/SKILL.md +249 -0
- package/template/.agent/skills/regex-patterns/SKILL.md +751 -0
- package/template/.agent/skills/resolve-ambiguity/SKILL.md +278 -0
- package/template/.agent/skills/rest-api-design/SKILL.md +478 -0
- package/template/.agent/skills/security-scanning-security-hardening/SKILL.md +231 -0
- package/template/.agent/skills/session-continuity/SKILL.md +730 -0
- package/template/.agent/skills/session-continuity/protocols/01-session-resumption.md +38 -0
- package/template/.agent/skills/session-continuity/protocols/02-progress-generation.md +85 -0
- package/template/.agent/skills/session-continuity/protocols/03-progress-update.md +70 -0
- package/template/.agent/skills/session-continuity/protocols/04-pattern-extraction.md +60 -0
- package/template/.agent/skills/session-continuity/protocols/05-session-close.md +37 -0
- package/template/.agent/skills/session-continuity/protocols/06-decision-analysis.md +84 -0
- package/template/.agent/skills/session-continuity/protocols/07-spec-pipeline-generation.md +48 -0
- package/template/.agent/skills/session-continuity/protocols/08-spec-pipeline-update.md +43 -0
- package/template/.agent/skills/session-continuity/protocols/09-parallel-claim.md +122 -0
- package/template/.agent/skills/session-continuity/protocols/10-placeholder-verification-gate.md +104 -0
- package/template/.agent/skills/session-continuity/protocols/ambiguity-gates.md +48 -0
- package/template/.agent/skills/skill-creator/LICENSE.txt +202 -0
- package/template/.agent/skills/skill-creator/README.md +270 -0
- package/template/.agent/skills/skill-creator/SKILL.md +590 -0
- package/template/.agent/skills/skill-creator/references/output-patterns.md +82 -0
- package/template/.agent/skills/skill-creator/references/workflows.md +28 -0
- package/template/.agent/skills/skill-creator/scripts/init_skill.py +303 -0
- package/template/.agent/skills/skill-creator/scripts/package_skill.py +110 -0
- package/template/.agent/skills/skill-creator/scripts/quick_validate.py +95 -0
- package/template/.agent/skills/spec-writing/SKILL.md +110 -0
- package/template/.agent/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/template/.agent/skills/systematic-debugging/SKILL.md +297 -0
- package/template/.agent/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/template/.agent/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/template/.agent/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/template/.agent/skills/systematic-debugging/find-polluter.sh +63 -0
- package/template/.agent/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/template/.agent/skills/systematic-debugging/test-academic.md +14 -0
- package/template/.agent/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/template/.agent/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/template/.agent/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/template/.agent/skills/tdd-workflow/SKILL.md +409 -0
- package/template/.agent/skills/tech-stack-catalog/SKILL.md +49 -0
- package/template/.agent/skills/tech-stack-catalog/references/constraint-questions.md +21 -0
- package/template/.agent/skills/tech-stack-catalog/references/dev-tooling-decisions.md +37 -0
- package/template/.agent/skills/tech-stack-catalog/references/surface-decision-tables.md +69 -0
- package/template/.agent/skills/technical-writer/SKILL.md +242 -0
- package/template/.agent/skills/testing-strategist/SKILL.md +932 -0
- package/template/.agent/skills/verification-before-completion/SKILL.md +145 -0
- package/template/.agent/skills/workflow-automation/SKILL.md +73 -0
- package/template/.agent/workflows/audit-ambiguity-execute.md +165 -0
- package/template/.agent/workflows/audit-ambiguity-rubrics.md +83 -0
- package/template/.agent/workflows/audit-ambiguity.md +64 -0
- package/template/.agent/workflows/bootstrap-agents-fill.md +201 -0
- package/template/.agent/workflows/bootstrap-agents-provision.md +197 -0
- package/template/.agent/workflows/bootstrap-agents.md +66 -0
- package/template/.agent/workflows/create-prd-architecture.md +119 -0
- package/template/.agent/workflows/create-prd-compile.md +138 -0
- package/template/.agent/workflows/create-prd-design-system.md +135 -0
- package/template/.agent/workflows/create-prd-security.md +113 -0
- package/template/.agent/workflows/create-prd-stack.md +91 -0
- package/template/.agent/workflows/create-prd.md +168 -0
- package/template/.agent/workflows/decompose-architecture-structure.md +82 -0
- package/template/.agent/workflows/decompose-architecture-validate.md +119 -0
- package/template/.agent/workflows/decompose-architecture.md +111 -0
- package/template/.agent/workflows/evolve-contract.md +98 -0
- package/template/.agent/workflows/evolve-feature-cascade.md +140 -0
- package/template/.agent/workflows/evolve-feature-classify.md +116 -0
- package/template/.agent/workflows/evolve-feature.md +56 -0
- package/template/.agent/workflows/ideate-discover.md +144 -0
- package/template/.agent/workflows/ideate-extract.md +129 -0
- package/template/.agent/workflows/ideate-validate.md +117 -0
- package/template/.agent/workflows/ideate.md +113 -0
- package/template/.agent/workflows/implement-slice-setup.md +113 -0
- package/template/.agent/workflows/implement-slice-tdd.md +198 -0
- package/template/.agent/workflows/implement-slice.md +50 -0
- package/template/.agent/workflows/plan-phase.md +202 -0
- package/template/.agent/workflows/propagate-decision-apply.md +135 -0
- package/template/.agent/workflows/propagate-decision-scan.md +147 -0
- package/template/.agent/workflows/propagate-decision.md +56 -0
- package/template/.agent/workflows/remediate-pipeline-assess.md +138 -0
- package/template/.agent/workflows/remediate-pipeline-execute.md +135 -0
- package/template/.agent/workflows/remediate-pipeline.md +55 -0
- package/template/.agent/workflows/resolve-ambiguity.md +82 -0
- package/template/.agent/workflows/sync-kit.md +209 -0
- package/template/.agent/workflows/update-architecture-map.md +74 -0
- package/template/.agent/workflows/validate-phase.md +219 -0
- package/template/.agent/workflows/verify-infrastructure.md +207 -0
- package/template/.agent/workflows/write-architecture-spec-deepen.md +139 -0
- package/template/.agent/workflows/write-architecture-spec-design.md +202 -0
- package/template/.agent/workflows/write-architecture-spec.md +63 -0
- package/template/.agent/workflows/write-be-spec-classify.md +165 -0
- package/template/.agent/workflows/write-be-spec-write.md +98 -0
- package/template/.agent/workflows/write-be-spec.md +76 -0
- package/template/.agent/workflows/write-fe-spec-classify.md +170 -0
- package/template/.agent/workflows/write-fe-spec-write.md +94 -0
- package/template/.agent/workflows/write-fe-spec.md +71 -0
- package/template/AGENTS.md +176 -0
- package/template/GEMINI.md +177 -0
- package/template/docs/README.md +187 -0
- package/template/docs/audits/.gitkeep +0 -0
- package/template/docs/audits/README.md +10 -0
- package/template/docs/plans/.gitkeep +0 -0
- package/template/docs/plans/README.md +21 -0
- package/template/docs/plans/be/.gitkeep +0 -0
- package/template/docs/plans/be/README.md +11 -0
- package/template/docs/plans/fe/.gitkeep +0 -0
- package/template/docs/plans/fe/README.md +11 -0
- package/template/docs/plans/ia/.gitkeep +0 -0
- package/template/docs/plans/ia/README.md +17 -0
- package/template/docs/plans/ia/deep-dives/.gitkeep +0 -0
- package/template/docs/plans/ia/deep-dives/README.md +5 -0
- package/template/docs/plans/phases/.gitkeep +0 -0
- package/template/docs/plans/phases/README.md +11 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: clickhouse
|
|
3
|
+
description: "Expert ClickHouse guide covering schema design (ORDER BY planning, column cardinality ordering, LowCardinality, Nullable avoidance, partitioning), query optimization (JOIN algorithms, dictionaries vs denormalization, skipping indices, materialized views), and insert strategy (batch sizing, async inserts, mutation avoidance, ReplacingMergeTree/CollapsingMergeTree). Use when designing analytics tables, optimizing OLAP queries, or building data ingestion pipelines with ClickHouse."
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# ClickHouse Expert Guide
|
|
8
|
+
|
|
9
|
+
> Use this skill when designing ClickHouse table schemas, writing analytical queries, optimizing JOINs, configuring materialized views, or building data ingestion pipelines. Based on 28 official ClickHouse best-practice rules (Apache-2.0).
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Designing `CREATE TABLE` statements for analytics workloads
|
|
14
|
+
- Choosing `ORDER BY` / `PRIMARY KEY` columns
|
|
15
|
+
- Optimizing slow ClickHouse queries
|
|
16
|
+
- Building data ingestion pipelines (batch or streaming)
|
|
17
|
+
- Configuring partitioning and TTL strategies
|
|
18
|
+
- Working with ReplacingMergeTree, CollapsingMergeTree, or AggregatingMergeTree
|
|
19
|
+
|
|
20
|
+
## When NOT to Use This Skill
|
|
21
|
+
|
|
22
|
+
- OLTP workloads with frequent row-level updates → use PostgreSQL
|
|
23
|
+
- Full-text search → use Elasticsearch or Meilisearch
|
|
24
|
+
- Graph traversals → use Neo4j or SurrealDB
|
|
25
|
+
- Document store with flexible queries → use MongoDB
|
|
26
|
+
- Real-time subscriptions with push → use SpacetimeDB
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 1. Schema Design (CRITICAL)
|
|
31
|
+
|
|
32
|
+
### ORDER BY / PRIMARY KEY Planning
|
|
33
|
+
|
|
34
|
+
`ORDER BY` is **immutable** after table creation. Wrong choices require full data migration.
|
|
35
|
+
|
|
36
|
+
**Rule: Order columns by cardinality, low → high:**
|
|
37
|
+
|
|
38
|
+
| Position | Cardinality | Examples |
|
|
39
|
+
|----------|-------------|----------|
|
|
40
|
+
| 1st | Low (few distinct values) | `event_type`, `status`, `country` |
|
|
41
|
+
| 2nd | Date (coarse granularity) | `toDate(timestamp)` |
|
|
42
|
+
| 3rd+ | Medium-High | `user_id`, `session_id` |
|
|
43
|
+
| Last | High (if needed) | `event_id`, `uuid` |
|
|
44
|
+
|
|
45
|
+
```sql
|
|
46
|
+
-- ✅ Low cardinality first enables granule skipping
|
|
47
|
+
CREATE TABLE events (
|
|
48
|
+
event_type LowCardinality(String),
|
|
49
|
+
event_date Date,
|
|
50
|
+
user_id UInt64,
|
|
51
|
+
event_id UUID,
|
|
52
|
+
payload String
|
|
53
|
+
)
|
|
54
|
+
ENGINE = MergeTree()
|
|
55
|
+
ORDER BY (event_type, event_date, user_id);
|
|
56
|
+
|
|
57
|
+
-- ❌ High cardinality first prevents index pruning
|
|
58
|
+
-- ORDER BY (event_id, event_type, event_date);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
> **Tip**: Use `toDate(timestamp)` instead of raw `DateTime` in ORDER BY when day-level filtering suffices — reduces index size from 32-bit to 16-bit.
|
|
62
|
+
|
|
63
|
+
### Data Types
|
|
64
|
+
|
|
65
|
+
| Rule | Pattern |
|
|
66
|
+
|------|---------|
|
|
67
|
+
| Use native types | `DateTime`, `UInt32`, `IPv4` — not `String` for everything |
|
|
68
|
+
| Minimize bit-width | `UInt8` for HTTP codes, `UInt16` for years |
|
|
69
|
+
| `LowCardinality(String)` | For columns with <10K unique string values |
|
|
70
|
+
| `Enum8`/`Enum16` | For finite, validated value sets |
|
|
71
|
+
| Avoid `Nullable` | Use `DEFAULT` instead — Nullable adds storage overhead |
|
|
72
|
+
|
|
73
|
+
```sql
|
|
74
|
+
-- ✅ Right-sized types
|
|
75
|
+
CREATE TABLE metrics (
|
|
76
|
+
status_code UInt16, -- HTTP codes fit in UInt16
|
|
77
|
+
age UInt8, -- 0-255
|
|
78
|
+
country LowCardinality(String), -- ~200 countries
|
|
79
|
+
event_type Enum8('click' = 1, 'view' = 2, 'purchase' = 3),
|
|
80
|
+
amount Decimal(10,2),
|
|
81
|
+
created_at DateTime DEFAULT now() -- Not Nullable(DateTime)
|
|
82
|
+
)
|
|
83
|
+
ENGINE = MergeTree()
|
|
84
|
+
ORDER BY (country, event_type, created_at);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Partitioning
|
|
88
|
+
|
|
89
|
+
Partitioning is for **data lifecycle management**, not query performance.
|
|
90
|
+
|
|
91
|
+
| Rule | Detail |
|
|
92
|
+
|------|--------|
|
|
93
|
+
| Keep partition cardinality 100–1,000 | Monthly partitions: 12/year, bounded |
|
|
94
|
+
| Use for TTL/DROP PARTITION cleanup | Instant bulk deletion |
|
|
95
|
+
| **Consider starting without partitioning** | Add later when you understand access patterns |
|
|
96
|
+
| Never partition by high-cardinality columns | `user_id` = millions of partitions = crash |
|
|
97
|
+
|
|
98
|
+
```sql
|
|
99
|
+
-- ✅ Monthly partitions, bounded cardinality
|
|
100
|
+
CREATE TABLE events (...)
|
|
101
|
+
ENGINE = MergeTree()
|
|
102
|
+
PARTITION BY toStartOfMonth(timestamp)
|
|
103
|
+
ORDER BY (event_type, timestamp);
|
|
104
|
+
|
|
105
|
+
-- ✅ TTL with partition-based cleanup
|
|
106
|
+
ALTER TABLE events DROP PARTITION '202301'; -- Instant
|
|
107
|
+
|
|
108
|
+
-- ❌ Never: PARTITION BY user_id
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Validation query:**
|
|
112
|
+
|
|
113
|
+
```sql
|
|
114
|
+
SELECT partition, count() as parts, sum(rows) as rows,
|
|
115
|
+
formatReadableSize(sum(bytes_on_disk)) as size
|
|
116
|
+
FROM system.parts
|
|
117
|
+
WHERE table = 'events' AND active
|
|
118
|
+
GROUP BY partition ORDER BY partition;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### JSON Type
|
|
122
|
+
|
|
123
|
+
Use `JSON` type only for truly dynamic/semi-structured data. Use typed columns for known fields:
|
|
124
|
+
|
|
125
|
+
```sql
|
|
126
|
+
-- ✅ Known fields as typed columns + dynamic remainder as JSON
|
|
127
|
+
CREATE TABLE events (
|
|
128
|
+
event_type LowCardinality(String),
|
|
129
|
+
timestamp DateTime,
|
|
130
|
+
user_id UInt64,
|
|
131
|
+
metadata JSON -- Only for dynamic/unknown fields
|
|
132
|
+
)
|
|
133
|
+
ENGINE = MergeTree()
|
|
134
|
+
ORDER BY (event_type, timestamp);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## 2. Query Optimization (CRITICAL)
|
|
140
|
+
|
|
141
|
+
### JOIN Algorithms
|
|
142
|
+
|
|
143
|
+
ClickHouse defaults to loading the RIGHT table into memory. Choose the right algorithm:
|
|
144
|
+
|
|
145
|
+
| Algorithm | Best For | Trade-off |
|
|
146
|
+
|-----------|----------|-----------|
|
|
147
|
+
| `parallel_hash` | Small-to-medium in-memory (default 24.11+) | Fast, concurrent |
|
|
148
|
+
| `direct` | Dictionary lookups (INNER/LEFT only) | Fastest — no hash build |
|
|
149
|
+
| `full_sorting_merge` | Tables already sorted on join key | Low memory |
|
|
150
|
+
| `partial_merge` | Large tables, memory-constrained | Slowest, lowest memory |
|
|
151
|
+
| `grace_hash` | Large datasets, tunable memory | Disk-spilling |
|
|
152
|
+
| `auto` | Adaptive | Tries hash, falls back on pressure |
|
|
153
|
+
|
|
154
|
+
```sql
|
|
155
|
+
-- For large-to-large joins
|
|
156
|
+
SET join_algorithm = 'partial_merge';
|
|
157
|
+
SELECT * FROM large_a JOIN large_b ON large_b.id = large_a.id;
|
|
158
|
+
|
|
159
|
+
-- For sorted join keys
|
|
160
|
+
SET join_algorithm = 'full_sorting_merge';
|
|
161
|
+
SELECT * FROM table_a a JOIN table_b b ON b.pk_col = a.pk_col;
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Alternatives to JOINs
|
|
165
|
+
|
|
166
|
+
**Dictionaries** — for frequent lookups to small dimension tables:
|
|
167
|
+
|
|
168
|
+
```sql
|
|
169
|
+
CREATE DICTIONARY customer_dict (
|
|
170
|
+
id UInt64, name String, email String
|
|
171
|
+
)
|
|
172
|
+
PRIMARY KEY id
|
|
173
|
+
SOURCE(CLICKHOUSE(TABLE 'customers'))
|
|
174
|
+
LAYOUT(HASHED())
|
|
175
|
+
LIFETIME(MIN 300 MAX 360);
|
|
176
|
+
|
|
177
|
+
-- Use dictGet instead of JOIN
|
|
178
|
+
SELECT order_id,
|
|
179
|
+
dictGet('customer_dict', 'name', customer_id) as name
|
|
180
|
+
FROM orders WHERE created_at > '2024-01-01';
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
| Approach | When | Performance |
|
|
184
|
+
|----------|------|-------------|
|
|
185
|
+
| Dictionary | Frequent lookups, small dimension | Fastest (in-memory) |
|
|
186
|
+
| Denormalization (MV) | Analytics always need enriched data | Fast (no join at query) |
|
|
187
|
+
| IN subquery | Existence filtering | Often faster than JOIN |
|
|
188
|
+
| JOIN | Infrequent or complex joins | Acceptable |
|
|
189
|
+
|
|
190
|
+
### Data Skipping Indices
|
|
191
|
+
|
|
192
|
+
For filters on columns **not** in `ORDER BY`:
|
|
193
|
+
|
|
194
|
+
```sql
|
|
195
|
+
CREATE TABLE logs (
|
|
196
|
+
timestamp DateTime,
|
|
197
|
+
service LowCardinality(String),
|
|
198
|
+
error_code UInt32,
|
|
199
|
+
message String,
|
|
200
|
+
INDEX idx_error_code error_code TYPE minmax GRANULARITY 4,
|
|
201
|
+
INDEX idx_message message TYPE tokenbf_v1(10240, 3, 0) GRANULARITY 1
|
|
202
|
+
)
|
|
203
|
+
ENGINE = MergeTree()
|
|
204
|
+
ORDER BY (service, timestamp);
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Materialized Views
|
|
208
|
+
|
|
209
|
+
**Incremental MVs** — real-time pre-aggregation:
|
|
210
|
+
|
|
211
|
+
```sql
|
|
212
|
+
CREATE MATERIALIZED VIEW hourly_stats_mv TO hourly_stats AS
|
|
213
|
+
SELECT
|
|
214
|
+
toStartOfHour(timestamp) as hour,
|
|
215
|
+
service,
|
|
216
|
+
count() as event_count,
|
|
217
|
+
avg(duration) as avg_duration
|
|
218
|
+
FROM events GROUP BY hour, service;
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Refreshable MVs** — for complex joins / batch workflows:
|
|
222
|
+
|
|
223
|
+
```sql
|
|
224
|
+
CREATE MATERIALIZED VIEW enriched_orders
|
|
225
|
+
REFRESH EVERY 1 HOUR TO enriched_orders_target AS
|
|
226
|
+
SELECT o.*, c.name as customer_name
|
|
227
|
+
FROM orders o JOIN customers c ON c.id = o.customer_id;
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## 3. Insert Strategy (CRITICAL)
|
|
233
|
+
|
|
234
|
+
### Batching
|
|
235
|
+
|
|
236
|
+
**Batch 10K–100K rows per INSERT.** Never insert row-by-row.
|
|
237
|
+
|
|
238
|
+
```sql
|
|
239
|
+
-- ✅ Batch insert
|
|
240
|
+
INSERT INTO events FORMAT JSONEachRow
|
|
241
|
+
{"event_type": "click", "timestamp": "2024-01-01 00:00:00", ...}
|
|
242
|
+
{"event_type": "view", "timestamp": "2024-01-01 00:00:01", ...}
|
|
243
|
+
-- ... 50K more rows
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Async Inserts
|
|
247
|
+
|
|
248
|
+
For high-frequency small batches where client batching is impractical:
|
|
249
|
+
|
|
250
|
+
```sql
|
|
251
|
+
SET async_insert = 1;
|
|
252
|
+
SET wait_for_async_insert = 1; -- Wait for flush confirmation
|
|
253
|
+
-- ClickHouse batches small inserts server-side
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Native Format
|
|
257
|
+
|
|
258
|
+
Use `Native` format for best insert performance (eliminates parsing overhead).
|
|
259
|
+
|
|
260
|
+
### Avoiding Mutations
|
|
261
|
+
|
|
262
|
+
**Never use `ALTER TABLE UPDATE/DELETE` for regular operations.** Use specialized engines:
|
|
263
|
+
|
|
264
|
+
| Operation | ❌ Avoid | ✅ Use Instead |
|
|
265
|
+
|-----------|---------|---------------|
|
|
266
|
+
| Updates | `ALTER TABLE UPDATE` | `ReplacingMergeTree` + insert new version |
|
|
267
|
+
| Soft deletes | `ALTER TABLE DELETE` | `CollapsingMergeTree` (sign = -1) |
|
|
268
|
+
| Occasional deletes | `ALTER TABLE DELETE` | Lightweight `DELETE FROM` (23.3+) |
|
|
269
|
+
| Bulk time-based cleanup | `ALTER TABLE DELETE WHERE date < X` | `DROP PARTITION '202301'` |
|
|
270
|
+
| Background merging | `OPTIMIZE TABLE FINAL` | Let background merges work |
|
|
271
|
+
|
|
272
|
+
```sql
|
|
273
|
+
-- ✅ ReplacingMergeTree for updates
|
|
274
|
+
CREATE TABLE users (
|
|
275
|
+
user_id UInt64,
|
|
276
|
+
name String,
|
|
277
|
+
status LowCardinality(String),
|
|
278
|
+
updated_at DateTime DEFAULT now()
|
|
279
|
+
)
|
|
280
|
+
ENGINE = ReplacingMergeTree(updated_at)
|
|
281
|
+
ORDER BY user_id;
|
|
282
|
+
|
|
283
|
+
-- "Update" by inserting new version
|
|
284
|
+
INSERT INTO users (user_id, name, status) VALUES (123, 'John', 'inactive');
|
|
285
|
+
-- Query with FINAL for latest version
|
|
286
|
+
SELECT * FROM users FINAL WHERE user_id = 123;
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## 4. Common Anti-Patterns
|
|
292
|
+
|
|
293
|
+
1. **Random ORDER BY** — placing high-cardinality UUIDs first destroys index pruning
|
|
294
|
+
2. **`String` for everything** — use `DateTime`, `UInt32`, `IPv4`, `Enum` for known types
|
|
295
|
+
3. **Per-row inserts** — batch 10K–100K rows; row-by-row creates excessive parts
|
|
296
|
+
4. **`Nullable` by default** — adds storage cost and complexity; use `DEFAULT` values
|
|
297
|
+
5. **`ALTER TABLE UPDATE`** — rewrites entire parts; use `ReplacingMergeTree` instead
|
|
298
|
+
6. **High-cardinality partitions** — `PARTITION BY user_id` → millions of parts → crash
|
|
299
|
+
7. **`OPTIMIZE TABLE FINAL`** — forces synchronous merge; let background merges work
|
|
300
|
+
8. **JOINing large dimension tables on every query** — use dictionaries or denormalization
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## References
|
|
305
|
+
|
|
306
|
+
- [ClickHouse Best Practices (Official)](https://clickhouse.com/docs/best-practices)
|
|
307
|
+
- [Choosing a Primary Key](https://clickhouse.com/docs/best-practices/choosing-a-primary-key)
|
|
308
|
+
- [Choosing a Partitioning Key](https://clickhouse.com/docs/best-practices/choosing-a-partitioning-key)
|
|
309
|
+
- [Avoiding Mutations](https://clickhouse.com/docs/best-practices/avoid-mutations)
|
|
310
|
+
- [Minimizing JOINs](https://clickhouse.com/docs/best-practices/minimize-optimize-joins)
|
|
311
|
+
- Source patterns from [ClickHouse/agent-skills](https://github.com/ClickHouse/agent-skills) (Apache-2.0)
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: influxdb
|
|
3
|
+
description: "Expert InfluxDB guide covering bucket and measurement design, Flux query language, line protocol ingestion, retention policies, downsampling with tasks, continuous queries, driver setup, cross-store coordination, and security hardening. Use when building time-series monitoring, IoT telemetry, or metrics pipelines."
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# InfluxDB Expert Guide
|
|
8
|
+
|
|
9
|
+
> Use this skill when designing time-series schemas, writing Flux queries, planning retention and downsampling strategies, setting up InfluxDB clients, or coordinating InfluxDB with primary stores. Targets InfluxDB 3.x / InfluxDB Cloud.
|
|
10
|
+
|
|
11
|
+
## When to Use This Skill
|
|
12
|
+
|
|
13
|
+
- Time-series metrics collection (application monitoring, infrastructure metrics)
|
|
14
|
+
- IoT sensor data ingestion and querying
|
|
15
|
+
- Real-time dashboards with time-windowed aggregations
|
|
16
|
+
- Downsampling and retention management for long-term time-series storage
|
|
17
|
+
- High-throughput write workloads with time-ordered data
|
|
18
|
+
|
|
19
|
+
## When NOT to Use This Skill
|
|
20
|
+
|
|
21
|
+
- Relational data with JOINs → use PostgreSQL
|
|
22
|
+
- Graph traversals → use Neo4j
|
|
23
|
+
- Vector similarity search → use Qdrant or pgvector
|
|
24
|
+
- General-purpose document storage → use MongoDB or SurrealDB
|
|
25
|
+
- Time-series co-located with relational data → consider TimescaleDB (PostgreSQL extension)
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 1. Data Model
|
|
30
|
+
|
|
31
|
+
### Buckets (Database Equivalent)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Create a bucket with 30-day retention
|
|
35
|
+
influx bucket create \
|
|
36
|
+
--name metrics \
|
|
37
|
+
--retention 30d \
|
|
38
|
+
--org my-org
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Measurement Design
|
|
42
|
+
|
|
43
|
+
Measurements are analogous to tables. Each data point has:
|
|
44
|
+
- **Measurement name** — the "table"
|
|
45
|
+
- **Tags** — indexed key-value pairs (strings only) for filtering
|
|
46
|
+
- **Fields** — non-indexed values (any type) for the actual data
|
|
47
|
+
- **Timestamp** — nanosecond-precision time
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
// Line protocol format
|
|
51
|
+
cpu,host=server01,region=us-east usage_idle=98.5,usage_user=1.2 1640000000000000000
|
|
52
|
+
│ │ │ │
|
|
53
|
+
│ └── tags (indexed) └── fields (not indexed) └── timestamp (ns)
|
|
54
|
+
└── measurement
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Tag vs Field Decision
|
|
58
|
+
|
|
59
|
+
| Criterion | Tag | Field |
|
|
60
|
+
|-----------|-----|-------|
|
|
61
|
+
| Used in WHERE/GROUP BY? | ✅ Tag | ❌ Field |
|
|
62
|
+
| High cardinality (>100K unique values)? | ❌ Avoid | ✅ Field |
|
|
63
|
+
| Numeric/boolean value? | ❌ Strings only | ✅ Any type |
|
|
64
|
+
| Needs aggregation (sum, mean)? | ❌ | ✅ Field |
|
|
65
|
+
|
|
66
|
+
> ⚠️ **High-cardinality tags kill performance.** Never use UUIDs, timestamps, or unbounded strings as tags.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 2. Write Patterns
|
|
71
|
+
|
|
72
|
+
### Line Protocol (Preferred)
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from influxdb_client import InfluxDBClient, Point, WritePrecision
|
|
76
|
+
from influxdb_client.client.write_api import SYNCHRONOUS
|
|
77
|
+
|
|
78
|
+
client = InfluxDBClient(
|
|
79
|
+
url=os.environ["INFLUXDB_URL"],
|
|
80
|
+
token=os.environ["INFLUXDB_TOKEN"],
|
|
81
|
+
org=os.environ["INFLUXDB_ORG"],
|
|
82
|
+
)
|
|
83
|
+
write_api = client.write_api(write_options=SYNCHRONOUS)
|
|
84
|
+
|
|
85
|
+
# Single point
|
|
86
|
+
point = Point("cpu") \
|
|
87
|
+
.tag("host", "server01") \
|
|
88
|
+
.tag("region", "us-east") \
|
|
89
|
+
.field("usage_idle", 98.5) \
|
|
90
|
+
.field("usage_user", 1.2) \
|
|
91
|
+
.time(datetime.utcnow(), WritePrecision.MS)
|
|
92
|
+
|
|
93
|
+
write_api.write(bucket="metrics", record=point)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Batch Writes
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from influxdb_client.client.write_api import WriteOptions
|
|
100
|
+
|
|
101
|
+
write_api = client.write_api(write_options=WriteOptions(
|
|
102
|
+
batch_size=5000,
|
|
103
|
+
flush_interval=1000, # ms
|
|
104
|
+
jitter_interval=200,
|
|
105
|
+
))
|
|
106
|
+
|
|
107
|
+
# Write many points — batched automatically
|
|
108
|
+
for metric in metrics:
|
|
109
|
+
write_api.write(bucket="metrics", record=metric)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 3. Query Patterns (Flux)
|
|
115
|
+
|
|
116
|
+
### Basic Query
|
|
117
|
+
|
|
118
|
+
```flux
|
|
119
|
+
from(bucket: "metrics")
|
|
120
|
+
|> range(start: -1h)
|
|
121
|
+
|> filter(fn: (r) => r._measurement == "cpu")
|
|
122
|
+
|> filter(fn: (r) => r.host == "server01")
|
|
123
|
+
|> filter(fn: (r) => r._field == "usage_idle")
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Aggregation (Windowed)
|
|
127
|
+
|
|
128
|
+
```flux
|
|
129
|
+
from(bucket: "metrics")
|
|
130
|
+
|> range(start: -24h)
|
|
131
|
+
|> filter(fn: (r) => r._measurement == "cpu" and r._field == "usage_idle")
|
|
132
|
+
|> aggregateWindow(every: 5m, fn: mean, createEmpty: false)
|
|
133
|
+
|> yield(name: "mean_cpu_idle")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Group By
|
|
137
|
+
|
|
138
|
+
```flux
|
|
139
|
+
from(bucket: "metrics")
|
|
140
|
+
|> range(start: -1h)
|
|
141
|
+
|> filter(fn: (r) => r._measurement == "cpu")
|
|
142
|
+
|> group(columns: ["host", "region"])
|
|
143
|
+
|> mean()
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Join
|
|
147
|
+
|
|
148
|
+
```flux
|
|
149
|
+
cpu = from(bucket: "metrics")
|
|
150
|
+
|> range(start: -1h)
|
|
151
|
+
|> filter(fn: (r) => r._measurement == "cpu")
|
|
152
|
+
|
|
153
|
+
mem = from(bucket: "metrics")
|
|
154
|
+
|> range(start: -1h)
|
|
155
|
+
|> filter(fn: (r) => r._measurement == "mem")
|
|
156
|
+
|
|
157
|
+
join(tables: {cpu: cpu, mem: mem}, on: ["_time", "host"])
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
> **InfluxDB 3.x** also supports SQL queries via the Flight SQL interface, reducing the need for Flux in many cases.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## 4. Retention & Downsampling
|
|
165
|
+
|
|
166
|
+
### Bucket Retention
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Set retention to 90 days
|
|
170
|
+
influx bucket update --id <bucket-id> --retention 90d
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Downsampling Tasks
|
|
174
|
+
|
|
175
|
+
```flux
|
|
176
|
+
option task = {name: "downsample_cpu_1h", every: 1h}
|
|
177
|
+
|
|
178
|
+
from(bucket: "metrics")
|
|
179
|
+
|> range(start: -task.every)
|
|
180
|
+
|> filter(fn: (r) => r._measurement == "cpu")
|
|
181
|
+
|> aggregateWindow(every: 1h, fn: mean, createEmpty: false)
|
|
182
|
+
|> to(bucket: "metrics_downsampled", org: "my-org")
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Multi-Tier Retention Strategy
|
|
186
|
+
|
|
187
|
+
| Tier | Bucket | Retention | Resolution |
|
|
188
|
+
|------|--------|-----------|------------|
|
|
189
|
+
| Hot | `metrics` | 7 days | Raw (1s) |
|
|
190
|
+
| Warm | `metrics_5m` | 90 days | 5-minute aggregates |
|
|
191
|
+
| Cold | `metrics_1h` | 2 years | 1-hour aggregates |
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 5. Driver Setup
|
|
196
|
+
|
|
197
|
+
### Python
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
from influxdb_client import InfluxDBClient
|
|
201
|
+
|
|
202
|
+
client = InfluxDBClient(
|
|
203
|
+
url=os.environ["INFLUXDB_URL"],
|
|
204
|
+
token=os.environ["INFLUXDB_TOKEN"],
|
|
205
|
+
org=os.environ["INFLUXDB_ORG"],
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
query_api = client.query_api()
|
|
209
|
+
write_api = client.write_api()
|
|
210
|
+
|
|
211
|
+
# Always close
|
|
212
|
+
client.close()
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### JavaScript/TypeScript
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
import { InfluxDB } from '@influxdata/influxdb-client';
|
|
219
|
+
|
|
220
|
+
const influx = new InfluxDB({
|
|
221
|
+
url: process.env.INFLUXDB_URL!,
|
|
222
|
+
token: process.env.INFLUXDB_TOKEN!,
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const queryApi = influx.getQueryApi(process.env.INFLUXDB_ORG!);
|
|
226
|
+
const writeApi = influx.getWriteApi(process.env.INFLUXDB_ORG!, 'metrics');
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Go
|
|
230
|
+
|
|
231
|
+
```go
|
|
232
|
+
import influxdb2 "github.com/influxdata/influxdb-client-go/v2"
|
|
233
|
+
|
|
234
|
+
client := influxdb2.NewClient(
|
|
235
|
+
os.Getenv("INFLUXDB_URL"),
|
|
236
|
+
os.Getenv("INFLUXDB_TOKEN"),
|
|
237
|
+
)
|
|
238
|
+
defer client.Close()
|
|
239
|
+
|
|
240
|
+
writeAPI := client.WriteAPIBlocking(os.Getenv("INFLUXDB_ORG"), "metrics")
|
|
241
|
+
queryAPI := client.QueryAPI(os.Getenv("INFLUXDB_ORG"))
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 6. Cross-Store Coordination
|
|
247
|
+
|
|
248
|
+
### Canonical ID Rule
|
|
249
|
+
|
|
250
|
+
InfluxDB is a **secondary store** — it stores time-series projections, not source-of-truth entities. Use the primary store's identifier as a tag value:
|
|
251
|
+
|
|
252
|
+
```
|
|
253
|
+
cpu,host=server01,entity_id=primary-uuid usage_idle=98.5 1640000000000000000
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Sync Pattern
|
|
257
|
+
|
|
258
|
+
- Time-series data flows **one-way** into InfluxDB (write-only from the application's perspective)
|
|
259
|
+
- Entities are **not** created in InfluxDB — only their metrics are recorded
|
|
260
|
+
- Deletion of an entity in the primary store does not require deleting historical metrics
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## 7. Security
|
|
265
|
+
|
|
266
|
+
- **Token-based auth** — use scoped tokens with least-privilege (read-only for dashboards, write-only for ingestion)
|
|
267
|
+
- **Network isolation** — keep InfluxDB behind VPC; never expose port 8086 publicly
|
|
268
|
+
- **TLS** — always enable HTTPS in production
|
|
269
|
+
- **Bucket-level access** — scope tokens to specific buckets
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## 8. Common Anti-Patterns
|
|
274
|
+
|
|
275
|
+
1. **High-cardinality tags** — using UUIDs or unbounded strings as tags creates series explosion
|
|
276
|
+
2. **Missing retention policies** — unbounded data grows storage costs indefinitely
|
|
277
|
+
3. **No downsampling** — querying raw data over long time ranges is slow; downsample for dashboards
|
|
278
|
+
4. **Using InfluxDB as primary store** — it's a time-series database, not a general-purpose store
|
|
279
|
+
5. **Single-point writes** — always batch writes for throughput
|
|
280
|
+
6. **Querying without time range** — every Flux query must have `range()` to avoid scanning all data
|