shmakk 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/package.json +6 -3
- package/scripts/import-skills.js +536 -0
- package/scripts/install-skills.js +64 -0
- package/skills/ai-elements.md +482 -0
- package/skills/architecture.md +151 -0
- package/skills/backend-adapter-aws-lambda.md +204 -0
- package/skills/backend-adapter-express.md +177 -0
- package/skills/backend-adapter-fastify.md +222 -0
- package/skills/backend-adapter-fetch.md +200 -0
- package/skills/backend-api-docs.md +22 -0
- package/skills/backend-aspire.md +232 -0
- package/skills/backend-aspnet-core.md +62 -0
- package/skills/backend-build-chatgpt-app.md +321 -0
- package/skills/backend-build-mcp-app.md +393 -0
- package/skills/backend-build-mcp-server.md +222 -0
- package/skills/backend-build-mcpb.md +200 -0
- package/skills/backend-building-ai-agent-on-cloudflare.md +401 -0
- package/skills/backend-caching.md +206 -0
- package/skills/backend-chatgpt-app-submission.md +157 -0
- package/skills/backend-chatgpt-apps.md +321 -0
- package/skills/backend-client-setup.md +318 -0
- package/skills/backend-containerize-aspnet-framework.md +455 -0
- package/skills/backend-create-spring-boot-java-project.md +164 -0
- package/skills/backend-create-spring-boot-kotlin-project.md +148 -0
- package/skills/backend-csharp-async.md +50 -0
- package/skills/backend-csharp-docs.md +63 -0
- package/skills/backend-csharp-mcp-server-generator.md +60 -0
- package/skills/backend-dotenv.md +201 -0
- package/skills/backend-dotenvx.md +119 -0
- package/skills/backend-env-vars.md +259 -0
- package/skills/backend-error-handling.md +254 -0
- package/skills/backend-fastapi.md +437 -0
- package/skills/backend-go-mcp-server-generator.md +335 -0
- package/skills/backend-java-mcp-server-generator.md +757 -0
- package/skills/backend-kotlin-mcp-server-generator.md +450 -0
- package/skills/backend-middlewares.md +243 -0
- package/skills/backend-multi-stage-dockerfile.md +47 -0
- package/skills/backend-nestjs.md +192 -0
- package/skills/backend-next-forge.md +375 -0
- package/skills/backend-nextjs.md +746 -0
- package/skills/backend-openapi-to-application-code.md +113 -0
- package/skills/backend-php-mcp-server-generator.md +523 -0
- package/skills/backend-python-mcp-server-generator.md +106 -0
- package/skills/backend-routing-middleware.md +251 -0
- package/skills/backend-ruby-mcp-server-generator.md +661 -0
- package/skills/backend-rust-mcp-server-generator.md +578 -0
- package/skills/backend-semantic-kernel.md +57 -0
- package/skills/backend-server-setup.md +379 -0
- package/skills/backend-server-side-calls.md +250 -0
- package/skills/backend-subscriptions.md +407 -0
- package/skills/backend-swift-mcp-server-generator.md +670 -0
- package/skills/backend-trpc-router.md +152 -0
- package/skills/backend-typescript-mcp-server-generator.md +91 -0
- package/skills/backend-validators.md +229 -0
- package/skills/backend.md +76 -0
- package/skills/backup.md +165 -0
- package/skills/budget.md +140 -0
- package/skills/business-gtm-0-to-1-launch.md +322 -0
- package/skills/business-gtm-operating-cadence.md +421 -0
- package/skills/business-gtm-positioning-strategy.md +439 -0
- package/skills/business-gtm-product-led-growth.md +340 -0
- package/skills/calendar.md +95 -0
- package/skills/code-review.md +130 -0
- package/skills/compliance.md +168 -0
- package/skills/contracts.md +130 -0
- package/skills/daily-job-run.md +46 -0
- package/skills/daily-webdesign.md +187 -0
- package/skills/database-bigquery-pipeline-audit.md +130 -0
- package/skills/database-cosmosdb-datamodeling.md +1046 -0
- package/skills/database-durable-objects.md +187 -0
- package/skills/database-ef-core.md +76 -0
- package/skills/database-fabric-lakehouse.md +107 -0
- package/skills/database-neon-postgres-egress-optimizer.md +213 -0
- package/skills/database-neon-postgres.md +218 -0
- package/skills/database-postgresql-code-review.md +213 -0
- package/skills/database-postgresql-optimization.md +405 -0
- package/skills/database-sql-code-review.md +302 -0
- package/skills/database-sql-optimization.md +297 -0
- package/skills/dependency-audit.md +165 -0
- package/skills/design-kami-landing.md +234 -0
- package/skills/design.md +221 -0
- package/skills/dev-acquire-codebase-knowledge.md +175 -0
- package/skills/dev-add-educational-comments.md +129 -0
- package/skills/dev-add-model-descriptions.md +74 -0
- package/skills/dev-adr-review.md +56 -0
- package/skills/dev-boost-prompt.md +26 -0
- package/skills/dev-build-run-debug.md +130 -0
- package/skills/dev-chunk.md +49 -0
- package/skills/dev-claude-md-improver.md +180 -0
- package/skills/dev-code-exemplars-blueprint-generator.md +127 -0
- package/skills/dev-code-tour.md +434 -0
- package/skills/dev-comment-code-generate-a-tutorial.md +27 -0
- package/skills/dev-commit.md +81 -0
- package/skills/dev-context-map.md +53 -0
- package/skills/dev-conventional-commit.md +73 -0
- package/skills/dev-create-architectural-decision-record.md +98 -0
- package/skills/dev-create-draft-pr.md +17 -0
- package/skills/dev-create-pr.md +17 -0
- package/skills/dev-create-readme.md +22 -0
- package/skills/dev-csharp-mstest.md +479 -0
- package/skills/dev-csharp-nunit.md +72 -0
- package/skills/dev-csharp-tunit.md +101 -0
- package/skills/dev-csharp-xunit.md +69 -0
- package/skills/dev-debug-failing-test.md +90 -0
- package/skills/dev-diff-analyze.md +32 -0
- package/skills/dev-diffs.md +24 -0
- package/skills/dev-dotnet-best-practices.md +86 -0
- package/skills/dev-dotnet-design-pattern-review.md +43 -0
- package/skills/dev-dotnet-timezone.md +110 -0
- package/skills/dev-dotnet-upgrade.md +117 -0
- package/skills/dev-doublecheck.md +278 -0
- package/skills/dev-explain-error.md +15 -0
- package/skills/dev-finding-discovery.md +164 -0
- package/skills/dev-fix-finding.md +111 -0
- package/skills/dev-full-file-edit.md +25 -0
- package/skills/dev-git-commit.md +125 -0
- package/skills/dev-git-flow-branch-creator.md +293 -0
- package/skills/dev-git-workflow.md +46 -0
- package/skills/dev-github-automation.md +64 -0
- package/skills/dev-github-code-review.md +1140 -0
- package/skills/dev-github-issues.md +202 -0
- package/skills/dev-gpt-5-4-prompting.md +55 -0
- package/skills/dev-investigation-mode.md +277 -0
- package/skills/dev-java-add-graalvm-native-image-support.md +450 -0
- package/skills/dev-java-docs.md +24 -0
- package/skills/dev-java-refactoring-extract-method.md +105 -0
- package/skills/dev-java-refactoring-remove-parameter.md +85 -0
- package/skills/dev-merge.md +73 -0
- package/skills/dev-migrate-create.md +36 -0
- package/skills/dev-migrate-validate.md +36 -0
- package/skills/dev-my-issues.md +9 -0
- package/skills/dev-my-pull-requests.md +15 -0
- package/skills/dev-planning-oracle-to-postgres-migration-integration-testing.md +45 -0
- package/skills/dev-playwright-generate-test.md +18 -0
- package/skills/dev-playwright.md +148 -0
- package/skills/dev-prompt-builder.md +142 -0
- package/skills/dev-pytest-coverage.md +29 -0
- package/skills/dev-python-manager-discovery.md +330 -0
- package/skills/dev-python-pypi-package-builder.md +445 -0
- package/skills/dev-readme-blueprint-generator.md +79 -0
- package/skills/dev-refactor-method-complexity-reduce.md +99 -0
- package/skills/dev-refactor-plan.md +66 -0
- package/skills/dev-refactor.md +646 -0
- package/skills/dev-review-and-refactor.md +16 -0
- package/skills/dev-reviewing-oracle-to-postgres-migration.md +68 -0
- package/skills/dev-ruff-recursive-fix.md +201 -0
- package/skills/dev-run-e2e-tests.md +126 -0
- package/skills/dev-run-pre-commit-checks.md +133 -0
- package/skills/dev-run-smoke-tests.md +127 -0
- package/skills/dev-scaffolding-oracle-to-postgres-migration-test-project.md +55 -0
- package/skills/dev-spring-boot-testing.md +190 -0
- package/skills/dev-sync-upstream.md +32 -0
- package/skills/dev-sync.md +74 -0
- package/skills/dev-tdd-workflow.md +23 -0
- package/skills/dev-terraform-azurerm-set-diff-analyzer.md +49 -0
- package/skills/dev-test-driven-development.md +372 -0
- package/skills/dev-test-gaps.md +18 -0
- package/skills/dev-test-triage.md +55 -0
- package/skills/dev-typer.md +267 -0
- package/skills/dev-typescript-setup.md +25 -0
- package/skills/dev-unified-diff-edit.md +16 -0
- package/skills/dev-unit-test-vue-pinia.md +198 -0
- package/skills/dev-using-git-worktrees.md +216 -0
- package/skills/dev-validation.md +99 -0
- package/skills/dev-verification.md +168 -0
- package/skills/dev-webapp-testing.md +134 -0
- package/skills/dev-write-coding-standards-from-file.md +317 -0
- package/skills/dev-write-tests.md +16 -0
- package/skills/devops-appinsights-instrumentation.md +49 -0
- package/skills/devops-az-cost-optimize.md +306 -0
- package/skills/devops-chronicle.md +154 -0
- package/skills/devops-deployments-cicd.md +331 -0
- package/skills/devops-devops-rollout-plan.md +118 -0
- package/skills/devops-geistdocs.md +276 -0
- package/skills/devops-observability.md +774 -0
- package/skills/devops-observe-metrics.md +35 -0
- package/skills/devops-observe-trace.md +30 -0
- package/skills/devops-phoenix-cli.md +163 -0
- package/skills/devops-phoenix-tracing.md +140 -0
- package/skills/devops-publish-to-pages.md +108 -0
- package/skills/devops-telemetry.md +87 -0
- package/skills/devops-update-avm-modules-in-bicep.md +61 -0
- package/skills/devops.md +81 -0
- package/skills/diagrams-canvas.md +204 -0
- package/skills/diagrams-draw-io-diagram-generator.md +463 -0
- package/skills/diagrams-excalidraw-diagram-generator.md +614 -0
- package/skills/diagrams-graphify.md +1277 -0
- package/skills/docs-bear-notes.md +108 -0
- package/skills/docs-create-llms.md +211 -0
- package/skills/docs-doc-gen.md +20 -0
- package/skills/docs-documentation-writer.md +46 -0
- package/skills/docs-llm-config.md +33 -0
- package/skills/docs-mkdocs-translations.md +109 -0
- package/skills/docs-obsidian-vault-maintainer.md +14 -0
- package/skills/docs-obsidian.md +82 -0
- package/skills/docs-prose.md +324 -0
- package/skills/docs-update-llms.md +217 -0
- package/skills/docs-update-markdown-file-index.md +77 -0
- package/skills/docs-wiki-maintainer.md +20 -0
- package/skills/documents.md +120 -0
- package/skills/email.md +113 -0
- package/skills/expenses.md +140 -0
- package/skills/file-ops.md +149 -0
- package/skills/files-convert-plaintext-to-md.md +363 -0
- package/skills/files-doc.md +81 -0
- package/skills/files-docx.md +594 -0
- package/skills/files-markdown-to-html.md +917 -0
- package/skills/files-nano-pdf.md +39 -0
- package/skills/files-pdf.md +315 -0
- package/skills/files-pdftk-server.md +163 -0
- package/skills/files-pptx-html-fidelity-audit.md +255 -0
- package/skills/files-pptx.md +231 -0
- package/skills/files-xlsx.md +301 -0
- package/skills/find-jobs.md +78 -0
- package/skills/format-conversion.md +157 -0
- package/skills/frontend-ai-elements.md +483 -0
- package/skills/frontend-ai-gateway.md +563 -0
- package/skills/frontend-ai-generation-persistence.md +242 -0
- package/skills/frontend-ai-sdk.md +799 -0
- package/skills/frontend-ai-visibility.md +127 -0
- package/skills/frontend-angular-developer.md +130 -0
- package/skills/frontend-aspnet-minimal-api-openapi.md +42 -0
- package/skills/frontend-bencium-innovative-ux-designer.md +719 -0
- package/skills/frontend-chat-sdk.md +666 -0
- package/skills/frontend-chrome-devtools.md +98 -0
- package/skills/frontend-frontend-app-builder.md +186 -0
- package/skills/frontend-frontend-design.md +43 -0
- package/skills/frontend-frontend-testing-debugging.md +143 -0
- package/skills/frontend-gsap-framer-scroll-animation.md +152 -0
- package/skills/frontend-internal-linking.md +109 -0
- package/skills/frontend-json-render.md +335 -0
- package/skills/frontend-keyword-clustering.md +118 -0
- package/skills/frontend-next-intl-add-language.md +20 -0
- package/skills/frontend-on-page-seo.md +112 -0
- package/skills/frontend-premium-frontend-ui.md +114 -0
- package/skills/frontend-react-best-practices.md +143 -0
- package/skills/frontend-schema-markup.md +160 -0
- package/skills/frontend-seo-audit.md +110 -0
- package/skills/frontend-swr.md +215 -0
- package/skills/frontend-technical-seo.md +162 -0
- package/skills/frontend-use-dom.md +418 -0
- package/skills/frontend-web-coder.md +564 -0
- package/skills/frontend-web-design-reviewer.md +369 -0
- package/skills/frontend-web-perf.md +202 -0
- package/skills/frontend.md +125 -0
- package/skills/general-adapter-standalone.md +199 -0
- package/skills/general-auth.md +356 -0
- package/skills/general-containerize-aspnetcore.md +393 -0
- package/skills/general-create-technical-spike.md +231 -0
- package/skills/general-cron-jobs.md +72 -0
- package/skills/general-ddd-aggregate.md +52 -0
- package/skills/general-ddd-context.md +46 -0
- package/skills/general-ddd-validate.md +51 -0
- package/skills/general-dependency-check.md +26 -0
- package/skills/general-email-marketing.md +86 -0
- package/skills/general-healthcheck.md +246 -0
- package/skills/general-import-infrastructure-as-code.md +368 -0
- package/skills/general-init.md +49 -0
- package/skills/general-java-junit.md +64 -0
- package/skills/general-java-springboot.md +66 -0
- package/skills/general-javascript-typescript-jest.md +45 -0
- package/skills/general-kotlin-springboot.md +71 -0
- package/skills/general-make-repo-contribution.md +91 -0
- package/skills/general-market-research.md +78 -0
- package/skills/general-marketplace.md +468 -0
- package/skills/general-model-recommendation.md +673 -0
- package/skills/general-payments.md +352 -0
- package/skills/general-quality-playbook.md +480 -0
- package/skills/general-run-integration-tests.md +113 -0
- package/skills/general-superjson.md +274 -0
- package/skills/general-swiftpm-macos.md +51 -0
- package/skills/general-threat-model.md +61 -0
- package/skills/invoices.md +167 -0
- package/skills/licenses.md +159 -0
- package/skills/logs.md +156 -0
- package/skills/marketing.md +139 -0
- package/skills/media-image-manipulation-image-magick.md +253 -0
- package/skills/media-imagegen.md +357 -0
- package/skills/media-openai-whisper-api.md +63 -0
- package/skills/media-openai-whisper.md +39 -0
- package/skills/media-peekaboo.md +191 -0
- package/skills/media-screenshot.md +268 -0
- package/skills/media-speech.md +145 -0
- package/skills/media-transcribe.md +82 -0
- package/skills/media-video-frames.md +47 -0
- package/skills/mobile-android-emulator-qa.md +81 -0
- package/skills/mobile-android-performance.md +280 -0
- package/skills/mobile-building-mcp-server-on-cloudflare.md +267 -0
- package/skills/mobile-building-native-ui.md +322 -0
- package/skills/mobile-expo-api-routes.md +369 -0
- package/skills/mobile-expo-cicd-workflows.md +92 -0
- package/skills/mobile-expo-deployment.md +191 -0
- package/skills/mobile-expo-dev-client.md +165 -0
- package/skills/mobile-expo-module.md +177 -0
- package/skills/mobile-expo-tailwind-setup.md +481 -0
- package/skills/mobile-expo-ui-jetpack-compose.md +41 -0
- package/skills/mobile-expo-ui-swift-ui.md +40 -0
- package/skills/mobile-ios-app-intents.md +78 -0
- package/skills/mobile-ios-debugger-agent.md +52 -0
- package/skills/mobile-ios-ettrace-performance.md +198 -0
- package/skills/mobile-ios-memgraph-leaks.md +77 -0
- package/skills/mobile-native-data-fetching.md +508 -0
- package/skills/mobile-packaging-notarization.md +48 -0
- package/skills/mobile-react-native-architecture.md +672 -0
- package/skills/mobile-react-native-mobile-design.md +438 -0
- package/skills/mobile-signing-entitlements.md +59 -0
- package/skills/mobile-swiftui-liquid-glass.md +91 -0
- package/skills/mobile-swiftui-patterns.md +210 -0
- package/skills/mobile-swiftui-performance-audit.md +108 -0
- package/skills/mobile-swiftui-ui-patterns.md +97 -0
- package/skills/mobile-swiftui-view-refactor.md +204 -0
- package/skills/mobile-upgrading-expo.md +134 -0
- package/skills/mobile.md +183 -0
- package/skills/notes.md +106 -0
- package/skills/planning-adr-create.md +62 -0
- package/skills/planning-adr-index.md +67 -0
- package/skills/planning-architecture-blueprint-generator.md +323 -0
- package/skills/planning-brainstorming.md +165 -0
- package/skills/planning-breakdown-epic-arch.md +67 -0
- package/skills/planning-breakdown-epic-pm.md +59 -0
- package/skills/planning-breakdown-feature-implementation.md +129 -0
- package/skills/planning-breakdown-feature-prd.md +62 -0
- package/skills/planning-breakdown-plan.md +510 -0
- package/skills/planning-breakdown-test.md +366 -0
- package/skills/planning-cloud-design-patterns.md +63 -0
- package/skills/planning-content-brief.md +128 -0
- package/skills/planning-content-strategy.md +138 -0
- package/skills/planning-content-translation.md +143 -0
- package/skills/planning-create-github-action-workflow-specification.md +277 -0
- package/skills/planning-create-github-issues-feature-from-implementation-plan.md +29 -0
- package/skills/planning-create-github-issues-for-unmet-specification-requirements.md +36 -0
- package/skills/planning-create-github-pull-request-from-specification.md +25 -0
- package/skills/planning-create-implementation-plan.md +158 -0
- package/skills/planning-create-specification.md +128 -0
- package/skills/planning-first-ask.md +31 -0
- package/skills/planning-folder-structure-blueprint-generator.md +406 -0
- package/skills/planning-gen-specs-as-issues.md +166 -0
- package/skills/planning-generate-snapshot.md +144 -0
- package/skills/planning-generate-status-report.md +336 -0
- package/skills/planning-metric-pack-designer.md +27 -0
- package/skills/planning-pm-spec.md +53 -0
- package/skills/planning-prd.md +144 -0
- package/skills/planning-project-assessment.md +182 -0
- package/skills/planning-project-setup-info-local.md +128 -0
- package/skills/planning-project-workflow-analysis-blueprint-generator.md +294 -0
- package/skills/planning-service-oriented-architecture.md +248 -0
- package/skills/planning-spec-to-backlog.md +544 -0
- package/skills/planning-technology-stack-blueprint-generator.md +243 -0
- package/skills/planning-update-implementation-plan.md +158 -0
- package/skills/planning-update-specification.md +128 -0
- package/skills/planning-what-context-needed.md +40 -0
- package/skills/planning-writing-plans.md +153 -0
- package/skills/prepare-application.md +81 -0
- package/skills/productivity-apple-notes.md +78 -0
- package/skills/productivity-apple-reminders.md +119 -0
- package/skills/productivity-capture-tasks-from-meeting-notes.md +680 -0
- package/skills/productivity-daily-prep.md +156 -0
- package/skills/productivity-email-drafter.md +101 -0
- package/skills/productivity-hr-onboarding.md +53 -0
- package/skills/productivity-things-mac.md +87 -0
- package/skills/productivity-update.md +169 -0
- package/skills/reminders.md +109 -0
- package/skills/research-dossier-collect.md +71 -0
- package/skills/research-kg-extract.md +37 -0
- package/skills/research-openai-docs.md +89 -0
- package/skills/research-research-add-items.md +31 -0
- package/skills/research-research-report.md +94 -0
- package/skills/research-research-synthesize.md +63 -0
- package/skills/research-summarize.md +88 -0
- package/skills/research-transformers-js.md +635 -0
- package/skills/research.md +119 -0
- package/skills/security-ai-prompt-engineering-safety-review.md +231 -0
- package/skills/security-attack-path-analysis.md +182 -0
- package/skills/security-gdpr-compliant.md +284 -0
- package/skills/security-mcp-security-audit.md +279 -0
- package/skills/security-pii-detect.md +31 -0
- package/skills/security-secret-scanning.md +243 -0
- package/skills/security-security-best-practices.md +87 -0
- package/skills/security-security-ownership-map.md +207 -0
- package/skills/security-security-review.md +169 -0
- package/skills/security-security-scan.md +138 -0
- package/skills/security-security-threat-model.md +82 -0
- package/skills/security-threat-model-analyst.md +76 -0
- package/skills/sysmon.md +181 -0
- package/skills/system-arch-linux-triage.md +32 -0
- package/skills/system-centos-linux-triage.md +32 -0
- package/skills/system-debian-linux-triage.md +32 -0
- package/skills/system-fedora-linux-triage.md +32 -0
- package/skills/system-geofeed-tuner.md +865 -0
- package/skills/system-iot-anomalies.md +15 -0
- package/skills/system-iot-firmware.md +16 -0
- package/skills/system-iot-fleet.md +14 -0
- package/skills/system-iot-register.md +19 -0
- package/skills/system-iot-witness-verify.md +15 -0
- package/skills/system-tmux.md +171 -0
- package/skills/system-window-management.md +228 -0
- package/skills/task-management.md +90 -0
- package/skills/tasks.md +102 -0
- package/skills/test-coverage.md +188 -0
- package/skills/ux-ui.md +128 -0
- package/skills/web.md +186 -0
- package/skills/workflow-act-on-feedback.md +15 -0
- package/skills/workflow-automate-this.md +245 -0
- package/skills/workflow-autoresearch.md +276 -0
- package/skills/workflow-coding-agent.md +317 -0
- package/skills/workflow-deep-research.md +44 -0
- package/skills/workflow-dispatching-parallel-agents.md +183 -0
- package/skills/workflow-eval-driven-dev.md +148 -0
- package/skills/workflow-executing-plans.md +71 -0
- package/skills/workflow-mentoring-juniors.md +311 -0
- package/skills/workflow-receiving-code-review.md +214 -0
- package/skills/workflow-repo-story-time.md +155 -0
- package/skills/workflow-requesting-code-review.md +104 -0
- package/skills/workflow-session-report.md +43 -0
- package/skills/workflow-structured-autonomy-generate.md +126 -0
- package/skills/workflow-subagent-driven-development.md +280 -0
- package/skills/writing.md +106 -0
- package/src/agent.js +0 -0
- package/src/browser.js +297 -0
- package/src/cli.js +25 -4
- package/src/code-reviewer.js +119 -0
- package/src/completions.js +1 -1
- package/src/control.js +222 -30
- package/src/coordinator.js +303 -0
- package/src/correction.js +29 -8
- package/src/edit-tracker.js +21 -0
- package/src/edit-viewer.js +414 -0
- package/src/endpoints.js +64 -15
- package/src/index.js +45 -11
- package/src/llm.js +86 -2
- package/src/mcp-client.js +416 -0
- package/src/memory.js +182 -0
- package/src/planner.js +216 -0
- package/src/rules.js +90 -0
- package/src/self-commands.js +757 -0
- package/src/services/voice.js +10 -7
- package/src/session-search.js +427 -0
- package/src/session.js +487 -99
- package/src/shmakk-server.js +91 -0
- package/src/skills.js +410 -3
- package/src/subagent.js +4 -1
- package/src/system-prompt.js +13 -5
- package/src/task-file.js +114 -0
- package/src/taskClassifier.js +246 -0
- package/src/team.js +752 -0
- package/src/tools.js +142 -21
- package/src/web.js +35 -5
- package/src/workflows.js +261 -0
- package/src/workspace-index.js +25 -6
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-driven-development
|
|
3
|
+
description: Use when implementing any feature or bugfix, before writing implementation code
|
|
4
|
+
category: dev
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Test-Driven Development (TDD)
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Write the test first. Watch it fail. Write minimal code to pass.
|
|
12
|
+
|
|
13
|
+
**Core principle:** If you didn't watch the test fail, you don't know if it tests the right thing.
|
|
14
|
+
|
|
15
|
+
**Violating the letter of the rules is violating the spirit of the rules.**
|
|
16
|
+
|
|
17
|
+
## When to Use
|
|
18
|
+
|
|
19
|
+
**Always:**
|
|
20
|
+
- New features
|
|
21
|
+
- Bug fixes
|
|
22
|
+
- Refactoring
|
|
23
|
+
- Behavior changes
|
|
24
|
+
|
|
25
|
+
**Exceptions (ask your human partner):**
|
|
26
|
+
- Throwaway prototypes
|
|
27
|
+
- Generated code
|
|
28
|
+
- Configuration files
|
|
29
|
+
|
|
30
|
+
Thinking "skip TDD just this once"? Stop. That's rationalization.
|
|
31
|
+
|
|
32
|
+
## The Iron Law
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Write code before the test? Delete it. Start over.
|
|
39
|
+
|
|
40
|
+
**No exceptions:**
|
|
41
|
+
- Don't keep it as "reference"
|
|
42
|
+
- Don't "adapt" it while writing tests
|
|
43
|
+
- Don't look at it
|
|
44
|
+
- Delete means delete
|
|
45
|
+
|
|
46
|
+
Implement fresh from tests. Period.
|
|
47
|
+
|
|
48
|
+
## Red-Green-Refactor
|
|
49
|
+
|
|
50
|
+
```dot
|
|
51
|
+
digraph tdd_cycle {
|
|
52
|
+
rankdir=LR;
|
|
53
|
+
red [label="RED\nWrite failing test", shape=box, style=filled, fillcolor="#ffcccc"];
|
|
54
|
+
verify_red [label="Verify fails\ncorrectly", shape=diamond];
|
|
55
|
+
green [label="GREEN\nMinimal code", shape=box, style=filled, fillcolor="#ccffcc"];
|
|
56
|
+
verify_green [label="Verify passes\nAll green", shape=diamond];
|
|
57
|
+
refactor [label="REFACTOR\nClean up", shape=box, style=filled, fillcolor="#ccccff"];
|
|
58
|
+
next [label="Next", shape=ellipse];
|
|
59
|
+
|
|
60
|
+
red -> verify_red;
|
|
61
|
+
verify_red -> green [label="yes"];
|
|
62
|
+
verify_red -> red [label="wrong\nfailure"];
|
|
63
|
+
green -> verify_green;
|
|
64
|
+
verify_green -> refactor [label="yes"];
|
|
65
|
+
verify_green -> green [label="no"];
|
|
66
|
+
refactor -> verify_green [label="stay\ngreen"];
|
|
67
|
+
verify_green -> next;
|
|
68
|
+
next -> red;
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### RED - Write Failing Test
|
|
73
|
+
|
|
74
|
+
Write one minimal test showing what should happen.
|
|
75
|
+
|
|
76
|
+
<Good>
|
|
77
|
+
```typescript
|
|
78
|
+
test('retries failed operations 3 times', async () => {
|
|
79
|
+
let attempts = 0;
|
|
80
|
+
const operation = () => {
|
|
81
|
+
attempts++;
|
|
82
|
+
if (attempts < 3) throw new Error('fail');
|
|
83
|
+
return 'success';
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const result = await retryOperation(operation);
|
|
87
|
+
|
|
88
|
+
expect(result).toBe('success');
|
|
89
|
+
expect(attempts).toBe(3);
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
Clear name, tests real behavior, one thing
|
|
93
|
+
</Good>
|
|
94
|
+
|
|
95
|
+
<Bad>
|
|
96
|
+
```typescript
|
|
97
|
+
test('retry works', async () => {
|
|
98
|
+
const mock = jest.fn()
|
|
99
|
+
.mockRejectedValueOnce(new Error())
|
|
100
|
+
.mockRejectedValueOnce(new Error())
|
|
101
|
+
.mockResolvedValueOnce('success');
|
|
102
|
+
await retryOperation(mock);
|
|
103
|
+
expect(mock).toHaveBeenCalledTimes(3);
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
Vague name, tests mock not code
|
|
107
|
+
</Bad>
|
|
108
|
+
|
|
109
|
+
**Requirements:**
|
|
110
|
+
- One behavior
|
|
111
|
+
- Clear name
|
|
112
|
+
- Real code (no mocks unless unavoidable)
|
|
113
|
+
|
|
114
|
+
### Verify RED - Watch It Fail
|
|
115
|
+
|
|
116
|
+
**MANDATORY. Never skip.**
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm test path/to/test.test.ts
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Confirm:
|
|
123
|
+
- Test fails (not errors)
|
|
124
|
+
- Failure message is expected
|
|
125
|
+
- Fails because feature missing (not typos)
|
|
126
|
+
|
|
127
|
+
**Test passes?** You're testing existing behavior. Fix test.
|
|
128
|
+
|
|
129
|
+
**Test errors?** Fix error, re-run until it fails correctly.
|
|
130
|
+
|
|
131
|
+
### GREEN - Minimal Code
|
|
132
|
+
|
|
133
|
+
Write simplest code to pass the test.
|
|
134
|
+
|
|
135
|
+
<Good>
|
|
136
|
+
```typescript
|
|
137
|
+
async function retryOperation<T>(fn: () => Promise<T>): Promise<T> {
|
|
138
|
+
for (let i = 0; i < 3; i++) {
|
|
139
|
+
try {
|
|
140
|
+
return await fn();
|
|
141
|
+
} catch (e) {
|
|
142
|
+
if (i === 2) throw e;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
throw new Error('unreachable');
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
Just enough to pass
|
|
149
|
+
</Good>
|
|
150
|
+
|
|
151
|
+
<Bad>
|
|
152
|
+
```typescript
|
|
153
|
+
async function retryOperation<T>(
|
|
154
|
+
fn: () => Promise<T>,
|
|
155
|
+
options?: {
|
|
156
|
+
maxRetries?: number;
|
|
157
|
+
backoff?: 'linear' | 'exponential';
|
|
158
|
+
onRetry?: (attempt: number) => void;
|
|
159
|
+
}
|
|
160
|
+
): Promise<T> {
|
|
161
|
+
// YAGNI
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
Over-engineered
|
|
165
|
+
</Bad>
|
|
166
|
+
|
|
167
|
+
Don't add features, refactor other code, or "improve" beyond the test.
|
|
168
|
+
|
|
169
|
+
### Verify GREEN - Watch It Pass
|
|
170
|
+
|
|
171
|
+
**MANDATORY.**
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
npm test path/to/test.test.ts
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Confirm:
|
|
178
|
+
- Test passes
|
|
179
|
+
- Other tests still pass
|
|
180
|
+
- Output pristine (no errors, warnings)
|
|
181
|
+
|
|
182
|
+
**Test fails?** Fix code, not test.
|
|
183
|
+
|
|
184
|
+
**Other tests fail?** Fix now.
|
|
185
|
+
|
|
186
|
+
### REFACTOR - Clean Up
|
|
187
|
+
|
|
188
|
+
After green only:
|
|
189
|
+
- Remove duplication
|
|
190
|
+
- Improve names
|
|
191
|
+
- Extract helpers
|
|
192
|
+
|
|
193
|
+
Keep tests green. Don't add behavior.
|
|
194
|
+
|
|
195
|
+
### Repeat
|
|
196
|
+
|
|
197
|
+
Next failing test for next feature.
|
|
198
|
+
|
|
199
|
+
## Good Tests
|
|
200
|
+
|
|
201
|
+
| Quality | Good | Bad |
|
|
202
|
+
|---------|------|-----|
|
|
203
|
+
| **Minimal** | One thing. "and" in name? Split it. | `test('validates email and domain and whitespace')` |
|
|
204
|
+
| **Clear** | Name describes behavior | `test('test1')` |
|
|
205
|
+
| **Shows intent** | Demonstrates desired API | Obscures what code should do |
|
|
206
|
+
|
|
207
|
+
## Why Order Matters
|
|
208
|
+
|
|
209
|
+
**"I'll write tests after to verify it works"**
|
|
210
|
+
|
|
211
|
+
Tests written after code pass immediately. Passing immediately proves nothing:
|
|
212
|
+
- Might test wrong thing
|
|
213
|
+
- Might test implementation, not behavior
|
|
214
|
+
- Might miss edge cases you forgot
|
|
215
|
+
- You never saw it catch the bug
|
|
216
|
+
|
|
217
|
+
Test-first forces you to see the test fail, proving it actually tests something.
|
|
218
|
+
|
|
219
|
+
**"I already manually tested all the edge cases"**
|
|
220
|
+
|
|
221
|
+
Manual testing is ad-hoc. You think you tested everything but:
|
|
222
|
+
- No record of what you tested
|
|
223
|
+
- Can't re-run when code changes
|
|
224
|
+
- Easy to forget cases under pressure
|
|
225
|
+
- "It worked when I tried it" ≠ comprehensive
|
|
226
|
+
|
|
227
|
+
Automated tests are systematic. They run the same way every time.
|
|
228
|
+
|
|
229
|
+
**"Deleting X hours of work is wasteful"**
|
|
230
|
+
|
|
231
|
+
Sunk cost fallacy. The time is already gone. Your choice now:
|
|
232
|
+
- Delete and rewrite with TDD (X more hours, high confidence)
|
|
233
|
+
- Keep it and add tests after (30 min, low confidence, likely bugs)
|
|
234
|
+
|
|
235
|
+
The "waste" is keeping code you can't trust. Working code without real tests is technical debt.
|
|
236
|
+
|
|
237
|
+
**"TDD is dogmatic, being pragmatic means adapting"**
|
|
238
|
+
|
|
239
|
+
TDD IS pragmatic:
|
|
240
|
+
- Finds bugs before commit (faster than debugging after)
|
|
241
|
+
- Prevents regressions (tests catch breaks immediately)
|
|
242
|
+
- Documents behavior (tests show how to use code)
|
|
243
|
+
- Enables refactoring (change freely, tests catch breaks)
|
|
244
|
+
|
|
245
|
+
"Pragmatic" shortcuts = debugging in production = slower.
|
|
246
|
+
|
|
247
|
+
**"Tests after achieve the same goals - it's spirit not ritual"**
|
|
248
|
+
|
|
249
|
+
No. Tests-after answer "What does this do?" Tests-first answer "What should this do?"
|
|
250
|
+
|
|
251
|
+
Tests-after are biased by your implementation. You test what you built, not what's required. You verify remembered edge cases, not discovered ones.
|
|
252
|
+
|
|
253
|
+
Tests-first force edge case discovery before implementing. Tests-after verify you remembered everything (you didn't).
|
|
254
|
+
|
|
255
|
+
30 minutes of tests after ≠ TDD. You get coverage, lose proof tests work.
|
|
256
|
+
|
|
257
|
+
## Common Rationalizations
|
|
258
|
+
|
|
259
|
+
| Excuse | Reality |
|
|
260
|
+
|--------|---------|
|
|
261
|
+
| "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
|
|
262
|
+
| "I'll test after" | Tests passing immediately prove nothing. |
|
|
263
|
+
| "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
|
|
264
|
+
| "Already manually tested" | Ad-hoc ≠ systematic. No record, can't re-run. |
|
|
265
|
+
| "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is technical debt. |
|
|
266
|
+
| "Keep as reference, write tests first" | You'll adapt it. That's testing after. Delete means delete. |
|
|
267
|
+
| "Need to explore first" | Fine. Throw away exploration, start with TDD. |
|
|
268
|
+
| "Test hard = design unclear" | Listen to test. Hard to test = hard to use. |
|
|
269
|
+
| "TDD will slow me down" | TDD faster than debugging. Pragmatic = test-first. |
|
|
270
|
+
| "Manual test faster" | Manual doesn't prove edge cases. You'll re-test every change. |
|
|
271
|
+
| "Existing code has no tests" | You're improving it. Add tests for existing code. |
|
|
272
|
+
|
|
273
|
+
## Red Flags - STOP and Start Over
|
|
274
|
+
|
|
275
|
+
- Code before test
|
|
276
|
+
- Test after implementation
|
|
277
|
+
- Test passes immediately
|
|
278
|
+
- Can't explain why test failed
|
|
279
|
+
- Tests added "later"
|
|
280
|
+
- Rationalizing "just this once"
|
|
281
|
+
- "I already manually tested it"
|
|
282
|
+
- "Tests after achieve the same purpose"
|
|
283
|
+
- "It's about spirit not ritual"
|
|
284
|
+
- "Keep as reference" or "adapt existing code"
|
|
285
|
+
- "Already spent X hours, deleting is wasteful"
|
|
286
|
+
- "TDD is dogmatic, I'm being pragmatic"
|
|
287
|
+
- "This is different because..."
|
|
288
|
+
|
|
289
|
+
**All of these mean: Delete code. Start over with TDD.**
|
|
290
|
+
|
|
291
|
+
## Example: Bug Fix
|
|
292
|
+
|
|
293
|
+
**Bug:** Empty email accepted
|
|
294
|
+
|
|
295
|
+
**RED**
|
|
296
|
+
```typescript
|
|
297
|
+
test('rejects empty email', async () => {
|
|
298
|
+
const result = await submitForm({ email: '' });
|
|
299
|
+
expect(result.error).toBe('Email required');
|
|
300
|
+
});
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
**Verify RED**
|
|
304
|
+
```bash
|
|
305
|
+
$ npm test
|
|
306
|
+
FAIL: expected 'Email required', got undefined
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**GREEN**
|
|
310
|
+
```typescript
|
|
311
|
+
function submitForm(data: FormData) {
|
|
312
|
+
if (!data.email?.trim()) {
|
|
313
|
+
return { error: 'Email required' };
|
|
314
|
+
}
|
|
315
|
+
// ...
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**Verify GREEN**
|
|
320
|
+
```bash
|
|
321
|
+
$ npm test
|
|
322
|
+
PASS
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**REFACTOR**
|
|
326
|
+
Extract validation for multiple fields if needed.
|
|
327
|
+
|
|
328
|
+
## Verification Checklist
|
|
329
|
+
|
|
330
|
+
Before marking work complete:
|
|
331
|
+
|
|
332
|
+
- [ ] Every new function/method has a test
|
|
333
|
+
- [ ] Watched each test fail before implementing
|
|
334
|
+
- [ ] Each test failed for expected reason (feature missing, not typo)
|
|
335
|
+
- [ ] Wrote minimal code to pass each test
|
|
336
|
+
- [ ] All tests pass
|
|
337
|
+
- [ ] Output pristine (no errors, warnings)
|
|
338
|
+
- [ ] Tests use real code (mocks only if unavoidable)
|
|
339
|
+
- [ ] Edge cases and errors covered
|
|
340
|
+
|
|
341
|
+
Can't check all boxes? You skipped TDD. Start over.
|
|
342
|
+
|
|
343
|
+
## When Stuck
|
|
344
|
+
|
|
345
|
+
| Problem | Solution |
|
|
346
|
+
|---------|----------|
|
|
347
|
+
| Don't know how to test | Write wished-for API. Write assertion first. Ask your human partner. |
|
|
348
|
+
| Test too complicated | Design too complicated. Simplify interface. |
|
|
349
|
+
| Must mock everything | Code too coupled. Use dependency injection. |
|
|
350
|
+
| Test setup huge | Extract helpers. Still complex? Simplify design. |
|
|
351
|
+
|
|
352
|
+
## Debugging Integration
|
|
353
|
+
|
|
354
|
+
Bug found? Write failing test reproducing it. Follow TDD cycle. Test proves fix and prevents regression.
|
|
355
|
+
|
|
356
|
+
Never fix bugs without a test.
|
|
357
|
+
|
|
358
|
+
## Testing Anti-Patterns
|
|
359
|
+
|
|
360
|
+
When adding mocks or test utilities, read @testing-anti-patterns.md to avoid common pitfalls:
|
|
361
|
+
- Testing mock behavior instead of real behavior
|
|
362
|
+
- Adding test-only methods to production classes
|
|
363
|
+
- Mocking without understanding dependencies
|
|
364
|
+
|
|
365
|
+
## Final Rule
|
|
366
|
+
|
|
367
|
+
```
|
|
368
|
+
Production code → test exists and failed first
|
|
369
|
+
Otherwise → not TDD
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
No exceptions without your human partner's permission.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-gaps
|
|
3
|
+
description: Detect missing test coverage and generate test suggestions
|
|
4
|
+
argument-hint: "[--path PATH] [--limit N]"
|
|
5
|
+
allowed-tools: Bash(npx *) mcp__claude-flow__hooks_worker-dispatch Read Grep
|
|
6
|
+
category: dev
|
|
7
|
+
---
|
|
8
|
+
Find test coverage gaps via CLI:
|
|
9
|
+
```bash
|
|
10
|
+
npx @claude-flow/cli@latest hooks coverage-gaps --format table --limit 20
|
|
11
|
+
npx @claude-flow/cli@latest hooks coverage-route --task "add auth tests"
|
|
12
|
+
npx @claude-flow/cli@latest hooks coverage-suggest --path src/
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or dispatch the testgaps worker via MCP:
|
|
16
|
+
`mcp__claude-flow__hooks_worker-dispatch({ trigger: "testgaps" })`
|
|
17
|
+
|
|
18
|
+
For continuous detection, use `/loop` with the `loop-worker` skill targeting the `testgaps` worker.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-triage
|
|
3
|
+
description: Triage failing macOS tests across Xcode and SwiftPM workflows. Use when asked to run macOS tests, narrow failing scopes, explain assertion or crash failures, or separate real test regressions from setup and environment problems.
|
|
4
|
+
category: dev
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Test Triage
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
Use this skill to run the smallest meaningful test scope first, classify
|
|
12
|
+
failures precisely, and avoid treating every test failure like a product bug.
|
|
13
|
+
|
|
14
|
+
## Workflow
|
|
15
|
+
|
|
16
|
+
1. Detect the test harness.
|
|
17
|
+
- Use `xcodebuild test` for Xcode-based projects.
|
|
18
|
+
- Use `swift test` for SwiftPM packages.
|
|
19
|
+
|
|
20
|
+
2. Narrow the scope.
|
|
21
|
+
- If the user gave a target, product, or test filter, use it.
|
|
22
|
+
- If not, prefer the smallest likely failing target before a full suite.
|
|
23
|
+
|
|
24
|
+
3. Classify the result.
|
|
25
|
+
- Build failure
|
|
26
|
+
- Assertion failure
|
|
27
|
+
- Crash or signal
|
|
28
|
+
- Async timing or flake
|
|
29
|
+
- Environment or fixture setup issue
|
|
30
|
+
- Missing entitlement or host app issue
|
|
31
|
+
|
|
32
|
+
4. Rerun intelligently.
|
|
33
|
+
- Use focused reruns when a specific case fails.
|
|
34
|
+
- Avoid burning time on full-suite reruns without new information.
|
|
35
|
+
|
|
36
|
+
5. Summarize clearly.
|
|
37
|
+
- What command ran
|
|
38
|
+
- Which tests failed
|
|
39
|
+
- What kind of failure it was
|
|
40
|
+
- The best next proof step or fix path
|
|
41
|
+
|
|
42
|
+
## Guardrails
|
|
43
|
+
|
|
44
|
+
- Distinguish compilation failures from test execution failures.
|
|
45
|
+
- Call out when a test appears to assume iOS-only or simulator-only behavior.
|
|
46
|
+
- Mark likely flakes as such instead of overstating confidence.
|
|
47
|
+
|
|
48
|
+
## Output Expectations
|
|
49
|
+
|
|
50
|
+
Provide:
|
|
51
|
+
- the command used
|
|
52
|
+
- the smallest failing scope
|
|
53
|
+
- the top failure category
|
|
54
|
+
- a concise explanation of the likely cause
|
|
55
|
+
- the next rerun or fix step
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: typer
|
|
3
|
+
description: Typer best practices and conventions. Use when working with Typer CLIs. Keeps Typer code clean and up to date with the latest features and patterns, updated with new versions. Write new code or refactor and update old code.
|
|
4
|
+
category: dev
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Typer
|
|
8
|
+
|
|
9
|
+
Official Typer skill to write code with best practices, keeping up to date with new versions and features.
|
|
10
|
+
|
|
11
|
+
## Installing typer
|
|
12
|
+
|
|
13
|
+
In a virtual environment, `pip install typer` (with pip) or `uv pip install typer` (with uv). For your library/project, add `typer` to the dependencies in `pyproject.toml`.
|
|
14
|
+
|
|
15
|
+
Do not install `typer-slim` or `typer-cli`, they are both deprecated and will now simply install `typer`.
|
|
16
|
+
|
|
17
|
+
Typer supports Python 3.10 and above.
|
|
18
|
+
|
|
19
|
+
## Use an explicit `Typer` app
|
|
20
|
+
|
|
21
|
+
For maximum generalizability, create an explicit Typer app and register subcommand(s), instead of using `typer.run`:
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import typer
|
|
25
|
+
|
|
26
|
+
app = typer.Typer()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@app.command()
|
|
30
|
+
def hello():
|
|
31
|
+
print(f"Hello World")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if __name__ == "__main__":
|
|
35
|
+
app()
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
instead of:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
# DO NOT DO THIS: Not extensible. Use Typer() instead.
|
|
42
|
+
import typer
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def main():
|
|
46
|
+
print(f"Hello World")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if __name__ == "__main__":
|
|
50
|
+
typer.run(main)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Execute the app
|
|
54
|
+
|
|
55
|
+
To execute the app in the terminal, run
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
python main.py
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
When multiple commands are registered to the Typer app, you have to add the command name:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
python main.py hello
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
To see the automatically generated help documentation, run
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
python main.py --help
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
or set `no_args_is_help` to `True` when creating the `Typer()` add to automatically show the help when running a command without any arguments.
|
|
74
|
+
|
|
75
|
+
## Use `Annotated`
|
|
76
|
+
|
|
77
|
+
Always prefer the `Annotated` style for declarations of CLI arguments and options.
|
|
78
|
+
|
|
79
|
+
It allows us to pass additional metadata that can be used by Typer.
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from typing import Annotated
|
|
83
|
+
|
|
84
|
+
import typer
|
|
85
|
+
|
|
86
|
+
app = typer.Typer()
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@app.command()
|
|
90
|
+
def hello(name: Annotated[str, typer.Argument()] = "World"):
|
|
91
|
+
# Note that name is an optional Argument, as a default is provided
|
|
92
|
+
print(f"Hello {name}")
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
if __name__ == "__main__":
|
|
96
|
+
app()
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
This program can be run as-is, or can provide a specific name:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
python main.py
|
|
103
|
+
python main.py Rick
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
An older way of setting a default value is this:
|
|
107
|
+
```python
|
|
108
|
+
# DO NOT DO THIS: old style. Use Annotated instead.
|
|
109
|
+
|
|
110
|
+
@app.command()
|
|
111
|
+
def main(name: str = typer.Argument(default="World")):
|
|
112
|
+
# Note that name is an optional Argument, as a default is provided
|
|
113
|
+
print(f"Hello {name}")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Similarly, the old style could use ellipsis (...) to explicitely mark an argument as required.
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
# DO NOT DO THIS: old style. Use Annotated without a default value instead.
|
|
120
|
+
|
|
121
|
+
@app.command()
|
|
122
|
+
def main(name: str = typer.Argument(default=...)):
|
|
123
|
+
# Note that name is now a required Argument
|
|
124
|
+
print(f"Hello {name}")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## CLI Options
|
|
128
|
+
|
|
129
|
+
CLI options are declared in a similar fashion as arguments, but will be called on the CLI with a single dash (single letter) or 2 dashes (full name):
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from typing import Annotated
|
|
133
|
+
|
|
134
|
+
import typer
|
|
135
|
+
|
|
136
|
+
app = typer.Typer()
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@app.command()
|
|
140
|
+
def main(user_name: Annotated[str, typer.Option("--name", "-n")]):
|
|
141
|
+
# On the CLI, the required user name can be specified with -n or --name
|
|
142
|
+
print(f"Hello {user_name}")
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
if __name__ == "__main__":
|
|
146
|
+
app()
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
You can run this program as such:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
python main.py -n "Rick"
|
|
153
|
+
python main.py --name "Morty"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### CLI options with multiple values
|
|
157
|
+
|
|
158
|
+
By declaring a CLI option as a list, it can receive multiple values:
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from typing import Annotated
|
|
162
|
+
|
|
163
|
+
import typer
|
|
164
|
+
|
|
165
|
+
app = typer.Typer()
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@app.command()
|
|
169
|
+
def main(user: Annotated[list[str] | None, typer.Option()] = None):
|
|
170
|
+
if not user:
|
|
171
|
+
print(f"No users provided!")
|
|
172
|
+
raise typer.Abort()
|
|
173
|
+
for u in user:
|
|
174
|
+
print(f"Processing user: {u}")
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
if __name__ == "__main__":
|
|
178
|
+
app()
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
This can be executed like so:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
python main.py --user Rick --user Morty --user Summer
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Rich
|
|
188
|
+
|
|
189
|
+
By default, Rich can be used with its custom markup syntax to set colors and styles, e.g.
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
from rich import print
|
|
193
|
+
|
|
194
|
+
print("[bold red]Alert![/bold red] [green]Portal gun[/green] shooting! :boom:")
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Typer supports using Rich formatting in the docstrings and the help messages of CLI arguments and CLI options.
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
from typing import Annotated
|
|
202
|
+
|
|
203
|
+
import typer
|
|
204
|
+
|
|
205
|
+
app = typer.Typer(rich_markup_mode="rich")
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
@app.command()
|
|
209
|
+
def create(
|
|
210
|
+
username: Annotated[
|
|
211
|
+
str, typer.Argument(help="The username to be [green]created[/green]")
|
|
212
|
+
],
|
|
213
|
+
):
|
|
214
|
+
"""
|
|
215
|
+
[bold green]Create[/bold green] a new [italic]shiny[/italic] user. :sparkles:
|
|
216
|
+
|
|
217
|
+
This requires a [underline]username[/underline].
|
|
218
|
+
"""
|
|
219
|
+
print(f"Creating user: {username}")
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
@app.command(help="[bold red]Delete[/bold red] a user with [italic]USERNAME[/italic].")
|
|
223
|
+
def delete(
|
|
224
|
+
username: Annotated[
|
|
225
|
+
str, typer.Argument(help="The username to be [red]deleted[/red]")
|
|
226
|
+
],
|
|
227
|
+
):
|
|
228
|
+
"""
|
|
229
|
+
Some internal utility function to delete.
|
|
230
|
+
"""
|
|
231
|
+
print(f"Deleting user: {username}")
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
if __name__ == "__main__":
|
|
235
|
+
app()
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
To disable Rich formatting, set `rich_markup_mode` to `None` when creating a `Typer()` app. By default (when no value is given), Rich formatting is enabled.
|
|
239
|
+
|
|
240
|
+
### Rich markdown
|
|
241
|
+
|
|
242
|
+
You can also set `rich_markup_mode` to `"markdown"` to use Markdown in the docstring:
|
|
243
|
+
|
|
244
|
+
```python
|
|
245
|
+
from typing import Annotated
|
|
246
|
+
|
|
247
|
+
import typer
|
|
248
|
+
|
|
249
|
+
app = typer.Typer(rich_markup_mode="markdown")
|
|
250
|
+
|
|
251
|
+
@app.command(help="**Delete** a user with *USERNAME*.")
|
|
252
|
+
def delete(
|
|
253
|
+
username: Annotated[str, typer.Argument(help="The username to be **deleted** :boom:")]
|
|
254
|
+
):
|
|
255
|
+
print(f"Deleting user: {username}")
|
|
256
|
+
|
|
257
|
+
if __name__ == "__main__":
|
|
258
|
+
app()
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Click
|
|
262
|
+
|
|
263
|
+
Originally, Typer was built on Click. However, going forward Typer will vendor Click. As such, Click extensions should not be used anymore.
|
|
264
|
+
|
|
265
|
+
Other settings of `Option` and `Argument` that came from Click but shouldn't be used in Typer anymore, include: `expose_value`, `shell_complete`, `show_choices`, `errors`, `prompt_required`, `is_flag`, `flag_value` and `allow_from_autoenv`.
|
|
266
|
+
|
|
267
|
+
Code bases using these should be refactored to use pure Typer functionality.
|