@ruaruababa/vibe-kit 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/CATALOG.md +317 -0
- package/README.md +121 -0
- package/aliases.json +65 -0
- package/bin/vibe.js +2 -0
- package/bundles.json +265 -0
- package/catalog.json +1560 -0
- package/dist/antigravity-skills/bin/cli.js +438 -0
- package/dist/antigravity-skills/lib/skill-utils.js +158 -0
- package/dist/antigravity-skills/scripts/build-catalog.js +305 -0
- package/dist/antigravity-skills/scripts/normalize-frontmatter.js +144 -0
- package/dist/antigravity-skills/scripts/validate-skills.js +230 -0
- package/dist/bin/vibe.js +2 -0
- package/dist/dist/src/cli/index.js +26 -0
- package/dist/lib/skill-utils.js +158 -0
- package/dist/scripts/build-catalog.js +50 -0
- package/dist/scripts/normalize-frontmatter.js +144 -0
- package/dist/scripts/validate-skills.js +56 -0
- package/dist/src/cli/index.js +146 -0
- package/dist/src/types/index.js +13 -0
- package/dist/src/utils/fs.js +1 -0
- package/package.json +43 -0
- package/skills/accessibility-compliance-accessibility-audit/SKILL.md +42 -0
- package/skills/accessibility-compliance-accessibility-audit/resources/implementation-playbook.md +502 -0
- package/skills/agent-orchestration-improve-agent/SKILL.md +349 -0
- package/skills/agent-orchestration-multi-agent-optimize/SKILL.md +239 -0
- package/skills/agent-orchestrator/SKILL.md +24 -0
- package/skills/ai-engineer/SKILL.md +171 -0
- package/skills/airflow-dag-patterns/SKILL.md +41 -0
- package/skills/airflow-dag-patterns/resources/implementation-playbook.md +509 -0
- package/skills/angular-migration/SKILL.md +428 -0
- package/skills/anti-reversing-techniques/SKILL.md +42 -0
- package/skills/anti-reversing-techniques/resources/implementation-playbook.md +539 -0
- package/skills/api-design-principles/SKILL.md +37 -0
- package/skills/api-design-principles/assets/api-design-checklist.md +155 -0
- package/skills/api-design-principles/assets/rest-api-template.py +182 -0
- package/skills/api-design-principles/references/graphql-schema-design.md +583 -0
- package/skills/api-design-principles/references/rest-best-practices.md +408 -0
- package/skills/api-design-principles/resources/implementation-playbook.md +513 -0
- package/skills/api-documenter/SKILL.md +184 -0
- package/skills/api-testing-observability-api-mock/SKILL.md +46 -0
- package/skills/api-testing-observability-api-mock/resources/implementation-playbook.md +1327 -0
- package/skills/application-performance-performance-optimization/SKILL.md +154 -0
- package/skills/architect-review/SKILL.md +174 -0
- package/skills/architecture-decision-records/SKILL.md +441 -0
- package/skills/architecture-patterns/SKILL.md +37 -0
- package/skills/architecture-patterns/resources/implementation-playbook.md +479 -0
- package/skills/arm-cortex-expert/SKILL.md +306 -0
- package/skills/async-python-patterns/SKILL.md +39 -0
- package/skills/async-python-patterns/resources/implementation-playbook.md +678 -0
- package/skills/attack-tree-construction/SKILL.md +38 -0
- package/skills/attack-tree-construction/resources/implementation-playbook.md +671 -0
- package/skills/auth-implementation-patterns/SKILL.md +39 -0
- package/skills/auth-implementation-patterns/resources/implementation-playbook.md +618 -0
- package/skills/backend-architect/SKILL.md +333 -0
- package/skills/backend-development-feature-development/SKILL.md +180 -0
- package/skills/backend-security-coder/SKILL.md +156 -0
- package/skills/backtesting-frameworks/SKILL.md +39 -0
- package/skills/backtesting-frameworks/resources/implementation-playbook.md +647 -0
- package/skills/bash-defensive-patterns/SKILL.md +43 -0
- package/skills/bash-defensive-patterns/resources/implementation-playbook.md +517 -0
- package/skills/bash-pro/SKILL.md +310 -0
- package/skills/bats-testing-patterns/SKILL.md +34 -0
- package/skills/bats-testing-patterns/resources/implementation-playbook.md +614 -0
- package/skills/bazel-build-optimization/SKILL.md +397 -0
- package/skills/billing-automation/SKILL.md +42 -0
- package/skills/billing-automation/resources/implementation-playbook.md +544 -0
- package/skills/binary-analysis-patterns/SKILL.md +450 -0
- package/skills/blockchain-developer/SKILL.md +208 -0
- package/skills/business-analyst/SKILL.md +182 -0
- package/skills/c-pro/SKILL.md +56 -0
- package/skills/c4-architecture-c4-architecture/SKILL.md +389 -0
- package/skills/c4-code/SKILL.md +244 -0
- package/skills/c4-component/SKILL.md +153 -0
- package/skills/c4-container/SKILL.md +171 -0
- package/skills/c4-context/SKILL.md +150 -0
- package/skills/changelog-automation/SKILL.md +38 -0
- package/skills/changelog-automation/resources/implementation-playbook.md +538 -0
- package/skills/cicd-automation-workflow-automate/SKILL.md +51 -0
- package/skills/cicd-automation-workflow-automate/resources/implementation-playbook.md +1333 -0
- package/skills/clean-markdown/SKILL.md +23 -0
- package/skills/cloud-architect/SKILL.md +135 -0
- package/skills/code-documentation-code-explain/SKILL.md +46 -0
- package/skills/code-documentation-code-explain/resources/implementation-playbook.md +802 -0
- package/skills/code-documentation-doc-generate/SKILL.md +48 -0
- package/skills/code-documentation-doc-generate/resources/implementation-playbook.md +640 -0
- package/skills/code-refactoring-context-restore/SKILL.md +179 -0
- package/skills/code-refactoring-refactor-clean/SKILL.md +51 -0
- package/skills/code-refactoring-refactor-clean/resources/implementation-playbook.md +879 -0
- package/skills/code-refactoring-tech-debt/SKILL.md +386 -0
- package/skills/code-review-ai-ai-review/SKILL.md +450 -0
- package/skills/code-review-excellence/SKILL.md +40 -0
- package/skills/code-review-excellence/resources/implementation-playbook.md +515 -0
- package/skills/code-reviewer/SKILL.md +178 -0
- package/skills/codebase-cleanup-deps-audit/SKILL.md +51 -0
- package/skills/codebase-cleanup-deps-audit/resources/implementation-playbook.md +766 -0
- package/skills/codebase-cleanup-refactor-clean/SKILL.md +51 -0
- package/skills/codebase-cleanup-refactor-clean/resources/implementation-playbook.md +879 -0
- package/skills/codebase-cleanup-tech-debt/SKILL.md +386 -0
- package/skills/competitive-landscape/SKILL.md +34 -0
- package/skills/competitive-landscape/resources/implementation-playbook.md +494 -0
- package/skills/comprehensive-review-full-review/SKILL.md +146 -0
- package/skills/comprehensive-review-pr-enhance/SKILL.md +46 -0
- package/skills/comprehensive-review-pr-enhance/resources/implementation-playbook.md +691 -0
- package/skills/conductor-implement/SKILL.md +388 -0
- package/skills/conductor-manage/SKILL.md +39 -0
- package/skills/conductor-manage/resources/implementation-playbook.md +1120 -0
- package/skills/conductor-new-track/SKILL.md +433 -0
- package/skills/conductor-revert/SKILL.md +372 -0
- package/skills/conductor-setup/SKILL.md +426 -0
- package/skills/conductor-status/SKILL.md +338 -0
- package/skills/conductor-validator/SKILL.md +62 -0
- package/skills/content-marketer/SKILL.md +170 -0
- package/skills/context-driven-development/SKILL.md +400 -0
- package/skills/context-management-context-restore/SKILL.md +179 -0
- package/skills/context-management-context-save/SKILL.md +177 -0
- package/skills/context-manager/SKILL.md +185 -0
- package/skills/cost-optimization/SKILL.md +286 -0
- package/skills/cpp-pro/SKILL.md +59 -0
- package/skills/cqrs-implementation/SKILL.md +35 -0
- package/skills/cqrs-implementation/resources/implementation-playbook.md +540 -0
- package/skills/csharp-pro/SKILL.md +59 -0
- package/skills/customer-support/SKILL.md +170 -0
- package/skills/data-engineer/SKILL.md +224 -0
- package/skills/data-engineering-data-driven-feature/SKILL.md +182 -0
- package/skills/data-engineering-data-pipeline/SKILL.md +201 -0
- package/skills/data-quality-frameworks/SKILL.md +40 -0
- package/skills/data-quality-frameworks/resources/implementation-playbook.md +573 -0
- package/skills/data-scientist/SKILL.md +199 -0
- package/skills/data-storytelling/SKILL.md +465 -0
- package/skills/database-admin/SKILL.md +165 -0
- package/skills/database-architect/SKILL.md +268 -0
- package/skills/database-cloud-optimization-cost-optimize/SKILL.md +44 -0
- package/skills/database-cloud-optimization-cost-optimize/resources/implementation-playbook.md +1441 -0
- package/skills/database-migration/SKILL.md +436 -0
- package/skills/database-migrations-migration-observability/SKILL.md +420 -0
- package/skills/database-migrations-sql-migrations/SKILL.md +53 -0
- package/skills/database-migrations-sql-migrations/resources/implementation-playbook.md +499 -0
- package/skills/database-optimizer/SKILL.md +167 -0
- package/skills/dbt-transformation-patterns/SKILL.md +34 -0
- package/skills/dbt-transformation-patterns/resources/implementation-playbook.md +547 -0
- package/skills/debugger/SKILL.md +49 -0
- package/skills/debugging-strategies/SKILL.md +34 -0
- package/skills/debugging-strategies/resources/implementation-playbook.md +511 -0
- package/skills/debugging-toolkit-smart-debug/SKILL.md +197 -0
- package/skills/defi-protocol-templates/SKILL.md +466 -0
- package/skills/dependency-management-deps-audit/SKILL.md +44 -0
- package/skills/dependency-management-deps-audit/resources/implementation-playbook.md +766 -0
- package/skills/dependency-upgrade/SKILL.md +421 -0
- package/skills/deployment-engineer/SKILL.md +170 -0
- package/skills/deployment-pipeline-design/SKILL.md +371 -0
- package/skills/deployment-validation-config-validate/SKILL.md +496 -0
- package/skills/devops-troubleshooter/SKILL.md +161 -0
- package/skills/distributed-debugging-debug-trace/SKILL.md +44 -0
- package/skills/distributed-debugging-debug-trace/resources/implementation-playbook.md +1307 -0
- package/skills/distributed-tracing/SKILL.md +450 -0
- package/skills/django-pro/SKILL.md +180 -0
- package/skills/docs-architect/SKILL.md +98 -0
- package/skills/documentation-generation-doc-generate/SKILL.md +48 -0
- package/skills/documentation-generation-doc-generate/resources/implementation-playbook.md +640 -0
- package/skills/dotnet-architect/SKILL.md +197 -0
- package/skills/dotnet-backend-patterns/SKILL.md +37 -0
- package/skills/dotnet-backend-patterns/assets/repository-template.cs +523 -0
- package/skills/dotnet-backend-patterns/assets/service-template.cs +336 -0
- package/skills/dotnet-backend-patterns/references/dapper-patterns.md +544 -0
- package/skills/dotnet-backend-patterns/references/ef-core-best-practices.md +355 -0
- package/skills/dotnet-backend-patterns/resources/implementation-playbook.md +799 -0
- package/skills/dummy-skill/SKILL.md +5 -0
- package/skills/dx-optimizer/SKILL.md +83 -0
- package/skills/e2e-testing-patterns/SKILL.md +41 -0
- package/skills/e2e-testing-patterns/resources/implementation-playbook.md +531 -0
- package/skills/elixir-pro/SKILL.md +59 -0
- package/skills/embedding-strategies/SKILL.md +491 -0
- package/skills/employment-contract-templates/SKILL.md +39 -0
- package/skills/employment-contract-templates/resources/implementation-playbook.md +493 -0
- package/skills/error-debugging-error-analysis/SKILL.md +47 -0
- package/skills/error-debugging-error-analysis/resources/implementation-playbook.md +1143 -0
- package/skills/error-debugging-error-trace/SKILL.md +43 -0
- package/skills/error-debugging-error-trace/resources/implementation-playbook.md +1361 -0
- package/skills/error-debugging-multi-agent-review/SKILL.md +216 -0
- package/skills/error-detective/SKILL.md +53 -0
- package/skills/error-diagnostics-error-analysis/SKILL.md +47 -0
- package/skills/error-diagnostics-error-analysis/resources/implementation-playbook.md +1143 -0
- package/skills/error-diagnostics-error-trace/SKILL.md +48 -0
- package/skills/error-diagnostics-error-trace/resources/implementation-playbook.md +1371 -0
- package/skills/error-diagnostics-smart-debug/SKILL.md +197 -0
- package/skills/error-handling-patterns/SKILL.md +35 -0
- package/skills/error-handling-patterns/resources/implementation-playbook.md +635 -0
- package/skills/event-sourcing-architect/SKILL.md +58 -0
- package/skills/event-store-design/SKILL.md +449 -0
- package/skills/fastapi-pro/SKILL.md +192 -0
- package/skills/fastapi-templates/SKILL.md +32 -0
- package/skills/fastapi-templates/resources/implementation-playbook.md +566 -0
- package/skills/final-test/SKILL.md +5 -0
- package/skills/firmware-analyst/SKILL.md +320 -0
- package/skills/flutter-expert/SKILL.md +200 -0
- package/skills/framework-migration-code-migrate/SKILL.md +48 -0
- package/skills/framework-migration-code-migrate/resources/implementation-playbook.md +1052 -0
- package/skills/framework-migration-deps-upgrade/SKILL.md +48 -0
- package/skills/framework-migration-deps-upgrade/resources/implementation-playbook.md +755 -0
- package/skills/framework-migration-legacy-modernize/SKILL.md +132 -0
- package/skills/frontend-developer/SKILL.md +171 -0
- package/skills/frontend-mobile-development-component-scaffold/SKILL.md +403 -0
- package/skills/frontend-mobile-security-xss-scan/SKILL.md +322 -0
- package/skills/frontend-security-coder/SKILL.md +170 -0
- package/skills/full-stack-orchestration-full-stack-feature/SKILL.md +135 -0
- package/skills/gdpr-data-handling/SKILL.md +33 -0
- package/skills/gdpr-data-handling/resources/implementation-playbook.md +615 -0
- package/skills/git-advanced-workflows/SKILL.md +412 -0
- package/skills/git-pr-workflows-git-workflow/SKILL.md +140 -0
- package/skills/git-pr-workflows-onboard/SKILL.md +416 -0
- package/skills/git-pr-workflows-pr-enhance/SKILL.md +48 -0
- package/skills/git-pr-workflows-pr-enhance/resources/implementation-playbook.md +701 -0
- package/skills/github-actions-templates/SKILL.md +345 -0
- package/skills/gitlab-ci-patterns/SKILL.md +283 -0
- package/skills/gitops-workflow/SKILL.md +303 -0
- package/skills/gitops-workflow/references/argocd-setup.md +134 -0
- package/skills/gitops-workflow/references/sync-policies.md +131 -0
- package/skills/go-concurrency-patterns/SKILL.md +33 -0
- package/skills/go-concurrency-patterns/resources/implementation-playbook.md +654 -0
- package/skills/godot-gdscript-patterns/SKILL.md +33 -0
- package/skills/godot-gdscript-patterns/resources/implementation-playbook.md +804 -0
- package/skills/golang-pro/SKILL.md +179 -0
- package/skills/grafana-dashboards/SKILL.md +381 -0
- package/skills/graphql-architect/SKILL.md +182 -0
- package/skills/haskell-pro/SKILL.md +56 -0
- package/skills/helm-chart-scaffolding/SKILL.md +34 -0
- package/skills/helm-chart-scaffolding/assets/Chart.yaml.template +42 -0
- package/skills/helm-chart-scaffolding/assets/values.yaml.template +185 -0
- package/skills/helm-chart-scaffolding/references/chart-structure.md +500 -0
- package/skills/helm-chart-scaffolding/resources/implementation-playbook.md +543 -0
- package/skills/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
- package/skills/hr-pro/SKILL.md +126 -0
- package/skills/hybrid-cloud-architect/SKILL.md +168 -0
- package/skills/hybrid-cloud-networking/SKILL.md +238 -0
- package/skills/hybrid-search-implementation/SKILL.md +32 -0
- package/skills/hybrid-search-implementation/resources/implementation-playbook.md +567 -0
- package/skills/incident-responder/SKILL.md +213 -0
- package/skills/incident-response-incident-response/SKILL.md +168 -0
- package/skills/incident-response-smart-fix/SKILL.md +29 -0
- package/skills/incident-response-smart-fix/resources/implementation-playbook.md +838 -0
- package/skills/incident-runbook-templates/SKILL.md +395 -0
- package/skills/ios-developer/SKILL.md +219 -0
- package/skills/istio-traffic-management/SKILL.md +337 -0
- package/skills/java-pro/SKILL.md +177 -0
- package/skills/javascript-pro/SKILL.md +57 -0
- package/skills/javascript-testing-patterns/SKILL.md +35 -0
- package/skills/javascript-testing-patterns/resources/implementation-playbook.md +1024 -0
- package/skills/javascript-typescript-typescript-scaffold/SKILL.md +361 -0
- package/skills/julia-pro/SKILL.md +209 -0
- package/skills/k8s-manifest-generator/SKILL.md +35 -0
- package/skills/k8s-manifest-generator/assets/configmap-template.yaml +296 -0
- package/skills/k8s-manifest-generator/assets/deployment-template.yaml +203 -0
- package/skills/k8s-manifest-generator/assets/service-template.yaml +171 -0
- package/skills/k8s-manifest-generator/references/deployment-spec.md +753 -0
- package/skills/k8s-manifest-generator/references/service-spec.md +724 -0
- package/skills/k8s-manifest-generator/resources/implementation-playbook.md +510 -0
- package/skills/k8s-security-policies/SKILL.md +346 -0
- package/skills/k8s-security-policies/assets/network-policy-template.yaml +177 -0
- package/skills/k8s-security-policies/references/rbac-patterns.md +187 -0
- package/skills/kpi-dashboard-design/SKILL.md +440 -0
- package/skills/kubernetes-architect/SKILL.md +170 -0
- package/skills/langchain-architecture/SKILL.md +350 -0
- package/skills/legacy-modernizer/SKILL.md +53 -0
- package/skills/legal-advisor/SKILL.md +70 -0
- package/skills/linkerd-patterns/SKILL.md +321 -0
- package/skills/llm-application-dev-ai-assistant/SKILL.md +35 -0
- package/skills/llm-application-dev-ai-assistant/resources/implementation-playbook.md +1236 -0
- package/skills/llm-application-dev-langchain-agent/SKILL.md +246 -0
- package/skills/llm-application-dev-prompt-optimize/SKILL.md +37 -0
- package/skills/llm-application-dev-prompt-optimize/resources/implementation-playbook.md +591 -0
- package/skills/llm-evaluation/SKILL.md +483 -0
- package/skills/machine-learning-ops-ml-pipeline/SKILL.md +314 -0
- package/skills/malware-analyst/SKILL.md +247 -0
- package/skills/market-sizing-analysis/SKILL.md +425 -0
- package/skills/market-sizing-analysis/examples/saas-market-sizing.md +349 -0
- package/skills/market-sizing-analysis/references/data-sources.md +360 -0
- package/skills/memory-forensics/SKILL.md +491 -0
- package/skills/memory-safety-patterns/SKILL.md +33 -0
- package/skills/memory-safety-patterns/resources/implementation-playbook.md +603 -0
- package/skills/mermaid-expert/SKILL.md +59 -0
- package/skills/microservices-patterns/SKILL.md +35 -0
- package/skills/microservices-patterns/resources/implementation-playbook.md +607 -0
- package/skills/minecraft-bukkit-pro/SKILL.md +126 -0
- package/skills/ml-engineer/SKILL.md +168 -0
- package/skills/ml-pipeline-workflow/SKILL.md +257 -0
- package/skills/mlops-engineer/SKILL.md +219 -0
- package/skills/mobile-developer/SKILL.md +205 -0
- package/skills/mobile-security-coder/SKILL.md +184 -0
- package/skills/modern-javascript-patterns/SKILL.md +35 -0
- package/skills/modern-javascript-patterns/resources/implementation-playbook.md +910 -0
- package/skills/monorepo-architect/SKILL.md +61 -0
- package/skills/monorepo-management/SKILL.md +35 -0
- package/skills/monorepo-management/resources/implementation-playbook.md +621 -0
- package/skills/mtls-configuration/SKILL.md +359 -0
- package/skills/multi-cloud-architecture/SKILL.md +189 -0
- package/skills/multi-platform-apps-multi-platform/SKILL.md +203 -0
- package/skills/network-engineer/SKILL.md +169 -0
- package/skills/nextjs-app-router-patterns/SKILL.md +33 -0
- package/skills/nextjs-app-router-patterns/resources/implementation-playbook.md +543 -0
- package/skills/nft-standards/SKILL.md +395 -0
- package/skills/node-expert/SKILL.md +23 -0
- package/skills/nodejs-backend-patterns/SKILL.md +35 -0
- package/skills/nodejs-backend-patterns/resources/implementation-playbook.md +1019 -0
- package/skills/nx-workspace-patterns/SKILL.md +464 -0
- package/skills/observability-engineer/SKILL.md +237 -0
- package/skills/observability-monitoring-monitor-setup/SKILL.md +48 -0
- package/skills/observability-monitoring-monitor-setup/resources/implementation-playbook.md +505 -0
- package/skills/observability-monitoring-slo-implement/SKILL.md +43 -0
- package/skills/observability-monitoring-slo-implement/resources/implementation-playbook.md +1077 -0
- package/skills/on-call-handoff-patterns/SKILL.md +453 -0
- package/skills/openapi-spec-generation/SKILL.md +33 -0
- package/skills/openapi-spec-generation/resources/implementation-playbook.md +1027 -0
- package/skills/payment-integration/SKILL.md +77 -0
- package/skills/paypal-integration/SKILL.md +479 -0
- package/skills/pci-compliance/SKILL.md +478 -0
- package/skills/performance-engineer/SKILL.md +180 -0
- package/skills/performance-testing-review-ai-review/SKILL.md +450 -0
- package/skills/performance-testing-review-multi-agent-review/SKILL.md +216 -0
- package/skills/php-pro/SKILL.md +63 -0
- package/skills/posix-shell-pro/SKILL.md +304 -0
- package/skills/postgresql/SKILL.md +230 -0
- package/skills/postmortem-writing/SKILL.md +386 -0
- package/skills/projection-patterns/SKILL.md +33 -0
- package/skills/projection-patterns/resources/implementation-playbook.md +501 -0
- package/skills/prometheus-configuration/SKILL.md +404 -0
- package/skills/prompt-engineer/SKILL.md +272 -0
- package/skills/prompt-engineering-patterns/SKILL.md +213 -0
- package/skills/prompt-engineering-patterns/assets/few-shot-examples.json +106 -0
- package/skills/prompt-engineering-patterns/assets/prompt-template-library.md +246 -0
- package/skills/prompt-engineering-patterns/references/chain-of-thought.md +399 -0
- package/skills/prompt-engineering-patterns/references/few-shot-learning.md +369 -0
- package/skills/prompt-engineering-patterns/references/prompt-optimization.md +414 -0
- package/skills/prompt-engineering-patterns/references/prompt-templates.md +470 -0
- package/skills/prompt-engineering-patterns/references/system-prompts.md +189 -0
- package/skills/prompt-engineering-patterns/scripts/optimize-prompt.py +279 -0
- package/skills/protocol-reverse-engineering/SKILL.md +29 -0
- package/skills/protocol-reverse-engineering/resources/implementation-playbook.md +509 -0
- package/skills/python-development-python-scaffold/SKILL.md +331 -0
- package/skills/python-packaging/SKILL.md +36 -0
- package/skills/python-packaging/resources/implementation-playbook.md +869 -0
- package/skills/python-performance-optimization/SKILL.md +36 -0
- package/skills/python-performance-optimization/resources/implementation-playbook.md +868 -0
- package/skills/python-pro/SKILL.md +158 -0
- package/skills/python-testing-patterns/SKILL.md +37 -0
- package/skills/python-testing-patterns/resources/implementation-playbook.md +906 -0
- package/skills/quant-analyst/SKILL.md +53 -0
- package/skills/rag-implementation/SKILL.md +421 -0
- package/skills/react-modernization/SKILL.md +34 -0
- package/skills/react-modernization/resources/implementation-playbook.md +512 -0
- package/skills/react-native-architecture/SKILL.md +33 -0
- package/skills/react-native-architecture/resources/implementation-playbook.md +670 -0
- package/skills/react-state-management/SKILL.md +441 -0
- package/skills/reference-builder/SKILL.md +188 -0
- package/skills/reverse-engineer/SKILL.md +173 -0
- package/skills/risk-manager/SKILL.md +61 -0
- package/skills/risk-metrics-calculation/SKILL.md +33 -0
- package/skills/risk-metrics-calculation/resources/implementation-playbook.md +554 -0
- package/skills/ruby-pro/SKILL.md +56 -0
- package/skills/rust-async-patterns/SKILL.md +33 -0
- package/skills/rust-async-patterns/resources/implementation-playbook.md +516 -0
- package/skills/rust-pro/SKILL.md +178 -0
- package/skills/saga-orchestration/SKILL.md +496 -0
- package/skills/sales-automator/SKILL.md +55 -0
- package/skills/sast-configuration/SKILL.md +212 -0
- package/skills/scala-pro/SKILL.md +82 -0
- package/skills/screen-reader-testing/SKILL.md +33 -0
- package/skills/screen-reader-testing/resources/implementation-playbook.md +544 -0
- package/skills/search-specialist/SKILL.md +80 -0
- package/skills/secrets-management/SKILL.md +364 -0
- package/skills/security-auditor/SKILL.md +169 -0
- package/skills/security-compliance-compliance-check/SKILL.md +55 -0
- package/skills/security-compliance-compliance-check/resources/implementation-playbook.md +963 -0
- package/skills/security-requirement-extraction/SKILL.md +33 -0
- package/skills/security-requirement-extraction/resources/implementation-playbook.md +676 -0
- package/skills/security-scanning-security-dependencies/SKILL.md +43 -0
- package/skills/security-scanning-security-dependencies/resources/implementation-playbook.md +544 -0
- package/skills/security-scanning-security-hardening/SKILL.md +147 -0
- package/skills/security-scanning-security-sast/SKILL.md +495 -0
- package/skills/seo-authority-builder/SKILL.md +136 -0
- package/skills/seo-cannibalization-detector/SKILL.md +123 -0
- package/skills/seo-content-auditor/SKILL.md +83 -0
- package/skills/seo-content-planner/SKILL.md +108 -0
- package/skills/seo-content-refresher/SKILL.md +118 -0
- package/skills/seo-content-writer/SKILL.md +96 -0
- package/skills/seo-keyword-strategist/SKILL.md +95 -0
- package/skills/seo-meta-optimizer/SKILL.md +92 -0
- package/skills/seo-snippet-hunter/SKILL.md +114 -0
- package/skills/seo-structure-architect/SKILL.md +108 -0
- package/skills/service-mesh-expert/SKILL.md +58 -0
- package/skills/service-mesh-observability/SKILL.md +395 -0
- package/skills/shellcheck-configuration/SKILL.md +466 -0
- package/skills/similarity-search-patterns/SKILL.md +33 -0
- package/skills/similarity-search-patterns/resources/implementation-playbook.md +557 -0
- package/skills/slo-implementation/SKILL.md +341 -0
- package/skills/solidity-security/SKILL.md +34 -0
- package/skills/solidity-security/resources/implementation-playbook.md +524 -0
- package/skills/spark-optimization/SKILL.md +427 -0
- package/skills/sql-optimization-patterns/SKILL.md +35 -0
- package/skills/sql-optimization-patterns/resources/implementation-playbook.md +504 -0
- package/skills/sql-pro/SKILL.md +173 -0
- package/skills/startup-analyst/SKILL.md +328 -0
- package/skills/startup-business-analyst-business-case/SKILL.md +487 -0
- package/skills/startup-business-analyst-financial-projections/SKILL.md +353 -0
- package/skills/startup-business-analyst-market-opportunity/SKILL.md +240 -0
- package/skills/startup-financial-modeling/SKILL.md +467 -0
- package/skills/startup-metrics-framework/SKILL.md +34 -0
- package/skills/startup-metrics-framework/resources/implementation-playbook.md +500 -0
- package/skills/stride-analysis-patterns/SKILL.md +33 -0
- package/skills/stride-analysis-patterns/resources/implementation-playbook.md +655 -0
- package/skills/stripe-integration/SKILL.md +454 -0
- package/skills/systems-programming-rust-project/SKILL.md +440 -0
- package/skills/tailwind-design-system/SKILL.md +33 -0
- package/skills/tailwind-design-system/resources/implementation-playbook.md +665 -0
- package/skills/tdd-orchestrator/SKILL.md +205 -0
- package/skills/tdd-workflows-tdd-cycle/SKILL.md +221 -0
- package/skills/tdd-workflows-tdd-green/SKILL.md +73 -0
- package/skills/tdd-workflows-tdd-green/resources/implementation-playbook.md +870 -0
- package/skills/tdd-workflows-tdd-red/SKILL.md +164 -0
- package/skills/tdd-workflows-tdd-refactor/SKILL.md +187 -0
- package/skills/team-collaboration-issue/SKILL.md +37 -0
- package/skills/team-collaboration-issue/resources/implementation-playbook.md +640 -0
- package/skills/team-collaboration-standup-notes/SKILL.md +44 -0
- package/skills/team-collaboration-standup-notes/resources/implementation-playbook.md +768 -0
- package/skills/team-composition-analysis/SKILL.md +413 -0
- package/skills/temporal-python-pro/SKILL.md +370 -0
- package/skills/temporal-python-testing/SKILL.md +170 -0
- package/skills/temporal-python-testing/resources/integration-testing.md +455 -0
- package/skills/temporal-python-testing/resources/local-setup.md +553 -0
- package/skills/temporal-python-testing/resources/replay-testing.md +462 -0
- package/skills/temporal-python-testing/resources/unit-testing.md +328 -0
- package/skills/terraform-module-library/SKILL.md +261 -0
- package/skills/terraform-module-library/references/aws-modules.md +63 -0
- package/skills/terraform-specialist/SKILL.md +166 -0
- package/skills/test-automator/SKILL.md +224 -0
- package/skills/threat-mitigation-mapping/SKILL.md +33 -0
- package/skills/threat-mitigation-mapping/resources/implementation-playbook.md +744 -0
- package/skills/threat-modeling-expert/SKILL.md +60 -0
- package/skills/track-management/SKILL.md +38 -0
- package/skills/track-management/resources/implementation-playbook.md +591 -0
- package/skills/turborepo-caching/SKILL.md +419 -0
- package/skills/tutorial-engineer/SKILL.md +139 -0
- package/skills/typescript-advanced-types/SKILL.md +35 -0
- package/skills/typescript-advanced-types/resources/implementation-playbook.md +716 -0
- package/skills/typescript-pro/SKILL.md +55 -0
- package/skills/ui-minimal/SKILL.md +23 -0
- package/skills/ui-ux-designer/SKILL.md +209 -0
- package/skills/ui-visual-validator/SKILL.md +214 -0
- package/skills/unit-testing-test-generate/SKILL.md +319 -0
- package/skills/unity-developer/SKILL.md +230 -0
- package/skills/unity-ecs-patterns/SKILL.md +33 -0
- package/skills/unity-ecs-patterns/resources/implementation-playbook.md +625 -0
- package/skills/uv-package-manager/SKILL.md +37 -0
- package/skills/uv-package-manager/resources/implementation-playbook.md +830 -0
- package/skills/vector-database-engineer/SKILL.md +60 -0
- package/skills/vector-index-tuning/SKILL.md +42 -0
- package/skills/vector-index-tuning/resources/implementation-playbook.md +507 -0
- package/skills/wcag-audit-patterns/SKILL.md +41 -0
- package/skills/wcag-audit-patterns/resources/implementation-playbook.md +541 -0
- package/skills/web3-testing/SKILL.md +427 -0
- package/skills/workflow-orchestration-patterns/SKILL.md +333 -0
- package/skills/workflow-patterns/SKILL.md +38 -0
- package/skills/workflow-patterns/resources/implementation-playbook.md +621 -0
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
# Rust Async Patterns Implementation Playbook
|
|
2
|
+
|
|
3
|
+
This file contains detailed patterns, checklists, and code samples referenced by the skill.
|
|
4
|
+
|
|
5
|
+
# Rust Async Patterns
|
|
6
|
+
|
|
7
|
+
Production patterns for async Rust programming with Tokio runtime, including tasks, channels, streams, and error handling.
|
|
8
|
+
|
|
9
|
+
## When to Use This Skill
|
|
10
|
+
|
|
11
|
+
- Building async Rust applications
|
|
12
|
+
- Implementing concurrent network services
|
|
13
|
+
- Using Tokio for async I/O
|
|
14
|
+
- Handling async errors properly
|
|
15
|
+
- Debugging async code issues
|
|
16
|
+
- Optimizing async performance
|
|
17
|
+
|
|
18
|
+
## Core Concepts
|
|
19
|
+
|
|
20
|
+
### 1. Async Execution Model
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
Future (lazy) → poll() → Ready(value) | Pending
|
|
24
|
+
↑ ↓
|
|
25
|
+
Waker ← Runtime schedules
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Key Abstractions
|
|
29
|
+
|
|
30
|
+
| Concept | Purpose |
|
|
31
|
+
|---------|---------|
|
|
32
|
+
| `Future` | Lazy computation that may complete later |
|
|
33
|
+
| `async fn` | Function returning impl Future |
|
|
34
|
+
| `await` | Suspend until future completes |
|
|
35
|
+
| `Task` | Spawned future running concurrently |
|
|
36
|
+
| `Runtime` | Executor that polls futures |
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
```toml
|
|
41
|
+
# Cargo.toml
|
|
42
|
+
[dependencies]
|
|
43
|
+
tokio = { version = "1", features = ["full"] }
|
|
44
|
+
futures = "0.3"
|
|
45
|
+
async-trait = "0.1"
|
|
46
|
+
anyhow = "1.0"
|
|
47
|
+
tracing = "0.1"
|
|
48
|
+
tracing-subscriber = "0.3"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```rust
|
|
52
|
+
use tokio::time::{sleep, Duration};
|
|
53
|
+
use anyhow::Result;
|
|
54
|
+
|
|
55
|
+
#[tokio::main]
|
|
56
|
+
async fn main() -> Result<()> {
|
|
57
|
+
// Initialize tracing
|
|
58
|
+
tracing_subscriber::fmt::init();
|
|
59
|
+
|
|
60
|
+
// Async operations
|
|
61
|
+
let result = fetch_data("https://api.example.com").await?;
|
|
62
|
+
println!("Got: {}", result);
|
|
63
|
+
|
|
64
|
+
Ok(())
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async fn fetch_data(url: &str) -> Result<String> {
|
|
68
|
+
// Simulated async operation
|
|
69
|
+
sleep(Duration::from_millis(100)).await;
|
|
70
|
+
Ok(format!("Data from {}", url))
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Patterns
|
|
75
|
+
|
|
76
|
+
### Pattern 1: Concurrent Task Execution
|
|
77
|
+
|
|
78
|
+
```rust
|
|
79
|
+
use tokio::task::JoinSet;
|
|
80
|
+
use anyhow::Result;
|
|
81
|
+
|
|
82
|
+
// Spawn multiple concurrent tasks
|
|
83
|
+
async fn fetch_all_concurrent(urls: Vec<String>) -> Result<Vec<String>> {
|
|
84
|
+
let mut set = JoinSet::new();
|
|
85
|
+
|
|
86
|
+
for url in urls {
|
|
87
|
+
set.spawn(async move {
|
|
88
|
+
fetch_data(&url).await
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let mut results = Vec::new();
|
|
93
|
+
while let Some(res) = set.join_next().await {
|
|
94
|
+
match res {
|
|
95
|
+
Ok(Ok(data)) => results.push(data),
|
|
96
|
+
Ok(Err(e)) => tracing::error!("Task failed: {}", e),
|
|
97
|
+
Err(e) => tracing::error!("Join error: {}", e),
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
Ok(results)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// With concurrency limit
|
|
105
|
+
use futures::stream::{self, StreamExt};
|
|
106
|
+
|
|
107
|
+
async fn fetch_with_limit(urls: Vec<String>, limit: usize) -> Vec<Result<String>> {
|
|
108
|
+
stream::iter(urls)
|
|
109
|
+
.map(|url| async move { fetch_data(&url).await })
|
|
110
|
+
.buffer_unordered(limit) // Max concurrent tasks
|
|
111
|
+
.collect()
|
|
112
|
+
.await
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Select first to complete
|
|
116
|
+
use tokio::select;
|
|
117
|
+
|
|
118
|
+
async fn race_requests(url1: &str, url2: &str) -> Result<String> {
|
|
119
|
+
select! {
|
|
120
|
+
result = fetch_data(url1) => result,
|
|
121
|
+
result = fetch_data(url2) => result,
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Pattern 2: Channels for Communication
|
|
127
|
+
|
|
128
|
+
```rust
|
|
129
|
+
use tokio::sync::{mpsc, broadcast, oneshot, watch};
|
|
130
|
+
|
|
131
|
+
// Multi-producer, single-consumer
|
|
132
|
+
async fn mpsc_example() {
|
|
133
|
+
let (tx, mut rx) = mpsc::channel::<String>(100);
|
|
134
|
+
|
|
135
|
+
// Spawn producer
|
|
136
|
+
let tx2 = tx.clone();
|
|
137
|
+
tokio::spawn(async move {
|
|
138
|
+
tx2.send("Hello".to_string()).await.unwrap();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Consume
|
|
142
|
+
while let Some(msg) = rx.recv().await {
|
|
143
|
+
println!("Got: {}", msg);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Broadcast: multi-producer, multi-consumer
|
|
148
|
+
async fn broadcast_example() {
|
|
149
|
+
let (tx, _) = broadcast::channel::<String>(100);
|
|
150
|
+
|
|
151
|
+
let mut rx1 = tx.subscribe();
|
|
152
|
+
let mut rx2 = tx.subscribe();
|
|
153
|
+
|
|
154
|
+
tx.send("Event".to_string()).unwrap();
|
|
155
|
+
|
|
156
|
+
// Both receivers get the message
|
|
157
|
+
let _ = rx1.recv().await;
|
|
158
|
+
let _ = rx2.recv().await;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Oneshot: single value, single use
|
|
162
|
+
async fn oneshot_example() -> String {
|
|
163
|
+
let (tx, rx) = oneshot::channel::<String>();
|
|
164
|
+
|
|
165
|
+
tokio::spawn(async move {
|
|
166
|
+
tx.send("Result".to_string()).unwrap();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
rx.await.unwrap()
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Watch: single producer, multi-consumer, latest value
|
|
173
|
+
async fn watch_example() {
|
|
174
|
+
let (tx, mut rx) = watch::channel("initial".to_string());
|
|
175
|
+
|
|
176
|
+
tokio::spawn(async move {
|
|
177
|
+
loop {
|
|
178
|
+
// Wait for changes
|
|
179
|
+
rx.changed().await.unwrap();
|
|
180
|
+
println!("New value: {}", *rx.borrow());
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
tx.send("updated".to_string()).unwrap();
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Pattern 3: Async Error Handling
|
|
189
|
+
|
|
190
|
+
```rust
|
|
191
|
+
use anyhow::{Context, Result, bail};
|
|
192
|
+
use thiserror::Error;
|
|
193
|
+
|
|
194
|
+
#[derive(Error, Debug)]
|
|
195
|
+
pub enum ServiceError {
|
|
196
|
+
#[error("Network error: {0}")]
|
|
197
|
+
Network(#[from] reqwest::Error),
|
|
198
|
+
|
|
199
|
+
#[error("Database error: {0}")]
|
|
200
|
+
Database(#[from] sqlx::Error),
|
|
201
|
+
|
|
202
|
+
#[error("Not found: {0}")]
|
|
203
|
+
NotFound(String),
|
|
204
|
+
|
|
205
|
+
#[error("Timeout after {0:?}")]
|
|
206
|
+
Timeout(std::time::Duration),
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Using anyhow for application errors
|
|
210
|
+
async fn process_request(id: &str) -> Result<Response> {
|
|
211
|
+
let data = fetch_data(id)
|
|
212
|
+
.await
|
|
213
|
+
.context("Failed to fetch data")?;
|
|
214
|
+
|
|
215
|
+
let parsed = parse_response(&data)
|
|
216
|
+
.context("Failed to parse response")?;
|
|
217
|
+
|
|
218
|
+
Ok(parsed)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Using custom errors for library code
|
|
222
|
+
async fn get_user(id: &str) -> Result<User, ServiceError> {
|
|
223
|
+
let result = db.query(id).await?;
|
|
224
|
+
|
|
225
|
+
match result {
|
|
226
|
+
Some(user) => Ok(user),
|
|
227
|
+
None => Err(ServiceError::NotFound(id.to_string())),
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Timeout wrapper
|
|
232
|
+
use tokio::time::timeout;
|
|
233
|
+
|
|
234
|
+
async fn with_timeout<T, F>(duration: Duration, future: F) -> Result<T, ServiceError>
|
|
235
|
+
where
|
|
236
|
+
F: std::future::Future<Output = Result<T, ServiceError>>,
|
|
237
|
+
{
|
|
238
|
+
timeout(duration, future)
|
|
239
|
+
.await
|
|
240
|
+
.map_err(|_| ServiceError::Timeout(duration))?
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Pattern 4: Graceful Shutdown
|
|
245
|
+
|
|
246
|
+
```rust
|
|
247
|
+
use tokio::signal;
|
|
248
|
+
use tokio::sync::broadcast;
|
|
249
|
+
use tokio_util::sync::CancellationToken;
|
|
250
|
+
|
|
251
|
+
async fn run_server() -> Result<()> {
|
|
252
|
+
// Method 1: CancellationToken
|
|
253
|
+
let token = CancellationToken::new();
|
|
254
|
+
let token_clone = token.clone();
|
|
255
|
+
|
|
256
|
+
// Spawn task that respects cancellation
|
|
257
|
+
tokio::spawn(async move {
|
|
258
|
+
loop {
|
|
259
|
+
tokio::select! {
|
|
260
|
+
_ = token_clone.cancelled() => {
|
|
261
|
+
tracing::info!("Task shutting down");
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
_ = do_work() => {}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
// Wait for shutdown signal
|
|
270
|
+
signal::ctrl_c().await?;
|
|
271
|
+
tracing::info!("Shutdown signal received");
|
|
272
|
+
|
|
273
|
+
// Cancel all tasks
|
|
274
|
+
token.cancel();
|
|
275
|
+
|
|
276
|
+
// Give tasks time to cleanup
|
|
277
|
+
tokio::time::sleep(Duration::from_secs(5)).await;
|
|
278
|
+
|
|
279
|
+
Ok(())
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Method 2: Broadcast channel for shutdown
|
|
283
|
+
async fn run_with_broadcast() -> Result<()> {
|
|
284
|
+
let (shutdown_tx, _) = broadcast::channel::<()>(1);
|
|
285
|
+
|
|
286
|
+
let mut rx = shutdown_tx.subscribe();
|
|
287
|
+
tokio::spawn(async move {
|
|
288
|
+
tokio::select! {
|
|
289
|
+
_ = rx.recv() => {
|
|
290
|
+
tracing::info!("Received shutdown");
|
|
291
|
+
}
|
|
292
|
+
_ = async { loop { do_work().await } } => {}
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
signal::ctrl_c().await?;
|
|
297
|
+
let _ = shutdown_tx.send(());
|
|
298
|
+
|
|
299
|
+
Ok(())
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Pattern 5: Async Traits
|
|
304
|
+
|
|
305
|
+
```rust
|
|
306
|
+
use async_trait::async_trait;
|
|
307
|
+
|
|
308
|
+
#[async_trait]
|
|
309
|
+
pub trait Repository {
|
|
310
|
+
async fn get(&self, id: &str) -> Result<Entity>;
|
|
311
|
+
async fn save(&self, entity: &Entity) -> Result<()>;
|
|
312
|
+
async fn delete(&self, id: &str) -> Result<()>;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
pub struct PostgresRepository {
|
|
316
|
+
pool: sqlx::PgPool,
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
#[async_trait]
|
|
320
|
+
impl Repository for PostgresRepository {
|
|
321
|
+
async fn get(&self, id: &str) -> Result<Entity> {
|
|
322
|
+
sqlx::query_as!(Entity, "SELECT * FROM entities WHERE id = $1", id)
|
|
323
|
+
.fetch_one(&self.pool)
|
|
324
|
+
.await
|
|
325
|
+
.map_err(Into::into)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
async fn save(&self, entity: &Entity) -> Result<()> {
|
|
329
|
+
sqlx::query!(
|
|
330
|
+
"INSERT INTO entities (id, data) VALUES ($1, $2)
|
|
331
|
+
ON CONFLICT (id) DO UPDATE SET data = $2",
|
|
332
|
+
entity.id,
|
|
333
|
+
entity.data
|
|
334
|
+
)
|
|
335
|
+
.execute(&self.pool)
|
|
336
|
+
.await?;
|
|
337
|
+
Ok(())
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async fn delete(&self, id: &str) -> Result<()> {
|
|
341
|
+
sqlx::query!("DELETE FROM entities WHERE id = $1", id)
|
|
342
|
+
.execute(&self.pool)
|
|
343
|
+
.await?;
|
|
344
|
+
Ok(())
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Trait object usage
|
|
349
|
+
async fn process(repo: &dyn Repository, id: &str) -> Result<()> {
|
|
350
|
+
let entity = repo.get(id).await?;
|
|
351
|
+
// Process...
|
|
352
|
+
repo.save(&entity).await
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Pattern 6: Streams and Async Iteration
|
|
357
|
+
|
|
358
|
+
```rust
|
|
359
|
+
use futures::stream::{self, Stream, StreamExt};
|
|
360
|
+
use async_stream::stream;
|
|
361
|
+
|
|
362
|
+
// Create stream from async iterator
|
|
363
|
+
fn numbers_stream() -> impl Stream<Item = i32> {
|
|
364
|
+
stream! {
|
|
365
|
+
for i in 0..10 {
|
|
366
|
+
tokio::time::sleep(Duration::from_millis(100)).await;
|
|
367
|
+
yield i;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Process stream
|
|
373
|
+
async fn process_stream() {
|
|
374
|
+
let stream = numbers_stream();
|
|
375
|
+
|
|
376
|
+
// Map and filter
|
|
377
|
+
let processed: Vec<_> = stream
|
|
378
|
+
.filter(|n| futures::future::ready(*n % 2 == 0))
|
|
379
|
+
.map(|n| n * 2)
|
|
380
|
+
.collect()
|
|
381
|
+
.await;
|
|
382
|
+
|
|
383
|
+
println!("{:?}", processed);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// Chunked processing
|
|
387
|
+
async fn process_in_chunks() {
|
|
388
|
+
let stream = numbers_stream();
|
|
389
|
+
|
|
390
|
+
let mut chunks = stream.chunks(3);
|
|
391
|
+
|
|
392
|
+
while let Some(chunk) = chunks.next().await {
|
|
393
|
+
println!("Processing chunk: {:?}", chunk);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Merge multiple streams
|
|
398
|
+
async fn merge_streams() {
|
|
399
|
+
let stream1 = numbers_stream();
|
|
400
|
+
let stream2 = numbers_stream();
|
|
401
|
+
|
|
402
|
+
let merged = stream::select(stream1, stream2);
|
|
403
|
+
|
|
404
|
+
merged
|
|
405
|
+
.for_each(|n| async move {
|
|
406
|
+
println!("Got: {}", n);
|
|
407
|
+
})
|
|
408
|
+
.await;
|
|
409
|
+
}
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### Pattern 7: Resource Management
|
|
413
|
+
|
|
414
|
+
```rust
|
|
415
|
+
use std::sync::Arc;
|
|
416
|
+
use tokio::sync::{Mutex, RwLock, Semaphore};
|
|
417
|
+
|
|
418
|
+
// Shared state with RwLock (prefer for read-heavy)
|
|
419
|
+
struct Cache {
|
|
420
|
+
data: RwLock<HashMap<String, String>>,
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
impl Cache {
|
|
424
|
+
async fn get(&self, key: &str) -> Option<String> {
|
|
425
|
+
self.data.read().await.get(key).cloned()
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
async fn set(&self, key: String, value: String) {
|
|
429
|
+
self.data.write().await.insert(key, value);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// Connection pool with semaphore
|
|
434
|
+
struct Pool {
|
|
435
|
+
semaphore: Semaphore,
|
|
436
|
+
connections: Mutex<Vec<Connection>>,
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
impl Pool {
|
|
440
|
+
fn new(size: usize) -> Self {
|
|
441
|
+
Self {
|
|
442
|
+
semaphore: Semaphore::new(size),
|
|
443
|
+
connections: Mutex::new((0..size).map(|_| Connection::new()).collect()),
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
async fn acquire(&self) -> PooledConnection<'_> {
|
|
448
|
+
let permit = self.semaphore.acquire().await.unwrap();
|
|
449
|
+
let conn = self.connections.lock().await.pop().unwrap();
|
|
450
|
+
PooledConnection { pool: self, conn: Some(conn), _permit: permit }
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
struct PooledConnection<'a> {
|
|
455
|
+
pool: &'a Pool,
|
|
456
|
+
conn: Option<Connection>,
|
|
457
|
+
_permit: tokio::sync::SemaphorePermit<'a>,
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
impl Drop for PooledConnection<'_> {
|
|
461
|
+
fn drop(&mut self) {
|
|
462
|
+
if let Some(conn) = self.conn.take() {
|
|
463
|
+
let pool = self.pool;
|
|
464
|
+
tokio::spawn(async move {
|
|
465
|
+
pool.connections.lock().await.push(conn);
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
## Debugging Tips
|
|
473
|
+
|
|
474
|
+
```rust
|
|
475
|
+
// Enable tokio-console for runtime debugging
|
|
476
|
+
// Cargo.toml: tokio = { features = ["tracing"] }
|
|
477
|
+
// Run: RUSTFLAGS="--cfg tokio_unstable" cargo run
|
|
478
|
+
// Then: tokio-console
|
|
479
|
+
|
|
480
|
+
// Instrument async functions
|
|
481
|
+
use tracing::instrument;
|
|
482
|
+
|
|
483
|
+
#[instrument(skip(pool))]
|
|
484
|
+
async fn fetch_user(pool: &PgPool, id: &str) -> Result<User> {
|
|
485
|
+
tracing::debug!("Fetching user");
|
|
486
|
+
// ...
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// Track task spawning
|
|
490
|
+
let span = tracing::info_span!("worker", id = %worker_id);
|
|
491
|
+
tokio::spawn(async move {
|
|
492
|
+
// Enters span when polled
|
|
493
|
+
}.instrument(span));
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
## Best Practices
|
|
497
|
+
|
|
498
|
+
### Do's
|
|
499
|
+
- **Use `tokio::select!`** - For racing futures
|
|
500
|
+
- **Prefer channels** - Over shared state when possible
|
|
501
|
+
- **Use `JoinSet`** - For managing multiple tasks
|
|
502
|
+
- **Instrument with tracing** - For debugging async code
|
|
503
|
+
- **Handle cancellation** - Check `CancellationToken`
|
|
504
|
+
|
|
505
|
+
### Don'ts
|
|
506
|
+
- **Don't block** - Never use `std::thread::sleep` in async
|
|
507
|
+
- **Don't hold locks across awaits** - Causes deadlocks
|
|
508
|
+
- **Don't spawn unboundedly** - Use semaphores for limits
|
|
509
|
+
- **Don't ignore errors** - Propagate with `?` or log
|
|
510
|
+
- **Don't forget Send bounds** - For spawned futures
|
|
511
|
+
|
|
512
|
+
## Resources
|
|
513
|
+
|
|
514
|
+
- [Tokio Tutorial](https://tokio.rs/tokio/tutorial)
|
|
515
|
+
- [Async Book](https://rust-lang.github.io/async-book/)
|
|
516
|
+
- [Tokio Console](https://github.com/tokio-rs/console)
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rust-pro
|
|
3
|
+
description: Master Rust 1.75+ with modern async patterns, advanced type system
|
|
4
|
+
features, and production-ready systems programming. Expert in the latest Rust
|
|
5
|
+
ecosystem including Tokio, axum, and cutting-edge crates. Use PROACTIVELY for
|
|
6
|
+
Rust development, performance optimization, or systems programming.
|
|
7
|
+
metadata:
|
|
8
|
+
model: opus
|
|
9
|
+
---
|
|
10
|
+
You are a Rust expert specializing in modern Rust 1.75+ development with advanced async programming, systems-level performance, and production-ready applications.
|
|
11
|
+
|
|
12
|
+
## Use this skill when
|
|
13
|
+
|
|
14
|
+
- Building Rust services, libraries, or systems tooling
|
|
15
|
+
- Solving ownership, lifetime, or async design issues
|
|
16
|
+
- Optimizing performance with memory safety guarantees
|
|
17
|
+
|
|
18
|
+
## Do not use this skill when
|
|
19
|
+
|
|
20
|
+
- You need a quick script or dynamic runtime
|
|
21
|
+
- You only need basic Rust syntax
|
|
22
|
+
- You cannot introduce Rust into the stack
|
|
23
|
+
|
|
24
|
+
## Instructions
|
|
25
|
+
|
|
26
|
+
1. Clarify performance, safety, and runtime constraints.
|
|
27
|
+
2. Choose async/runtime and crate ecosystem approach.
|
|
28
|
+
3. Implement with tests and linting.
|
|
29
|
+
4. Profile and optimize hotspots.
|
|
30
|
+
|
|
31
|
+
## Purpose
|
|
32
|
+
Expert Rust developer mastering Rust 1.75+ features, advanced type system usage, and building high-performance, memory-safe systems. Deep knowledge of async programming, modern web frameworks, and the evolving Rust ecosystem.
|
|
33
|
+
|
|
34
|
+
## Capabilities
|
|
35
|
+
|
|
36
|
+
### Modern Rust Language Features
|
|
37
|
+
- Rust 1.75+ features including const generics and improved type inference
|
|
38
|
+
- Advanced lifetime annotations and lifetime elision rules
|
|
39
|
+
- Generic associated types (GATs) and advanced trait system features
|
|
40
|
+
- Pattern matching with advanced destructuring and guards
|
|
41
|
+
- Const evaluation and compile-time computation
|
|
42
|
+
- Macro system with procedural and declarative macros
|
|
43
|
+
- Module system and visibility controls
|
|
44
|
+
- Advanced error handling with Result, Option, and custom error types
|
|
45
|
+
|
|
46
|
+
### Ownership & Memory Management
|
|
47
|
+
- Ownership rules, borrowing, and move semantics mastery
|
|
48
|
+
- Reference counting with Rc, Arc, and weak references
|
|
49
|
+
- Smart pointers: Box, RefCell, Mutex, RwLock
|
|
50
|
+
- Memory layout optimization and zero-cost abstractions
|
|
51
|
+
- RAII patterns and automatic resource management
|
|
52
|
+
- Phantom types and zero-sized types (ZSTs)
|
|
53
|
+
- Memory safety without garbage collection
|
|
54
|
+
- Custom allocators and memory pool management
|
|
55
|
+
|
|
56
|
+
### Async Programming & Concurrency
|
|
57
|
+
- Advanced async/await patterns with Tokio runtime
|
|
58
|
+
- Stream processing and async iterators
|
|
59
|
+
- Channel patterns: mpsc, broadcast, watch channels
|
|
60
|
+
- Tokio ecosystem: axum, tower, hyper for web services
|
|
61
|
+
- Select patterns and concurrent task management
|
|
62
|
+
- Backpressure handling and flow control
|
|
63
|
+
- Async trait objects and dynamic dispatch
|
|
64
|
+
- Performance optimization in async contexts
|
|
65
|
+
|
|
66
|
+
### Type System & Traits
|
|
67
|
+
- Advanced trait implementations and trait bounds
|
|
68
|
+
- Associated types and generic associated types
|
|
69
|
+
- Higher-kinded types and type-level programming
|
|
70
|
+
- Phantom types and marker traits
|
|
71
|
+
- Orphan rule navigation and newtype patterns
|
|
72
|
+
- Derive macros and custom derive implementations
|
|
73
|
+
- Type erasure and dynamic dispatch strategies
|
|
74
|
+
- Compile-time polymorphism and monomorphization
|
|
75
|
+
|
|
76
|
+
### Performance & Systems Programming
|
|
77
|
+
- Zero-cost abstractions and compile-time optimizations
|
|
78
|
+
- SIMD programming with portable-simd
|
|
79
|
+
- Memory mapping and low-level I/O operations
|
|
80
|
+
- Lock-free programming and atomic operations
|
|
81
|
+
- Cache-friendly data structures and algorithms
|
|
82
|
+
- Profiling with perf, valgrind, and cargo-flamegraph
|
|
83
|
+
- Binary size optimization and embedded targets
|
|
84
|
+
- Cross-compilation and target-specific optimizations
|
|
85
|
+
|
|
86
|
+
### Web Development & Services
|
|
87
|
+
- Modern web frameworks: axum, warp, actix-web
|
|
88
|
+
- HTTP/2 and HTTP/3 support with hyper
|
|
89
|
+
- WebSocket and real-time communication
|
|
90
|
+
- Authentication and middleware patterns
|
|
91
|
+
- Database integration with sqlx and diesel
|
|
92
|
+
- Serialization with serde and custom formats
|
|
93
|
+
- GraphQL APIs with async-graphql
|
|
94
|
+
- gRPC services with tonic
|
|
95
|
+
|
|
96
|
+
### Error Handling & Safety
|
|
97
|
+
- Comprehensive error handling with thiserror and anyhow
|
|
98
|
+
- Custom error types and error propagation
|
|
99
|
+
- Panic handling and graceful degradation
|
|
100
|
+
- Result and Option patterns and combinators
|
|
101
|
+
- Error conversion and context preservation
|
|
102
|
+
- Logging and structured error reporting
|
|
103
|
+
- Testing error conditions and edge cases
|
|
104
|
+
- Recovery strategies and fault tolerance
|
|
105
|
+
|
|
106
|
+
### Testing & Quality Assurance
|
|
107
|
+
- Unit testing with built-in test framework
|
|
108
|
+
- Property-based testing with proptest and quickcheck
|
|
109
|
+
- Integration testing and test organization
|
|
110
|
+
- Mocking and test doubles with mockall
|
|
111
|
+
- Benchmark testing with criterion.rs
|
|
112
|
+
- Documentation tests and examples
|
|
113
|
+
- Coverage analysis with tarpaulin
|
|
114
|
+
- Continuous integration and automated testing
|
|
115
|
+
|
|
116
|
+
### Unsafe Code & FFI
|
|
117
|
+
- Safe abstractions over unsafe code
|
|
118
|
+
- Foreign Function Interface (FFI) with C libraries
|
|
119
|
+
- Memory safety invariants and documentation
|
|
120
|
+
- Pointer arithmetic and raw pointer manipulation
|
|
121
|
+
- Interfacing with system APIs and kernel modules
|
|
122
|
+
- Bindgen for automatic binding generation
|
|
123
|
+
- Cross-language interoperability patterns
|
|
124
|
+
- Auditing and minimizing unsafe code blocks
|
|
125
|
+
|
|
126
|
+
### Modern Tooling & Ecosystem
|
|
127
|
+
- Cargo workspace management and feature flags
|
|
128
|
+
- Cross-compilation and target configuration
|
|
129
|
+
- Clippy lints and custom lint configuration
|
|
130
|
+
- Rustfmt and code formatting standards
|
|
131
|
+
- Cargo extensions: audit, deny, outdated, edit
|
|
132
|
+
- IDE integration and development workflows
|
|
133
|
+
- Dependency management and version resolution
|
|
134
|
+
- Package publishing and documentation hosting
|
|
135
|
+
|
|
136
|
+
## Behavioral Traits
|
|
137
|
+
- Leverages the type system for compile-time correctness
|
|
138
|
+
- Prioritizes memory safety without sacrificing performance
|
|
139
|
+
- Uses zero-cost abstractions and avoids runtime overhead
|
|
140
|
+
- Implements explicit error handling with Result types
|
|
141
|
+
- Writes comprehensive tests including property-based tests
|
|
142
|
+
- Follows Rust idioms and community conventions
|
|
143
|
+
- Documents unsafe code blocks with safety invariants
|
|
144
|
+
- Optimizes for both correctness and performance
|
|
145
|
+
- Embraces functional programming patterns where appropriate
|
|
146
|
+
- Stays current with Rust language evolution and ecosystem
|
|
147
|
+
|
|
148
|
+
## Knowledge Base
|
|
149
|
+
- Rust 1.75+ language features and compiler improvements
|
|
150
|
+
- Modern async programming with Tokio ecosystem
|
|
151
|
+
- Advanced type system features and trait patterns
|
|
152
|
+
- Performance optimization and systems programming
|
|
153
|
+
- Web development frameworks and service patterns
|
|
154
|
+
- Error handling strategies and fault tolerance
|
|
155
|
+
- Testing methodologies and quality assurance
|
|
156
|
+
- Unsafe code patterns and FFI integration
|
|
157
|
+
- Cross-platform development and deployment
|
|
158
|
+
- Rust ecosystem trends and emerging crates
|
|
159
|
+
|
|
160
|
+
## Response Approach
|
|
161
|
+
1. **Analyze requirements** for Rust-specific safety and performance needs
|
|
162
|
+
2. **Design type-safe APIs** with comprehensive error handling
|
|
163
|
+
3. **Implement efficient algorithms** with zero-cost abstractions
|
|
164
|
+
4. **Include extensive testing** with unit, integration, and property-based tests
|
|
165
|
+
5. **Consider async patterns** for concurrent and I/O-bound operations
|
|
166
|
+
6. **Document safety invariants** for any unsafe code blocks
|
|
167
|
+
7. **Optimize for performance** while maintaining memory safety
|
|
168
|
+
8. **Recommend modern ecosystem** crates and patterns
|
|
169
|
+
|
|
170
|
+
## Example Interactions
|
|
171
|
+
- "Design a high-performance async web service with proper error handling"
|
|
172
|
+
- "Implement a lock-free concurrent data structure with atomic operations"
|
|
173
|
+
- "Optimize this Rust code for better memory usage and cache locality"
|
|
174
|
+
- "Create a safe wrapper around a C library using FFI"
|
|
175
|
+
- "Build a streaming data processor with backpressure handling"
|
|
176
|
+
- "Design a plugin system with dynamic loading and type safety"
|
|
177
|
+
- "Implement a custom allocator for a specific use case"
|
|
178
|
+
- "Debug and fix lifetime issues in this complex generic code"
|