opencode-skills-collection 4.0.53 → 4.0.55
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/bundled-skills/.antigravity-install-manifest.json +3 -2
- package/bundled-skills/00-andruia-consultant/SKILL.md +6 -0
- package/bundled-skills/007/SKILL.md +2 -610
- package/bundled-skills/007/references/detailed-guide.md +647 -0
- package/bundled-skills/10-andruia-skill-smith/SKILL.md +6 -0
- package/bundled-skills/20-andruia-niche-intelligence/SKILL.md +6 -0
- package/bundled-skills/2slides-ppt-generator/SKILL.md +2 -741
- package/bundled-skills/2slides-ppt-generator/references/detailed-guide.md +761 -0
- package/bundled-skills/ab-test-setup/SKILL.md +59 -27
- package/bundled-skills/ab-testing/SKILL.md +1 -1
- package/bundled-skills/acceptance-orchestrator/SKILL.md +6 -0
- package/bundled-skills/accint-commitments/SKILL.md +6 -0
- package/bundled-skills/accint-frames/SKILL.md +6 -0
- package/bundled-skills/accint-solve/SKILL.md +6 -0
- package/bundled-skills/advogado-criminal/SKILL.md +2 -912
- package/bundled-skills/advogado-criminal/references/detailed-guide.md +946 -0
- package/bundled-skills/advogado-especialista/SKILL.md +2 -1071
- package/bundled-skills/advogado-especialista/references/detailed-guide.md +1114 -0
- package/bundled-skills/agent-evaluation/SKILL.md +53 -1102
- package/bundled-skills/agent-evaluation/references/architecture-sketches.md +1112 -0
- package/bundled-skills/agent-memory/SKILL.md +6 -0
- package/bundled-skills/agent-memory-systems/SKILL.md +8 -1042
- package/bundled-skills/agent-memory-systems/references/detailed-guide.md +1088 -0
- package/bundled-skills/agent-squad/SKILL.md +1 -0
- package/bundled-skills/agent-tool-builder/SKILL.md +2 -624
- package/bundled-skills/agent-tool-builder/references/detailed-guide.md +650 -0
- package/bundled-skills/agentic-actions-auditor/SKILL.md +6 -0
- package/bundled-skills/agentmail/SKILL.md +1 -0
- package/bundled-skills/agentphone/SKILL.md +5 -1323
- package/bundled-skills/agentphone/references/detailed-guide.md +1333 -0
- package/bundled-skills/agents-v2-py/SKILL.md +23 -5
- package/bundled-skills/ai-agents-architect/SKILL.md +25 -25
- package/bundled-skills/ai-analyzer/SKILL.md +1 -0
- package/bundled-skills/ai-md/SKILL.md +25 -0
- package/bundled-skills/ai-md/references/detailed-guide.md +512 -0
- package/bundled-skills/ai-product/SKILL.md +2 -726
- package/bundled-skills/ai-product/references/detailed-guide.md +746 -0
- package/bundled-skills/ai-wrapper-product/SKILL.md +2 -641
- package/bundled-skills/ai-wrapper-product/references/detailed-guide.md +659 -0
- package/bundled-skills/airtable-automation/SKILL.md +6 -0
- package/bundled-skills/algolia-search/SKILL.md +2 -893
- package/bundled-skills/algolia-search/references/detailed-guide.md +901 -0
- package/bundled-skills/alpha-vantage/SKILL.md +1 -0
- package/bundled-skills/alternatives-pages/SKILL.md +7 -1
- package/bundled-skills/amazon-alexa/SKILL.md +2 -627
- package/bundled-skills/amazon-alexa/references/detailed-guide.md +644 -0
- package/bundled-skills/analytics/SKILL.md +1 -1
- package/bundled-skills/analytics-product/SKILL.md +57 -44
- package/bundled-skills/analytics-tracking/SKILL.md +21 -12
- package/bundled-skills/analyze-project/SKILL.md +1 -0
- package/bundled-skills/android-dev/SKILL.md +2 -490
- package/bundled-skills/android-dev/references/detailed-guide.md +506 -0
- package/bundled-skills/angular/SKILL.md +4 -783
- package/bundled-skills/angular/references/detailed-guide.md +801 -0
- package/bundled-skills/angular-best-practices/SKILL.md +4 -535
- package/bundled-skills/angular-best-practices/references/detailed-guide.md +549 -0
- package/bundled-skills/angular-state-management/SKILL.md +4 -608
- package/bundled-skills/angular-state-management/references/detailed-guide.md +618 -0
- package/bundled-skills/angular-ui-patterns/SKILL.md +2 -498
- package/bundled-skills/angular-ui-patterns/references/detailed-guide.md +513 -0
- package/bundled-skills/animejs-animation/SKILL.md +6 -0
- package/bundled-skills/anti-deception/SKILL.md +7 -1
- package/bundled-skills/antigravity-design-expert/SKILL.md +6 -0
- package/bundled-skills/antigravity-maintainer-batch-release/SKILL.md +16 -0
- package/bundled-skills/antigravity-workflows/SKILL.md +20 -3
- package/bundled-skills/antigravity-workflows/references/workflow-cards.md +78 -0
- package/bundled-skills/api-analyzer/SKILL.md +1 -1
- package/bundled-skills/api-designer/SKILL.md +1 -1
- package/bundled-skills/api-integration/SKILL.md +1 -1
- package/bundled-skills/api-onboarding/SKILL.md +1 -1
- package/bundled-skills/api-patterns/SKILL.md +19 -8
- package/bundled-skills/api-patterns/api-style.md +2 -2
- package/bundled-skills/api-patterns/auth.md +3 -2
- package/bundled-skills/api-patterns/graphql.md +1 -1
- package/bundled-skills/api-patterns/scripts/api_validator.py +9 -7
- package/bundled-skills/api-patterns/trpc.md +2 -2
- package/bundled-skills/api-patterns/versioning.md +1 -1
- package/bundled-skills/api-sdk-generator/SKILL.md +1 -1
- package/bundled-skills/api-security-best-practices/SKILL.md +179 -879
- package/bundled-skills/apify-actor-development/SKILL.md +1 -0
- package/bundled-skills/apify-actorization/SKILL.md +1 -0
- package/bundled-skills/apify-audience-analysis/SKILL.md +1 -0
- package/bundled-skills/apify-brand-reputation-monitoring/SKILL.md +1 -0
- package/bundled-skills/apify-competitor-intelligence/SKILL.md +1 -0
- package/bundled-skills/apify-content-analytics/SKILL.md +1 -0
- package/bundled-skills/apify-ecommerce/SKILL.md +1 -0
- package/bundled-skills/apify-influencer-discovery/SKILL.md +1 -0
- package/bundled-skills/apify-lead-generation/SKILL.md +1 -0
- package/bundled-skills/apify-market-research/SKILL.md +1 -0
- package/bundled-skills/apify-trend-analysis/SKILL.md +1 -0
- package/bundled-skills/apify-ultimate-scraper/SKILL.md +1 -0
- package/bundled-skills/appium-skill/SKILL.md +1 -1
- package/bundled-skills/apple-notes-search/SKILL.md +6 -0
- package/bundled-skills/application-performance-performance-optimization/SKILL.md +6 -0
- package/bundled-skills/applicationinsights-web-ts/SKILL.md +1 -1
- package/bundled-skills/ask-matt/SKILL.md +5 -0
- package/bundled-skills/ask-questions-if-underspecified/SKILL.md +1 -0
- package/bundled-skills/astropy/SKILL.md +1 -0
- package/bundled-skills/atlas-contract/SKILL.md +117 -0
- package/bundled-skills/atlas-contract/references/detailed-guide.md +572 -0
- package/bundled-skills/audio-transcriber/SKILL.md +2 -425
- package/bundled-skills/audio-transcriber/references/detailed-guide.md +430 -0
- package/bundled-skills/audit-context-building/SKILL.md +1 -0
- package/bundled-skills/auri-core/SKILL.md +5 -562
- package/bundled-skills/auri-core/references/detailed-guide.md +623 -0
- package/bundled-skills/auth-implementation-patterns/SKILL.md +14 -4
- package/bundled-skills/auth-implementation-patterns/resources/implementation-playbook.md +72 -180
- package/bundled-skills/automated-triage/SKILL.md +6 -0
- package/bundled-skills/autonomous-agent-patterns/SKILL.md +4 -741
- package/bundled-skills/autonomous-agent-patterns/references/detailed-guide.md +751 -0
- package/bundled-skills/autonomous-agents/SKILL.md +8 -1010
- package/bundled-skills/autonomous-agents/references/detailed-guide.md +1065 -0
- package/bundled-skills/awareness-stage-mapper/SKILL.md +6 -0
- package/bundled-skills/aws-agentic-ai/SKILL.md +7 -1
- package/bundled-skills/aws-cdk-development/SKILL.md +1 -1
- package/bundled-skills/aws-cost-operations/SKILL.md +1 -1
- package/bundled-skills/aws-mcp-setup/SKILL.md +1 -1
- package/bundled-skills/aws-serverless/SKILL.md +2 -1305
- package/bundled-skills/aws-serverless/references/detailed-guide.md +1340 -0
- package/bundled-skills/aws-serverless-eda/SKILL.md +1 -1
- package/bundled-skills/aws-skills/SKILL.md +6 -0
- package/bundled-skills/aws-sst-development/SKILL.md +7 -1
- package/bundled-skills/awt-e2e-testing/SKILL.md +7 -0
- package/bundled-skills/azure-functions/SKILL.md +2 -1321
- package/bundled-skills/azure-functions/references/detailed-guide.md +1356 -0
- package/bundled-skills/azure-maps-search-dotnet/SKILL.md +2 -482
- package/bundled-skills/azure-maps-search-dotnet/references/detailed-guide.md +496 -0
- package/bundled-skills/azure-search-documents-py/SKILL.md +2 -515
- package/bundled-skills/azure-search-documents-py/references/detailed-guide.md +548 -0
- package/bundled-skills/azure-storage-file-share-ts/SKILL.md +2 -481
- package/bundled-skills/azure-storage-file-share-ts/references/detailed-guide.md +500 -0
- package/bundled-skills/azure-storage-queue-ts/SKILL.md +2 -512
- package/bundled-skills/azure-storage-queue-ts/references/detailed-guide.md +530 -0
- package/bundled-skills/backend-development-feature-development/SKILL.md +6 -0
- package/bundled-skills/backend-security-coder/resources/implementation-playbook.md +23 -0
- package/bundled-skills/basecamp-automation/SKILL.md +6 -0
- package/bundled-skills/baseline-ui/SKILL.md +6 -0
- package/bundled-skills/bash-pro/SKILL.md +6 -0
- package/bundled-skills/bdi-mental-states/SKILL.md +1 -0
- package/bundled-skills/beautiful-prose/SKILL.md +1 -0
- package/bundled-skills/bill-gates/SKILL.md +2 -778
- package/bundled-skills/bill-gates/references/detailed-guide.md +784 -0
- package/bundled-skills/biopython/SKILL.md +1 -0
- package/bundled-skills/bitbucket-automation/SKILL.md +6 -0
- package/bundled-skills/blog-writing-guide/SKILL.md +6 -0
- package/bundled-skills/box-automation/SKILL.md +6 -0
- package/bundled-skills/brain-to-docs/SKILL.md +6 -0
- package/bundled-skills/brainstorming/SKILL.md +6 -0
- package/bundled-skills/brand-guidelines/SKILL.md +1 -0
- package/bundled-skills/brand-guidelines-anthropic/SKILL.md +23 -8
- package/bundled-skills/brand-guidelines-community/SKILL.md +23 -8
- package/bundled-skills/brand-perception-psychologist/SKILL.md +6 -0
- package/bundled-skills/brooks-audit/SKILL.md +1 -1
- package/bundled-skills/brooks-debt/SKILL.md +1 -1
- package/bundled-skills/brooks-harness/SKILL.md +1 -1
- package/bundled-skills/brooks-review/SKILL.md +7 -1
- package/bundled-skills/brooks-sweep/SKILL.md +1 -1
- package/bundled-skills/brooks-test/SKILL.md +1 -1
- package/bundled-skills/browser-automation/SKILL.md +18 -1044
- package/bundled-skills/browser-automation/references/detailed-guide.md +852 -0
- package/bundled-skills/bug-hunt-swarm/SKILL.md +7 -1
- package/bundled-skills/build/SKILL.md +5 -627
- package/bundled-skills/build/references/detailed-guide.md +637 -0
- package/bundled-skills/bun-development/SKILL.md +4 -678
- package/bundled-skills/bun-development/references/detailed-guide.md +691 -0
- package/bundled-skills/burpsuite-project-parser/SKILL.md +1 -0
- package/bundled-skills/business-analyst/resources/implementation-playbook.md +23 -0
- package/bundled-skills/c-pro/SKILL.md +6 -0
- package/bundled-skills/calendly-automation/SKILL.md +6 -0
- package/bundled-skills/cc-skill-backend-patterns/SKILL.md +2 -572
- package/bundled-skills/cc-skill-backend-patterns/references/detailed-guide.md +584 -0
- package/bundled-skills/cc-skill-coding-standards/SKILL.md +2 -510
- package/bundled-skills/cc-skill-coding-standards/references/detailed-guide.md +523 -0
- package/bundled-skills/cc-skill-continuous-learning/SKILL.md +49 -7
- package/bundled-skills/cc-skill-continuous-learning/config.json +1 -16
- package/bundled-skills/cc-skill-continuous-learning/evaluate-session.sh +56 -59
- package/bundled-skills/cc-skill-frontend-patterns/SKILL.md +2 -621
- package/bundled-skills/cc-skill-frontend-patterns/references/detailed-guide.md +633 -0
- package/bundled-skills/cc-skill-security-review/SKILL.md +4 -36
- package/bundled-skills/cc-skill-security-review/references/detailed-guide.md +40 -0
- package/bundled-skills/cc-skill-strategic-compact/SKILL.md +53 -7
- package/bundled-skills/cc-skill-strategic-compact/suggest-compact.sh +20 -51
- package/bundled-skills/changelog-updates/SKILL.md +6 -528
- package/bundled-skills/changelog-updates/references/detailed-guide.md +540 -0
- package/bundled-skills/chat-widget/SKILL.md +5 -879
- package/bundled-skills/chat-widget/references/detailed-guide.md +890 -0
- package/bundled-skills/cirq/SKILL.md +1 -0
- package/bundled-skills/citation-management/SKILL.md +3 -960
- package/bundled-skills/citation-management/references/detailed-guide.md +975 -0
- package/bundled-skills/ckw-design/SKILL.md +6 -0
- package/bundled-skills/claimable-postgres/SKILL.md +1 -1
- package/bundled-skills/clarity-gate/SKILL.md +3 -635
- package/bundled-skills/clarity-gate/references/detailed-guide.md +653 -0
- package/bundled-skills/claude-ally-health/SKILL.md +6 -0
- package/bundled-skills/claude-code-expert/SKILL.md +2 -527
- package/bundled-skills/claude-code-expert/references/detailed-guide.md +548 -0
- package/bundled-skills/claude-d3js-skill/SKILL.md +2 -798
- package/bundled-skills/claude-d3js-skill/references/detailed-guide.md +811 -0
- package/bundled-skills/claude-in-chrome-troubleshooting/SKILL.md +1 -0
- package/bundled-skills/claude-scientific-skills/SKILL.md +6 -0
- package/bundled-skills/claude-settings-audit/SKILL.md +1 -0
- package/bundled-skills/claude-speed-reader/SKILL.md +6 -0
- package/bundled-skills/claude-win11-speckit-update-skill/SKILL.md +6 -0
- package/bundled-skills/clean-code/SKILL.md +6 -0
- package/bundled-skills/clerk-auth/SKILL.md +2 -812
- package/bundled-skills/clerk-auth/references/detailed-guide.md +820 -0
- package/bundled-skills/clickup-automation/SKILL.md +6 -0
- package/bundled-skills/closed-loop-delivery/SKILL.md +6 -0
- package/bundled-skills/co-marketing/SKILL.md +1 -1
- package/bundled-skills/code-documentation-doc-generate/SKILL.md +16 -1
- package/bundled-skills/code-documentation-doc-generate/resources/implementation-playbook.md +33 -55
- package/bundled-skills/code-refactoring-context-restore/SKILL.md +40 -177
- package/bundled-skills/code-refactoring-tech-debt/SKILL.md +20 -9
- package/bundled-skills/code-simplifier/SKILL.md +1 -0
- package/bundled-skills/codebase-cleanup-tech-debt/SKILL.md +20 -9
- package/bundled-skills/cold-email/SKILL.md +6 -0
- package/bundled-skills/commit/SKILL.md +1 -0
- package/bundled-skills/community-building/SKILL.md +1 -1
- package/bundled-skills/competitor-alternatives/SKILL.md +2 -740
- package/bundled-skills/competitor-alternatives/references/detailed-guide.md +756 -0
- package/bundled-skills/competitor-profiling/SKILL.md +1 -1
- package/bundled-skills/competitor-tracking/SKILL.md +1 -1
- package/bundled-skills/comprehensive-review-full-review/SKILL.md +6 -0
- package/bundled-skills/comprehensive-review-pr-enhance/SKILL.md +1 -0
- package/bundled-skills/computer-use-agents/SKILL.md +2 -2131
- package/bundled-skills/computer-use-agents/references/detailed-guide.md +2158 -0
- package/bundled-skills/computer-vision-expert/SKILL.md +6 -0
- package/bundled-skills/conductor-setup/SKILL.md +1 -0
- package/bundled-skills/confluence-automation/SKILL.md +6 -0
- package/bundled-skills/constant-time-analysis/SKILL.md +1 -0
- package/bundled-skills/container-security-hardening/SKILL.md +4 -915
- package/bundled-skills/container-security-hardening/references/detailed-guide.md +927 -0
- package/bundled-skills/content-creator/SKILL.md +53 -23
- package/bundled-skills/content-creator/assets/content_calendar_template.md +5 -2
- package/bundled-skills/content-creator/references/brand_guidelines.md +7 -3
- package/bundled-skills/content-creator/references/content_frameworks.md +12 -7
- package/bundled-skills/content-creator/references/social_media_optimization.md +61 -317
- package/bundled-skills/content-creator/scripts/brand_voice_analyzer.py +14 -9
- package/bundled-skills/content-creator/scripts/seo_optimizer.py +31 -94
- package/bundled-skills/context-compression/SKILL.md +1 -0
- package/bundled-skills/context-degradation/SKILL.md +1 -0
- package/bundled-skills/context-fundamentals/SKILL.md +1 -0
- package/bundled-skills/context-management-context-restore/SKILL.md +40 -177
- package/bundled-skills/context-optimization/SKILL.md +1 -0
- package/bundled-skills/convex/SKILL.md +4 -766
- package/bundled-skills/convex/references/detailed-guide.md +772 -0
- package/bundled-skills/copilot-sdk/SKILL.md +4 -496
- package/bundled-skills/copilot-sdk/references/detailed-guide.md +516 -0
- package/bundled-skills/copy-editing/SKILL.md +6 -0
- package/bundled-skills/copywriting/SKILL.md +6 -0
- package/bundled-skills/copywriting-psychologist/SKILL.md +6 -0
- package/bundled-skills/create-branch/SKILL.md +1 -0
- package/bundled-skills/create-pr/SKILL.md +7 -0
- package/bundled-skills/cred-omega/SKILL.md +2 -847
- package/bundled-skills/cred-omega/references/detailed-guide.md +872 -0
- package/bundled-skills/cro/SKILL.md +1 -1
- package/bundled-skills/csharp-pro/SKILL.md +6 -0
- package/bundled-skills/cucumber-skill/SKILL.md +1 -1
- package/bundled-skills/customer-psychographic-profiler/SKILL.md +6 -0
- package/bundled-skills/customer-research/SKILL.md +1 -1
- package/bundled-skills/cv-generator/SKILL.md +4 -828
- package/bundled-skills/cv-generator/references/detailed-guide.md +845 -0
- package/bundled-skills/cypress-skill/SKILL.md +1 -1
- package/bundled-skills/daily-gift/SKILL.md +6 -0
- package/bundled-skills/debug-buttercup/SKILL.md +1 -0
- package/bundled-skills/debugger/SKILL.md +6 -0
- package/bundled-skills/debugging-code/SKILL.md +1 -1
- package/bundled-skills/deepapi/SKILL.md +4 -619
- package/bundled-skills/deepapi/references/detailed-guide.md +627 -0
- package/bundled-skills/delegating-to-agents/SKILL.md +6 -0
- package/bundled-skills/deployment-validation-config-validate/SKILL.md +4 -478
- package/bundled-skills/deployment-validation-config-validate/references/detailed-guide.md +484 -0
- package/bundled-skills/design-it/SKILL.md +6 -0
- package/bundled-skills/design-orchestration/SKILL.md +6 -0
- package/bundled-skills/design-spells/SKILL.md +6 -0
- package/bundled-skills/design-system/SKILL.md +7 -1
- package/bundled-skills/design-taste-frontend/SKILL.md +6 -0
- package/bundled-skills/design-thinking/SKILL.md +6 -0
- package/bundled-skills/design-ux/SKILL.md +7 -1
- package/bundled-skills/deterministic-design/SKILL.md +6 -0
- package/bundled-skills/developer-advocacy/SKILL.md +1 -1
- package/bundled-skills/developer-audience-context/SKILL.md +1 -1
- package/bundled-skills/developer-churn/SKILL.md +5 -625
- package/bundled-skills/developer-churn/references/detailed-guide.md +639 -0
- package/bundled-skills/developer-listening/SKILL.md +7 -1
- package/bundled-skills/developer-onboarding/SKILL.md +6 -474
- package/bundled-skills/developer-onboarding/references/detailed-guide.md +486 -0
- package/bundled-skills/developer-sandbox/SKILL.md +6 -414
- package/bundled-skills/developer-sandbox/references/detailed-guide.md +425 -0
- package/bundled-skills/developer-seo/SKILL.md +1 -1
- package/bundled-skills/developer-signup-flow/SKILL.md +1 -1
- package/bundled-skills/devops-troubleshooter/resources/implementation-playbook.md +23 -0
- package/bundled-skills/devrel-content/SKILL.md +1 -1
- package/bundled-skills/diagnosing-bugs/SKILL.md +5 -0
- package/bundled-skills/diary/SKILL.md +1 -0
- package/bundled-skills/differential-review/SKILL.md +1 -0
- package/bundled-skills/discord-automation/SKILL.md +6 -0
- package/bundled-skills/discord-bot-architect/SKILL.md +2 -1434
- package/bundled-skills/discord-bot-architect/references/detailed-guide.md +1465 -0
- package/bundled-skills/distributed-tracing/SKILL.md +22 -435
- package/bundled-skills/distributed-tracing/references/instrumentation.md +13 -0
- package/bundled-skills/distributed-tracing/references/jaeger-setup.md +13 -0
- package/bundled-skills/distributed-tracing/resources/implementation-playbook.md +23 -0
- package/bundled-skills/django-access-review/SKILL.md +1 -0
- package/bundled-skills/django-perf-review/SKILL.md +1 -0
- package/bundled-skills/django-pro/resources/implementation-playbook.md +23 -0
- package/bundled-skills/doc-coauthoring/SKILL.md +6 -0
- package/bundled-skills/docs-architect/SKILL.md +6 -0
- package/bundled-skills/docs-as-marketing/SKILL.md +1 -1
- package/bundled-skills/documentation-generation-doc-generate/SKILL.md +16 -1
- package/bundled-skills/documentation-generation-doc-generate/resources/implementation-playbook.md +33 -55
- package/bundled-skills/doubt-driven-development/SKILL.md +1 -1
- package/bundled-skills/dropbox-automation/SKILL.md +6 -0
- package/bundled-skills/dwarf-expert/SKILL.md +1 -0
- package/bundled-skills/dx-optimizer/SKILL.md +6 -0
- package/bundled-skills/e2e-testing-patterns/SKILL.md +14 -4
- package/bundled-skills/e2e-testing-patterns/resources/implementation-playbook.md +22 -41
- package/bundled-skills/eas-update-insights/SKILL.md +1 -1
- package/bundled-skills/ecl-harness-engineer/SKILL.md +4 -681
- package/bundled-skills/ecl-harness-engineer/references/detailed-guide.md +691 -0
- package/bundled-skills/efficient-web-research/SKILL.md +1 -0
- package/bundled-skills/electron-development/SKILL.md +4 -820
- package/bundled-skills/electron-development/references/detailed-guide.md +828 -0
- package/bundled-skills/elixir-pro/SKILL.md +6 -0
- package/bundled-skills/elon-musk/SKILL.md +5 -1278
- package/bundled-skills/elon-musk/references/detailed-guide.md +1293 -0
- package/bundled-skills/email-sequence/SKILL.md +2 -915
- package/bundled-skills/email-sequence/references/detailed-guide.md +932 -0
- package/bundled-skills/email-systems/SKILL.md +2 -654
- package/bundled-skills/email-systems/references/detailed-guide.md +669 -0
- package/bundled-skills/embedding-strategies/SKILL.md +40 -64
- package/bundled-skills/embedding-strategies/resources/implementation-playbook.md +23 -0
- package/bundled-skills/emergency-card/SKILL.md +1 -0
- package/bundled-skills/emil-design-eng/SKILL.md +4 -673
- package/bundled-skills/emil-design-eng/references/detailed-guide.md +690 -0
- package/bundled-skills/emotional-arc-designer/SKILL.md +6 -0
- package/bundled-skills/enhance-prompt/SKILL.md +1 -0
- package/bundled-skills/error-debugging-error-analysis/SKILL.md +15 -0
- package/bundled-skills/error-debugging-error-analysis/resources/implementation-playbook.md +122 -1125
- package/bundled-skills/error-debugging-multi-agent-review/SKILL.md +42 -214
- package/bundled-skills/error-detective/SKILL.md +6 -0
- package/bundled-skills/error-diagnostics-error-analysis/SKILL.md +15 -0
- package/bundled-skills/error-diagnostics-error-analysis/resources/implementation-playbook.md +122 -1125
- package/bundled-skills/event-sourcing-architect/SKILL.md +6 -0
- package/bundled-skills/event-staffing-compliance/SKILL.md +6 -0
- package/bundled-skills/event-staffing-ordering/SKILL.md +6 -0
- package/bundled-skills/evolution/SKILL.md +1 -0
- package/bundled-skills/executing-plans/SKILL.md +6 -0
- package/bundled-skills/explain-like-socrates/SKILL.md +6 -0
- package/bundled-skills/expo-deployment/SKILL.md +1 -1
- package/bundled-skills/expo-examples/SKILL.md +1 -1
- package/bundled-skills/expo-module/SKILL.md +1 -1
- package/bundled-skills/expo-observe/SKILL.md +1 -1
- package/bundled-skills/expo-ui/SKILL.md +1 -1
- package/bundled-skills/expo-ui-jetpack-compose/SKILL.md +1 -0
- package/bundled-skills/expo-ui-swift-ui/SKILL.md +1 -0
- package/bundled-skills/fable-safe-prompt/SKILL.md +6 -0
- package/bundled-skills/fal-audio/SKILL.md +6 -0
- package/bundled-skills/fal-generate/SKILL.md +6 -0
- package/bundled-skills/fal-image-edit/SKILL.md +6 -0
- package/bundled-skills/fal-platform/SKILL.md +6 -0
- package/bundled-skills/fal-upscale/SKILL.md +6 -0
- package/bundled-skills/fal-workflow/SKILL.md +6 -0
- package/bundled-skills/family-health-analyzer/SKILL.md +1 -0
- package/bundled-skills/fastapi-pro/resources/implementation-playbook.md +23 -0
- package/bundled-skills/favicon/SKILL.md +1 -0
- package/bundled-skills/fda-food-safety-auditor/SKILL.md +1 -0
- package/bundled-skills/fda-medtech-compliance-auditor/SKILL.md +1 -0
- package/bundled-skills/ffuf-claude-skill/SKILL.md +6 -0
- package/bundled-skills/ffuf-web-fuzzing/SKILL.md +5 -492
- package/bundled-skills/ffuf-web-fuzzing/references/detailed-guide.md +510 -0
- package/bundled-skills/file-organizer/SKILL.md +6 -0
- package/bundled-skills/file-uploads/SKILL.md +6 -0
- package/bundled-skills/filesystem-context/SKILL.md +1 -0
- package/bundled-skills/find-bugs/SKILL.md +7 -0
- package/bundled-skills/find-complementary-founders/scripts/assess_profile.py +7 -1
- package/bundled-skills/firebase/SKILL.md +8 -651
- package/bundled-skills/firebase/references/detailed-guide.md +662 -0
- package/bundled-skills/fitness-analyzer/SKILL.md +1 -0
- package/bundled-skills/fix-review/SKILL.md +6 -0
- package/bundled-skills/fixing-metadata/SKILL.md +7 -1
- package/bundled-skills/food-database-query/SKILL.md +5 -772
- package/bundled-skills/food-database-query/references/detailed-guide.md +785 -0
- package/bundled-skills/form-cro/SKILL.md +6 -0
- package/bundled-skills/fp-async/SKILL.md +5 -716
- package/bundled-skills/fp-async/references/detailed-guide.md +726 -0
- package/bundled-skills/fp-backend/SKILL.md +5 -1313
- package/bundled-skills/fp-backend/references/detailed-guide.md +1323 -0
- package/bundled-skills/fp-data-transforms/SKILL.md +5 -1181
- package/bundled-skills/fp-data-transforms/references/detailed-guide.md +1190 -0
- package/bundled-skills/fp-either-ref/SKILL.md +1 -0
- package/bundled-skills/fp-errors/SKILL.md +5 -835
- package/bundled-skills/fp-errors/references/detailed-guide.md +846 -0
- package/bundled-skills/fp-option-ref/SKILL.md +1 -0
- package/bundled-skills/fp-pipe-ref/SKILL.md +1 -0
- package/bundled-skills/fp-pragmatic/SKILL.md +5 -500
- package/bundled-skills/fp-pragmatic/references/detailed-guide.md +510 -0
- package/bundled-skills/fp-react/SKILL.md +3 -761
- package/bundled-skills/fp-react/references/detailed-guide.md +775 -0
- package/bundled-skills/fp-refactor/SKILL.md +5 -1761
- package/bundled-skills/fp-refactor/references/detailed-guide.md +1775 -0
- package/bundled-skills/fp-taskeither-ref/SKILL.md +1 -0
- package/bundled-skills/fp-ts-errors/SKILL.md +4 -835
- package/bundled-skills/fp-ts-errors/references/detailed-guide.md +846 -0
- package/bundled-skills/fp-ts-pragmatic/SKILL.md +4 -500
- package/bundled-skills/fp-ts-pragmatic/references/detailed-guide.md +510 -0
- package/bundled-skills/fp-ts-react/SKILL.md +4 -763
- package/bundled-skills/fp-ts-react/references/detailed-guide.md +775 -0
- package/bundled-skills/fp-types-ref/SKILL.md +1 -0
- package/bundled-skills/framework-migration-legacy-modernize/SKILL.md +6 -0
- package/bundled-skills/free-tool-strategy/SKILL.md +2 -532
- package/bundled-skills/free-tool-strategy/references/detailed-guide.md +550 -0
- package/bundled-skills/freshdesk-automation/SKILL.md +6 -0
- package/bundled-skills/frontend-architecture/SKILL.md +1 -1
- package/bundled-skills/frontend-data-contracts/SKILL.md +1 -1
- package/bundled-skills/frontend-design/SKILL.md +33 -34
- package/bundled-skills/frontend-observability/SKILL.md +1 -1
- package/bundled-skills/frontend-optimistic-mutations/SKILL.md +1 -1
- package/bundled-skills/frontend-security-coder/SKILL.md +5 -5
- package/bundled-skills/frontend-security-coder/resources/implementation-playbook.md +23 -0
- package/bundled-skills/frontend-seo/SKILL.md +6 -675
- package/bundled-skills/frontend-seo/references/detailed-guide.md +688 -0
- package/bundled-skills/frontend-slides-frontend-slides/SKILL.md +7 -1
- package/bundled-skills/frontend-ui-dark-ts/SKILL.md +2 -561
- package/bundled-skills/frontend-ui-dark-ts/references/detailed-guide.md +573 -0
- package/bundled-skills/full-stack-orchestration-full-stack-feature/SKILL.md +6 -0
- package/bundled-skills/game-development/2d-games/SKILL.md +6 -0
- package/bundled-skills/game-development/mobile-games/SKILL.md +6 -0
- package/bundled-skills/game-development/vr-ar/SKILL.md +6 -0
- package/bundled-skills/gcp-cloud-run/SKILL.md +2 -1303
- package/bundled-skills/gcp-cloud-run/references/detailed-guide.md +1350 -0
- package/bundled-skills/gemini-api-dev/SKILL.md +1 -1
- package/bundled-skills/gemini-live-api-dev/SKILL.md +1 -1
- package/bundled-skills/gemini-omni-flash-api/SKILL.md +1 -1
- package/bundled-skills/geo-fundamentals/SKILL.md +6 -0
- package/bundled-skills/geoffrey-hinton/SKILL.md +5 -1235
- package/bundled-skills/geoffrey-hinton/references/detailed-guide.md +1324 -0
- package/bundled-skills/gh-review-requests/SKILL.md +1 -0
- package/bundled-skills/github-actions-advanced/SKILL.md +4 -971
- package/bundled-skills/github-actions-advanced/references/detailed-guide.md +991 -0
- package/bundled-skills/github-actions-templates/SKILL.md +34 -314
- package/bundled-skills/github-actions-templates/references/common-workflows.md +13 -0
- package/bundled-skills/github-actions-templates/resources/implementation-playbook.md +23 -0
- package/bundled-skills/github-automation/SKILL.md +6 -0
- package/bundled-skills/github-workflow-automation/SKILL.md +4 -826
- package/bundled-skills/github-workflow-automation/references/detailed-guide.md +832 -0
- package/bundled-skills/gitlab-automation/SKILL.md +6 -0
- package/bundled-skills/gmail-automation/SKILL.md +1 -0
- package/bundled-skills/go-rod-master/SKILL.md +2 -496
- package/bundled-skills/go-rod-master/references/detailed-guide.md +508 -0
- package/bundled-skills/goal-analyzer/SKILL.md +5 -596
- package/bundled-skills/goal-analyzer/references/detailed-guide.md +602 -0
- package/bundled-skills/google-calendar-automation/SKILL.md +1 -0
- package/bundled-skills/google-docs-automation/SKILL.md +20 -69
- package/bundled-skills/google-drive-automation/SKILL.md +1 -0
- package/bundled-skills/google-sheets-automation/SKILL.md +21 -128
- package/bundled-skills/google-slides-automation/SKILL.md +20 -128
- package/bundled-skills/googlesheets-automation/SKILL.md +6 -0
- package/bundled-skills/gpt-taste/SKILL.md +6 -0
- package/bundled-skills/grafana-dashboards/SKILL.md +6 -6
- package/bundled-skills/grafana-dashboards/references/dashboard-design.md +13 -0
- package/bundled-skills/grafana-dashboards/resources/implementation-playbook.md +23 -0
- package/bundled-skills/graphql/SKILL.md +8 -1031
- package/bundled-skills/graphql/references/detailed-guide.md +1044 -0
- package/bundled-skills/grill-me/SKILL.md +5 -0
- package/bundled-skills/grill-with-docs/SKILL.md +5 -0
- package/bundled-skills/grilling/SKILL.md +5 -0
- package/bundled-skills/growth-engine/SKILL.md +6 -0
- package/bundled-skills/handoff/SKILL.md +5 -0
- package/bundled-skills/haskell-pro/SKILL.md +6 -0
- package/bundled-skills/headline-psychologist/SKILL.md +6 -0
- package/bundled-skills/health-trend-analyzer/SKILL.md +1 -0
- package/bundled-skills/hig-components-content/SKILL.md +6 -0
- package/bundled-skills/hig-components-controls/SKILL.md +6 -0
- package/bundled-skills/hig-components-dialogs/SKILL.md +6 -0
- package/bundled-skills/hig-components-layout/SKILL.md +6 -0
- package/bundled-skills/hig-components-menus/SKILL.md +6 -0
- package/bundled-skills/hig-components-search/SKILL.md +6 -0
- package/bundled-skills/hig-components-status/SKILL.md +6 -0
- package/bundled-skills/hig-components-system/SKILL.md +6 -0
- package/bundled-skills/hig-foundations/SKILL.md +6 -0
- package/bundled-skills/hig-inputs/SKILL.md +6 -0
- package/bundled-skills/hig-patterns/SKILL.md +6 -0
- package/bundled-skills/hig-platforms/SKILL.md +6 -0
- package/bundled-skills/hig-technologies/SKILL.md +6 -0
- package/bundled-skills/high-end-visual-design/SKILL.md +6 -0
- package/bundled-skills/hosted-agents/SKILL.md +7 -0
- package/bundled-skills/hosted-agents-v2-py/SKILL.md +23 -5
- package/bundled-skills/html-injection-testing/SKILL.md +2 -453
- package/bundled-skills/html-injection-testing/references/detailed-guide.md +462 -0
- package/bundled-skills/hubspot-automation/SKILL.md +6 -0
- package/bundled-skills/hubspot-integration/SKILL.md +8 -807
- package/bundled-skills/hubspot-integration/references/detailed-guide.md +815 -0
- package/bundled-skills/hugging-face-cli/SKILL.md +7 -1
- package/bundled-skills/hugging-face-community-evals/SKILL.md +1 -1
- package/bundled-skills/hugging-face-datasets/SKILL.md +5 -430
- package/bundled-skills/hugging-face-datasets/references/detailed-guide.md +442 -0
- package/bundled-skills/hugging-face-evaluation/SKILL.md +5 -640
- package/bundled-skills/hugging-face-evaluation/references/detailed-guide.md +652 -0
- package/bundled-skills/hugging-face-jobs/SKILL.md +3 -801
- package/bundled-skills/hugging-face-jobs/references/detailed-guide.md +821 -0
- package/bundled-skills/hugging-face-model-trainer/SKILL.md +3 -681
- package/bundled-skills/hugging-face-model-trainer/references/detailed-guide.md +702 -0
- package/bundled-skills/hugging-face-paper-publisher/SKILL.md +5 -617
- package/bundled-skills/hugging-face-paper-publisher/references/detailed-guide.md +624 -0
- package/bundled-skills/hugging-face-papers/SKILL.md +1 -1
- package/bundled-skills/hugging-face-tool-builder/SKILL.md +1 -0
- package/bundled-skills/hugging-face-trackio/SKILL.md +1 -1
- package/bundled-skills/hugging-face-vision-trainer/SKILL.md +5 -534
- package/bundled-skills/hugging-face-vision-trainer/references/detailed-guide.md +549 -0
- package/bundled-skills/huggingface-best/SKILL.md +1 -1
- package/bundled-skills/huggingface-lora-space-builder/SKILL.md +1 -1
- package/bundled-skills/huggingface-spaces/SKILL.md +1 -1
- package/bundled-skills/huggingface-tool-builder/SKILL.md +1 -1
- package/bundled-skills/huggingface-zerogpu/SKILL.md +1 -1
- package/bundled-skills/hugo-to-markdown/SKILL.md +1 -1
- package/bundled-skills/hyperexecute-skill/SKILL.md +7 -1
- package/bundled-skills/iconsax-library/SKILL.md +6 -0
- package/bundled-skills/idea-refine/SKILL.md +1 -1
- package/bundled-skills/identity-mirror/SKILL.md +6 -0
- package/bundled-skills/ilya-sutskever/SKILL.md +2 -1126
- package/bundled-skills/ilya-sutskever/references/detailed-guide.md +1167 -0
- package/bundled-skills/image-generator/SKILL.md +4 -320
- package/bundled-skills/image-generator/references/detailed-guide.md +332 -0
- package/bundled-skills/implement/SKILL.md +6 -0
- package/bundled-skills/incident-responder/SKILL.md +6 -0
- package/bundled-skills/incident-responder/resources/implementation-playbook.md +23 -0
- package/bundled-skills/incident-response-incident-response/SKILL.md +6 -0
- package/bundled-skills/industrial-brutalist-ui/SKILL.md +6 -0
- package/bundled-skills/instagram/scripts/config.py +33 -8
- package/bundled-skills/interactive-portfolio/SKILL.md +2 -482
- package/bundled-skills/interactive-portfolio/references/detailed-guide.md +500 -0
- package/bundled-skills/internal-comms/SKILL.md +20 -1
- package/bundled-skills/internal-comms/examples/3p-updates.md +5 -4
- package/bundled-skills/internal-comms/examples/company-newsletter.md +3 -2
- package/bundled-skills/internal-comms/examples/faq-answers.md +1 -0
- package/bundled-skills/internal-comms/examples/general-comms.md +1 -0
- package/bundled-skills/internal-comms-anthropic/SKILL.md +21 -2
- package/bundled-skills/internal-comms-anthropic/examples/3p-updates.md +5 -4
- package/bundled-skills/internal-comms-anthropic/examples/company-newsletter.md +3 -2
- package/bundled-skills/internal-comms-anthropic/examples/faq-answers.md +1 -0
- package/bundled-skills/internal-comms-anthropic/examples/general-comms.md +1 -0
- package/bundled-skills/internal-comms-community/SKILL.md +21 -2
- package/bundled-skills/internal-comms-community/examples/3p-updates.md +48 -0
- package/bundled-skills/internal-comms-community/examples/company-newsletter.md +66 -0
- package/bundled-skills/internal-comms-community/examples/faq-answers.md +31 -0
- package/bundled-skills/internal-comms-community/examples/general-comms.md +17 -0
- package/bundled-skills/ios-debugger-agent/SKILL.md +6 -0
- package/bundled-skills/ios-developer/resources/implementation-playbook.md +23 -0
- package/bundled-skills/issues/SKILL.md +1 -0
- package/bundled-skills/iterate-pr/SKILL.md +1 -0
- package/bundled-skills/javascript-mastery/SKILL.md +4 -625
- package/bundled-skills/javascript-mastery/references/detailed-guide.md +636 -0
- package/bundled-skills/javascript-pro/SKILL.md +6 -0
- package/bundled-skills/jest-skill/SKILL.md +1 -1
- package/bundled-skills/jira-automation/SKILL.md +6 -0
- package/bundled-skills/jobs-to-be-done-analyst/SKILL.md +6 -0
- package/bundled-skills/junit-5-skill/SKILL.md +1 -1
- package/bundled-skills/junta-leiloeiros/scripts/.snyk +5 -0
- package/bundled-skills/junta-leiloeiros/scripts/requirements.txt +2 -0
- package/bundled-skills/k6-load-testing/SKILL.md +2 -544
- package/bundled-skills/k6-load-testing/references/detailed-guide.md +563 -0
- package/bundled-skills/kaizen/SKILL.md +2 -711
- package/bundled-skills/kaizen/references/detailed-guide.md +720 -0
- package/bundled-skills/kpi-dashboard-design/SKILL.md +7 -67
- package/bundled-skills/kpi-dashboard-design/resources/implementation-playbook.md +23 -0
- package/bundled-skills/kpi-dashboard-design/resources/metric-queries.sql +30 -0
- package/bundled-skills/langfuse/SKILL.md +41 -468
- package/bundled-skills/langgraph/SKILL.md +2 -445
- package/bundled-skills/langgraph/references/detailed-guide.md +455 -0
- package/bundled-skills/laravel-expert/SKILL.md +6 -0
- package/bundled-skills/launch-strategy/SKILL.md +6 -0
- package/bundled-skills/lead-magnets/SKILL.md +6 -0
- package/bundled-skills/learn/SKILL.md +5 -0
- package/bundled-skills/legacy-modernizer/SKILL.md +6 -0
- package/bundled-skills/legal-advisor/SKILL.md +6 -0
- package/bundled-skills/leiloeiro-avaliacao/SKILL.md +2 -469
- package/bundled-skills/leiloeiro-avaliacao/references/detailed-guide.md +503 -0
- package/bundled-skills/leiloeiro-edital/SKILL.md +2 -468
- package/bundled-skills/leiloeiro-edital/references/detailed-guide.md +491 -0
- package/bundled-skills/leiloeiro-mercado/SKILL.md +2 -458
- package/bundled-skills/leiloeiro-mercado/references/detailed-guide.md +488 -0
- package/bundled-skills/leiloeiro-risco/SKILL.md +2 -457
- package/bundled-skills/leiloeiro-risco/references/detailed-guide.md +482 -0
- package/bundled-skills/lesson-generator/SKILL.md +5 -0
- package/bundled-skills/lightning-architecture-review/SKILL.md +6 -0
- package/bundled-skills/lightning-channel-factories/SKILL.md +6 -0
- package/bundled-skills/lightning-factory-explainer/SKILL.md +6 -0
- package/bundled-skills/linear-claude-skill/SKILL.md +4 -502
- package/bundled-skills/linear-claude-skill/references/detailed-guide.md +517 -0
- package/bundled-skills/linkedin-cli/SKILL.md +4 -513
- package/bundled-skills/linkedin-cli/references/detailed-guide.md +520 -0
- package/bundled-skills/lint-and-validate/SKILL.md +17 -39
- package/bundled-skills/lint-and-validate/scripts/lint_runner.py +17 -8
- package/bundled-skills/lint-and-validate/scripts/type_coverage.py +77 -167
- package/bundled-skills/linux-privilege-escalation/SKILL.md +2 -426
- package/bundled-skills/linux-privilege-escalation/references/detailed-guide.md +436 -0
- package/bundled-skills/linux-shell-scripting/SKILL.md +2 -473
- package/bundled-skills/linux-shell-scripting/references/detailed-guide.md +481 -0
- package/bundled-skills/llm-app-patterns/SKILL.md +16 -741
- package/bundled-skills/llm-app-patterns/references/detailed-guide.md +760 -0
- package/bundled-skills/llm-council/SKILL.md +4 -550
- package/bundled-skills/llm-council/references/detailed-guide.md +556 -0
- package/bundled-skills/llm-ops/SKILL.md +6 -0
- package/bundled-skills/local-legal-seo-audit/SKILL.md +6 -0
- package/bundled-skills/logic-diff/SKILL.md +1 -1
- package/bundled-skills/logic-explain/SKILL.md +7 -1
- package/bundled-skills/logic-fix-all/SKILL.md +1 -1
- package/bundled-skills/logic-locate/SKILL.md +1 -1
- package/bundled-skills/logic-review/SKILL.md +1 -1
- package/bundled-skills/loki-mode/SKILL.md +4 -696
- package/bundled-skills/loki-mode/references/detailed-guide.md +717 -0
- package/bundled-skills/longbridge-content/SKILL.md +1 -1
- package/bundled-skills/longbridge-fundamentals/SKILL.md +1 -1
- package/bundled-skills/longbridge-market-data/SKILL.md +1 -1
- package/bundled-skills/lookdev-auto/SKILL.md +6 -0
- package/bundled-skills/loopy/SKILL.md +1 -1
- package/bundled-skills/loss-aversion-designer/SKILL.md +6 -0
- package/bundled-skills/machine-learning-ops-ml-pipeline/SKILL.md +6 -0
- package/bundled-skills/magic-animator/SKILL.md +6 -0
- package/bundled-skills/magic-ui-generator/SKILL.md +6 -0
- package/bundled-skills/mailtrap-setting-up-sending-domain/SKILL.md +6 -0
- package/bundled-skills/makepad-animation/SKILL.md +1 -0
- package/bundled-skills/makepad-basics/SKILL.md +1 -0
- package/bundled-skills/makepad-deployment/SKILL.md +1 -0
- package/bundled-skills/makepad-dsl/SKILL.md +1 -0
- package/bundled-skills/makepad-event-action/SKILL.md +1 -0
- package/bundled-skills/makepad-font/SKILL.md +1 -0
- package/bundled-skills/makepad-layout/SKILL.md +1 -0
- package/bundled-skills/makepad-platform/SKILL.md +1 -0
- package/bundled-skills/makepad-reference/SKILL.md +1 -0
- package/bundled-skills/makepad-shaders/SKILL.md +1 -0
- package/bundled-skills/makepad-skills/SKILL.md +6 -0
- package/bundled-skills/makepad-splash/SKILL.md +1 -0
- package/bundled-skills/makepad-widgets/SKILL.md +1 -0
- package/bundled-skills/manage-skills/SKILL.md +1 -0
- package/bundled-skills/marketing-plan/SKILL.md +1 -1
- package/bundled-skills/matematico-tao/SKILL.md +2 -632
- package/bundled-skills/matematico-tao/references/detailed-guide.md +651 -0
- package/bundled-skills/matplotlib/SKILL.md +1 -0
- package/bundled-skills/maxia/SKILL.md +1 -0
- package/bundled-skills/mcp-builder/SKILL.md +46 -14
- package/bundled-skills/mcp-builder/reference/evaluation.md +69 -226
- package/bundled-skills/mcp-builder/reference/mcp_best_practices.md +8 -5
- package/bundled-skills/mcp-builder/reference/node_mcp_server.md +46 -144
- package/bundled-skills/mcp-builder/reference/python_mcp_server.md +42 -80
- package/bundled-skills/mcp-builder/scripts/connections.py +18 -11
- package/bundled-skills/mcp-builder/scripts/evaluation.py +88 -95
- package/bundled-skills/mcp-builder/scripts/example_evaluation.xml +1 -1
- package/bundled-skills/mcp-builder/scripts/requirements.txt +4 -2
- package/bundled-skills/mental-health-analyzer/SKILL.md +5 -974
- package/bundled-skills/mental-health-analyzer/references/detailed-guide.md +1014 -0
- package/bundled-skills/micro-saas-launcher/SKILL.md +2 -473
- package/bundled-skills/micro-saas-launcher/references/detailed-guide.md +491 -0
- package/bundled-skills/minecraft-bukkit-pro/SKILL.md +6 -0
- package/bundled-skills/minimalist-ui/SKILL.md +6 -0
- package/bundled-skills/moatmri/SKILL.md +6 -0
- package/bundled-skills/mobile-developer/resources/implementation-playbook.md +23 -0
- package/bundled-skills/molykit/SKILL.md +1 -0
- package/bundled-skills/monday-automation/SKILL.md +6 -0
- package/bundled-skills/monopoly/SKILL.md +1 -0
- package/bundled-skills/monopoly/patterns/SKILL.md +1 -0
- package/bundled-skills/monopoly/scale-benchmarks/SKILL.md +1 -0
- package/bundled-skills/monopoly/security-checklist/SKILL.md +6 -0
- package/bundled-skills/monopoly/tech-matrix/SKILL.md +1 -0
- package/bundled-skills/monorepo-architect/SKILL.md +6 -0
- package/bundled-skills/monte-carlo-analyze-root-cause/SKILL.md +1 -1
- package/bundled-skills/monte-carlo-performance-diagnosis/SKILL.md +7 -1
- package/bundled-skills/monte-carlo-validation-notebook/SKILL.md +4 -601
- package/bundled-skills/monte-carlo-validation-notebook/references/detailed-guide.md +613 -0
- package/bundled-skills/moodle-external-api-development/SKILL.md +4 -517
- package/bundled-skills/moodle-external-api-development/references/detailed-guide.md +529 -0
- package/bundled-skills/multi-agent-architect/SKILL.md +1 -0
- package/bundled-skills/multi-agent-brainstorming/SKILL.md +6 -0
- package/bundled-skills/multi-agent-patterns/SKILL.md +1 -0
- package/bundled-skills/multi-platform-apps-multi-platform/SKILL.md +6 -0
- package/bundled-skills/multi-platform-apps-multi-platform/resources/implementation-playbook.md +23 -0
- package/bundled-skills/n8n-code-javascript/SKILL.md +3 -667
- package/bundled-skills/n8n-code-javascript/references/detailed-guide.md +683 -0
- package/bundled-skills/n8n-code-python/SKILL.md +3 -664
- package/bundled-skills/n8n-code-python/references/detailed-guide.md +682 -0
- package/bundled-skills/n8n-expression-syntax/SKILL.md +5 -401
- package/bundled-skills/n8n-expression-syntax/references/detailed-guide.md +416 -0
- package/bundled-skills/n8n-mcp-tools-expert/SKILL.md +5 -485
- package/bundled-skills/n8n-mcp-tools-expert/references/detailed-guide.md +499 -0
- package/bundled-skills/n8n-node-configuration/SKILL.md +5 -775
- package/bundled-skills/n8n-node-configuration/references/detailed-guide.md +789 -0
- package/bundled-skills/n8n-validation-expert/SKILL.md +5 -679
- package/bundled-skills/n8n-validation-expert/references/detailed-guide.md +694 -0
- package/bundled-skills/n8n-workflow-patterns/SKILL.md +1 -0
- package/bundled-skills/nanobanana-ppt-skills/SKILL.md +6 -0
- package/bundled-skills/native-data-fetching/SKILL.md +2 -456
- package/bundled-skills/native-data-fetching/references/detailed-guide.md +465 -0
- package/bundled-skills/neon-ai-gateway/SKILL.md +1 -1
- package/bundled-skills/neon-functions/SKILL.md +1 -1
- package/bundled-skills/neon-object-storage/SKILL.md +1 -1
- package/bundled-skills/neon-postgres/SKILL.md +1 -1
- package/bundled-skills/neon-postgres-branches/SKILL.md +1 -1
- package/bundled-skills/neon-postgres-egress-optimizer/SKILL.md +1 -1
- package/bundled-skills/nerdzao-elite/SKILL.md +6 -0
- package/bundled-skills/nerdzao-elite-gemini-high/SKILL.md +6 -0
- package/bundled-skills/nestjs-expert/SKILL.md +2 -524
- package/bundled-skills/nestjs-expert/references/detailed-guide.md +539 -0
- package/bundled-skills/networkx/SKILL.md +1 -0
- package/bundled-skills/new-rails-project/SKILL.md +7 -0
- package/bundled-skills/newman-cicd-integration/SKILL.md +1 -1
- package/bundled-skills/nika/SKILL.md +1 -0
- package/bundled-skills/nosql-expert/SKILL.md +6 -0
- package/bundled-skills/not-a-vibe-coder/SKILL.md +7 -0
- package/bundled-skills/notebooklm/scripts/config.py +33 -11
- package/bundled-skills/notion-template-business/SKILL.md +2 -505
- package/bundled-skills/notion-template-business/references/detailed-guide.md +523 -0
- package/bundled-skills/nutrition-analyzer/SKILL.md +5 -766
- package/bundled-skills/nutrition-analyzer/references/detailed-guide.md +775 -0
- package/bundled-skills/objection-preemptor/SKILL.md +6 -0
- package/bundled-skills/observability-and-instrumentation/SKILL.md +5 -2
- package/bundled-skills/observability-and-instrumentation/references/observability-checklist.md +13 -0
- package/bundled-skills/observability-engineer/SKILL.md +16 -8
- package/bundled-skills/obsidian-bases/SKILL.md +4 -366
- package/bundled-skills/obsidian-bases/references/detailed-guide.md +380 -0
- package/bundled-skills/occupational-health-analyzer/SKILL.md +1 -0
- package/bundled-skills/odoo-accounting-setup/SKILL.md +1 -0
- package/bundled-skills/odoo-automated-tests/SKILL.md +1 -0
- package/bundled-skills/odoo-backup-strategy/SKILL.md +1 -0
- package/bundled-skills/odoo-docker-deployment/SKILL.md +1 -0
- package/bundled-skills/odoo-ecommerce-configurator/SKILL.md +1 -0
- package/bundled-skills/odoo-edi-connector/SKILL.md +1 -0
- package/bundled-skills/odoo-hr-payroll-setup/SKILL.md +1 -0
- package/bundled-skills/odoo-inventory-optimizer/SKILL.md +1 -0
- package/bundled-skills/odoo-l10n-compliance/SKILL.md +1 -0
- package/bundled-skills/odoo-manufacturing-advisor/SKILL.md +1 -0
- package/bundled-skills/odoo-migration-helper/SKILL.md +1 -0
- package/bundled-skills/odoo-module-developer/SKILL.md +1 -0
- package/bundled-skills/odoo-orm-expert/SKILL.md +1 -0
- package/bundled-skills/odoo-performance-tuner/SKILL.md +1 -0
- package/bundled-skills/odoo-project-timesheet/SKILL.md +1 -0
- package/bundled-skills/odoo-purchase-workflow/SKILL.md +1 -0
- package/bundled-skills/odoo-qweb-templates/SKILL.md +1 -0
- package/bundled-skills/odoo-rpc-api/SKILL.md +1 -0
- package/bundled-skills/odoo-sales-crm-expert/SKILL.md +1 -0
- package/bundled-skills/odoo-security-rules/SKILL.md +1 -0
- package/bundled-skills/odoo-shopify-integration/SKILL.md +1 -0
- package/bundled-skills/odoo-upgrade-advisor/SKILL.md +1 -0
- package/bundled-skills/odoo-woocommerce-bridge/SKILL.md +1 -0
- package/bundled-skills/odoo-xml-views-builder/SKILL.md +1 -0
- package/bundled-skills/odw/SKILL.md +6 -0
- package/bundled-skills/offers/SKILL.md +1 -1
- package/bundled-skills/onboarding/SKILL.md +1 -1
- package/bundled-skills/onboarding-psychologist/SKILL.md +6 -0
- package/bundled-skills/one-drive-automation/SKILL.md +6 -0
- package/bundled-skills/openapi-spec-generator/SKILL.md +1 -1
- package/bundled-skills/oral-health-analyzer/SKILL.md +8 -515
- package/bundled-skills/oral-health-analyzer/references/detailed-guide.md +529 -0
- package/bundled-skills/outlook-automation/SKILL.md +6 -0
- package/bundled-skills/pagespeed-enhancer/SKILL.md +4 -520
- package/bundled-skills/pagespeed-enhancer/references/detailed-guide.md +533 -0
- package/bundled-skills/paid-ads/SKILL.md +2 -541
- package/bundled-skills/paid-ads/references/detailed-guide.md +558 -0
- package/bundled-skills/parallel-search-mcp/SKILL.md +134 -0
- package/bundled-skills/payment-integration/SKILL.md +6 -0
- package/bundled-skills/paywall-upgrade-cro/SKILL.md +2 -560
- package/bundled-skills/paywall-upgrade-cro/references/detailed-guide.md +579 -0
- package/bundled-skills/pci-compliance/SKILL.md +23 -469
- package/bundled-skills/pci-compliance/resources/implementation-playbook.md +23 -0
- package/bundled-skills/performance-testing-review-multi-agent-review/SKILL.md +42 -214
- package/bundled-skills/personal-tool-builder/SKILL.md +2 -688
- package/bundled-skills/personal-tool-builder/references/detailed-guide.md +705 -0
- package/bundled-skills/phase-gated-debugging/SKILL.md +6 -0
- package/bundled-skills/photopea-embedded-editor/SKILL.md +3 -1218
- package/bundled-skills/photopea-embedded-editor/references/detailed-guide.md +1252 -0
- package/bundled-skills/php-pro/SKILL.md +6 -0
- package/bundled-skills/pi-custom-model/SKILL.md +6 -0
- package/bundled-skills/pipedrive-automation/SKILL.md +6 -0
- package/bundled-skills/pitch-psychologist/SKILL.md +6 -0
- package/bundled-skills/plaid-fintech/SKILL.md +8 -829
- package/bundled-skills/plaid-fintech/references/detailed-guide.md +837 -0
- package/bundled-skills/plotly/SKILL.md +1 -0
- package/bundled-skills/polars/SKILL.md +1 -0
- package/bundled-skills/popup-cro/SKILL.md +6 -0
- package/bundled-skills/posix-shell-pro/SKILL.md +6 -0
- package/bundled-skills/postgresql-cli/SKILL.md +1 -1
- package/bundled-skills/postman-collection-generator/SKILL.md +1 -1
- package/bundled-skills/postman-newman-automation/SKILL.md +1 -1
- package/bundled-skills/postman-openapi-converter/SKILL.md +1 -1
- package/bundled-skills/postmortem-writing/SKILL.md +1 -1
- package/bundled-skills/postmortem-writing/resources/implementation-playbook.md +23 -0
- package/bundled-skills/power-user-cultivation/SKILL.md +6 -572
- package/bundled-skills/power-user-cultivation/references/detailed-guide.md +585 -0
- package/bundled-skills/pr-writer/SKILL.md +1 -0
- package/bundled-skills/price-psychology-strategist/SKILL.md +6 -0
- package/bundled-skills/pricing/SKILL.md +1 -1
- package/bundled-skills/privacy-mask/SKILL.md +1 -1
- package/bundled-skills/product-decision-agent/SKILL.md +6 -0
- package/bundled-skills/product-inventor/SKILL.md +2 -627
- package/bundled-skills/product-inventor/references/detailed-guide.md +646 -0
- package/bundled-skills/product-manager/SKILL.md +6 -0
- package/bundled-skills/product-marketing/SKILL.md +1 -1
- package/bundled-skills/production-code-audit/SKILL.md +2 -264
- package/bundled-skills/production-code-audit/references/detailed-guide.md +277 -0
- package/bundled-skills/professional-proofreader/SKILL.md +6 -0
- package/bundled-skills/programmatic-seo/SKILL.md +6 -0
- package/bundled-skills/project-development/SKILL.md +1 -0
- package/bundled-skills/project-skill-audit/SKILL.md +6 -0
- package/bundled-skills/public-relations/SKILL.md +1 -1
- package/bundled-skills/pubmed-database/SKILL.md +1 -0
- package/bundled-skills/push-skill-to-github/SKILL.md +6 -0
- package/bundled-skills/pydantic-models-py/SKILL.md +1 -3
- package/bundled-skills/pypict-skill/SKILL.md +6 -0
- package/bundled-skills/pytest-skill/SKILL.md +1 -1
- package/bundled-skills/qiskit/SKILL.md +1 -0
- package/bundled-skills/quant-analyst/SKILL.md +6 -0
- package/bundled-skills/radix-ui-design-system/SKILL.md +2 -693
- package/bundled-skills/radix-ui-design-system/references/detailed-guide.md +711 -0
- package/bundled-skills/rag-engineer/SKILL.md +6 -0
- package/bundled-skills/rclone-cli/SKILL.md +1 -1
- package/bundled-skills/react-flow-architect/SKILL.md +2 -507
- package/bundled-skills/react-flow-architect/references/detailed-guide.md +517 -0
- package/bundled-skills/react-patterns/SKILL.md +6 -0
- package/bundled-skills/read-all-adrs/SKILL.md +6 -0
- package/bundled-skills/readme/SKILL.md +4 -822
- package/bundled-skills/readme/references/detailed-guide.md +829 -0
- package/bundled-skills/redesign-existing-projects/SKILL.md +6 -0
- package/bundled-skills/redis-cli/SKILL.md +1 -1
- package/bundled-skills/referral-program/SKILL.md +2 -508
- package/bundled-skills/referral-program/references/detailed-guide.md +524 -0
- package/bundled-skills/rehabilitation-analyzer/SKILL.md +5 -629
- package/bundled-skills/rehabilitation-analyzer/references/detailed-guide.md +641 -0
- package/bundled-skills/remotion/SKILL.md +1 -0
- package/bundled-skills/research-prompt/SKILL.md +6 -0
- package/bundled-skills/resolving-merge-conflicts/SKILL.md +6 -0
- package/bundled-skills/review-and-simplify-changes/SKILL.md +7 -1
- package/bundled-skills/review-swarm/SKILL.md +7 -1
- package/bundled-skills/risk-manager/SKILL.md +6 -0
- package/bundled-skills/robius-app-architecture/SKILL.md +1 -0
- package/bundled-skills/robius-event-action/SKILL.md +1 -0
- package/bundled-skills/robius-matrix-integration/SKILL.md +1 -0
- package/bundled-skills/robius-state-management/SKILL.md +1 -0
- package/bundled-skills/robius-widget-patterns/SKILL.md +1 -0
- package/bundled-skills/robot-framework-skill/SKILL.md +1 -1
- package/bundled-skills/ruby-pro/SKILL.md +6 -0
- package/bundled-skills/saga-orchestration/SKILL.md +4 -482
- package/bundled-skills/saga-orchestration/references/detailed-guide.md +491 -0
- package/bundled-skills/sales-automator/SKILL.md +6 -0
- package/bundled-skills/salesforce-development/SKILL.md +2 -985
- package/bundled-skills/salesforce-development/references/detailed-guide.md +994 -0
- package/bundled-skills/sam-altman/SKILL.md +5 -1040
- package/bundled-skills/sam-altman/references/detailed-guide.md +1102 -0
- package/bundled-skills/scala-pro/SKILL.md +6 -0
- package/bundled-skills/scanning-tools/SKILL.md +2 -546
- package/bundled-skills/scanning-tools/references/detailed-guide.md +555 -0
- package/bundled-skills/scanpy/SKILL.md +1 -0
- package/bundled-skills/scarcity-urgency-psychologist/SKILL.md +6 -0
- package/bundled-skills/scientific-writing/SKILL.md +3 -691
- package/bundled-skills/scientific-writing/references/detailed-guide.md +702 -0
- package/bundled-skills/scikit-learn/SKILL.md +3 -462
- package/bundled-skills/scikit-learn/references/detailed-guide.md +475 -0
- package/bundled-skills/scroll-experience/SKILL.md +2 -560
- package/bundled-skills/scroll-experience/references/detailed-guide.md +578 -0
- package/bundled-skills/sdk-dx/SKILL.md +6 -517
- package/bundled-skills/sdk-dx/references/detailed-guide.md +530 -0
- package/bundled-skills/seaborn/SKILL.md +5 -661
- package/bundled-skills/seaborn/references/detailed-guide.md +677 -0
- package/bundled-skills/search-specialist/SKILL.md +6 -0
- package/bundled-skills/secrets-management/SKILL.md +24 -349
- package/bundled-skills/secrets-management/references/github-secrets.md +13 -0
- package/bundled-skills/secrets-management/references/vault-setup.md +13 -0
- package/bundled-skills/security/aws-compliance-checker/SKILL.md +4 -492
- package/bundled-skills/security/aws-compliance-checker/references/detailed-guide.md +502 -0
- package/bundled-skills/security-and-hardening/SKILL.md +8 -6
- package/bundled-skills/security-and-hardening/references/security-checklist.md +13 -0
- package/bundled-skills/security-bluebook-builder/SKILL.md +7 -0
- package/bundled-skills/security-scanning-security-hardening/SKILL.md +6 -0
- package/bundled-skills/security-scanning-security-sast/SKILL.md +2 -463
- package/bundled-skills/security-scanning-security-sast/references/detailed-guide.md +476 -0
- package/bundled-skills/segment-cdp/SKILL.md +8 -822
- package/bundled-skills/segment-cdp/references/detailed-guide.md +830 -0
- package/bundled-skills/selenium-skill/SKILL.md +1 -1
- package/bundled-skills/semgrep-rule-creator/SKILL.md +1 -0
- package/bundled-skills/semgrep-rule-variant-creator/SKILL.md +1 -0
- package/bundled-skills/sendgrid-automation/SKILL.md +6 -0
- package/bundled-skills/seo-audit/SKILL.md +33 -44
- package/bundled-skills/seo-content/SKILL.md +6 -0
- package/bundled-skills/seo-content-auditor/SKILL.md +6 -0
- package/bundled-skills/seo-content-planner/resources/implementation-playbook.md +23 -0
- package/bundled-skills/seo-content-writer/SKILL.md +8 -2
- package/bundled-skills/seo-content-writer/resources/implementation-playbook.md +23 -0
- package/bundled-skills/seo-forensic-incident-response/SKILL.md +6 -0
- package/bundled-skills/seo-fundamentals/SKILL.md +6 -0
- package/bundled-skills/seo-programmatic/SKILL.md +6 -0
- package/bundled-skills/sequence-psychologist/SKILL.md +6 -0
- package/bundled-skills/server-management/SKILL.md +6 -0
- package/bundled-skills/service-mesh-expert/SKILL.md +6 -0
- package/bundled-skills/setup-help/SKILL.md +6 -0
- package/bundled-skills/sexual-health-analyzer/SKILL.md +8 -1109
- package/bundled-skills/sexual-health-analyzer/references/detailed-guide.md +1123 -0
- package/bundled-skills/sharp-coder/SKILL.md +1 -0
- package/bundled-skills/sharp-edges/SKILL.md +1 -0
- package/bundled-skills/shodan-reconnaissance/SKILL.md +2 -356
- package/bundled-skills/shodan-reconnaissance/references/detailed-guide.md +366 -0
- package/bundled-skills/shopify-apps/SKILL.md +2 -1477
- package/bundled-skills/shopify-apps/references/detailed-guide.md +1512 -0
- package/bundled-skills/shopify-development/scripts/.snyk +3 -0
- package/bundled-skills/short/SKILL.md +6 -0
- package/bundled-skills/signup-flow-cro/SKILL.md +6 -0
- package/bundled-skills/simplify-code/SKILL.md +6 -0
- package/bundled-skills/skill-creator/SKILL.md +2 -568
- package/bundled-skills/skill-creator/references/detailed-guide.md +581 -0
- package/bundled-skills/skill-creator-ms/SKILL.md +2 -601
- package/bundled-skills/skill-creator-ms/references/detailed-guide.md +614 -0
- package/bundled-skills/skill-improver/SKILL.md +1 -0
- package/bundled-skills/skill-router/SKILL.md +1 -0
- package/bundled-skills/skill-scanner/SKILL.md +1 -0
- package/bundled-skills/skill-security-audit/SKILL.md +87 -0
- package/bundled-skills/skill-seekers/SKILL.md +6 -0
- package/bundled-skills/skill-writer/SKILL.md +1 -0
- package/bundled-skills/skin-health-analyzer/SKILL.md +8 -696
- package/bundled-skills/skin-health-analyzer/references/detailed-guide.md +710 -0
- package/bundled-skills/slack-automation/SKILL.md +6 -0
- package/bundled-skills/slack-bot-builder/SKILL.md +2 -1372
- package/bundled-skills/slack-bot-builder/references/detailed-guide.md +1395 -0
- package/bundled-skills/slack-gif-creator/.snyk +5 -0
- package/bundled-skills/slack-gif-creator/requirements.txt +2 -2
- package/bundled-skills/sleep-analyzer/SKILL.md +5 -764
- package/bundled-skills/sleep-analyzer/references/detailed-guide.md +773 -0
- package/bundled-skills/slo-implementation/SKILL.md +24 -9
- package/bundled-skills/slo-implementation/references/error-budget.md +13 -0
- package/bundled-skills/slo-implementation/references/slo-definitions.md +13 -0
- package/bundled-skills/slo-implementation/resources/implementation-playbook.md +23 -0
- package/bundled-skills/smartui-skill/SKILL.md +1 -1
- package/bundled-skills/smtp-penetration-testing/SKILL.md +2 -346
- package/bundled-skills/smtp-penetration-testing/references/detailed-guide.md +355 -0
- package/bundled-skills/social-content/SKILL.md +2 -797
- package/bundled-skills/social-content/references/detailed-guide.md +816 -0
- package/bundled-skills/social-proof-architect/SKILL.md +6 -0
- package/bundled-skills/software-architecture/SKILL.md +6 -0
- package/bundled-skills/spec-to-code-compliance/SKILL.md +7 -0
- package/bundled-skills/speckit-updater/SKILL.md +1 -0
- package/bundled-skills/speed/SKILL.md +7 -0
- package/bundled-skills/sql-optimization-patterns/SKILL.md +10 -6
- package/bundled-skills/sql-optimization-patterns/resources/implementation-playbook.md +52 -56
- package/bundled-skills/sred-project-organizer/SKILL.md +1 -0
- package/bundled-skills/sred-work-summary/SKILL.md +1 -0
- package/bundled-skills/statsmodels/SKILL.md +3 -586
- package/bundled-skills/statsmodels/references/detailed-guide.md +600 -0
- package/bundled-skills/steve-jobs/SKILL.md +2 -564
- package/bundled-skills/steve-jobs/references/detailed-guide.md +574 -0
- package/bundled-skills/stitch-loop/SKILL.md +1 -0
- package/bundled-skills/stripe-automation/SKILL.md +6 -0
- package/bundled-skills/stripe-integration/SKILL.md +60 -79
- package/bundled-skills/styleseed-design-review/SKILL.md +1 -1
- package/bundled-skills/subagent-orchestrator/SKILL.md +1 -0
- package/bundled-skills/subject-line-psychologist/SKILL.md +6 -0
- package/bundled-skills/supabase/SKILL.md +1 -1
- package/bundled-skills/supabase-automation/SKILL.md +6 -0
- package/bundled-skills/superpowers-lab/SKILL.md +6 -0
- package/bundled-skills/supply-chain-risk-auditor/SKILL.md +7 -0
- package/bundled-skills/swiftui-expert-skill/SKILL.md +1 -1
- package/bundled-skills/sympy/SKILL.md +3 -426
- package/bundled-skills/sympy/references/detailed-guide.md +439 -0
- package/bundled-skills/systematic-debugging/CREATION-LOG.md +3 -0
- package/bundled-skills/systematic-debugging/SKILL.md +30 -34
- package/bundled-skills/systematic-debugging/condition-based-waiting.md +9 -6
- package/bundled-skills/systematic-debugging/defense-in-depth.md +13 -7
- package/bundled-skills/systematic-debugging/find-polluter.sh +77 -57
- package/bundled-skills/systematic-debugging/root-cause-tracing.md +7 -5
- package/bundled-skills/systematic-debugging/test-academic.md +3 -0
- package/bundled-skills/systematic-debugging/test-pressure-1.md +3 -0
- package/bundled-skills/systematic-debugging/test-pressure-2.md +3 -0
- package/bundled-skills/systematic-debugging/test-pressure-3.md +3 -0
- package/bundled-skills/tcm-constitution-analyzer/SKILL.md +5 -655
- package/bundled-skills/tcm-constitution-analyzer/references/detailed-guide.md +660 -0
- package/bundled-skills/tdd-workflows-tdd-cycle/SKILL.md +6 -0
- package/bundled-skills/technical-tutorials/SKILL.md +5 -483
- package/bundled-skills/technical-tutorials/references/detailed-guide.md +496 -0
- package/bundled-skills/telegram/SKILL.md +2 -541
- package/bundled-skills/telegram/assets/boilerplate/nodejs/package-lock.json +1888 -0
- package/bundled-skills/telegram/assets/boilerplate/nodejs/package.json +3 -0
- package/bundled-skills/telegram/references/detailed-guide.md +569 -0
- package/bundled-skills/telegram-mini-app/SKILL.md +2 -643
- package/bundled-skills/telegram-mini-app/references/detailed-guide.md +661 -0
- package/bundled-skills/temporal-python-pro/SKILL.md +6 -0
- package/bundled-skills/terraform-skill/SKILL.md +4 -417
- package/bundled-skills/terraform-skill/references/detailed-guide.md +430 -0
- package/bundled-skills/test-driven-development/SKILL.md +21 -124
- package/bundled-skills/test-driven-development/testing-anti-patterns.md +6 -6
- package/bundled-skills/test-framework-migration-skill/SKILL.md +7 -1
- package/bundled-skills/threat-modeling-expert/SKILL.md +6 -0
- package/bundled-skills/threejs-animation/SKILL.md +5 -551
- package/bundled-skills/threejs-animation/references/detailed-guide.md +566 -0
- package/bundled-skills/threejs-fundamentals/SKILL.md +5 -525
- package/bundled-skills/threejs-fundamentals/references/detailed-guide.md +535 -0
- package/bundled-skills/threejs-geometry/SKILL.md +5 -572
- package/bundled-skills/threejs-geometry/references/detailed-guide.md +587 -0
- package/bundled-skills/threejs-interaction/SKILL.md +5 -666
- package/bundled-skills/threejs-interaction/references/detailed-guide.md +679 -0
- package/bundled-skills/threejs-lighting/SKILL.md +1 -0
- package/bundled-skills/threejs-loaders/SKILL.md +5 -637
- package/bundled-skills/threejs-loaders/references/detailed-guide.md +651 -0
- package/bundled-skills/threejs-materials/SKILL.md +3 -535
- package/bundled-skills/threejs-materials/references/detailed-guide.md +560 -0
- package/bundled-skills/threejs-postprocessing/SKILL.md +5 -617
- package/bundled-skills/threejs-postprocessing/references/detailed-guide.md +630 -0
- package/bundled-skills/threejs-shaders/SKILL.md +5 -679
- package/bundled-skills/threejs-shaders/references/detailed-guide.md +695 -0
- package/bundled-skills/threejs-skills/SKILL.md +4 -683
- package/bundled-skills/threejs-skills/references/detailed-guide.md +693 -0
- package/bundled-skills/threejs-textures/SKILL.md +5 -630
- package/bundled-skills/threejs-textures/references/detailed-guide.md +649 -0
- package/bundled-skills/to-issues/SKILL.md +5 -0
- package/bundled-skills/to-prd/SKILL.md +5 -0
- package/bundled-skills/todoist-automation/SKILL.md +6 -0
- package/bundled-skills/tools-page-seo-optimizer/SKILL.md +2 -580
- package/bundled-skills/tools-page-seo-optimizer/references/detailed-guide.md +602 -0
- package/bundled-skills/top-web-vulnerabilities/SKILL.md +2 -513
- package/bundled-skills/top-web-vulnerabilities/references/detailed-guide.md +523 -0
- package/bundled-skills/train-sentence-transformers/SKILL.md +1 -1
- package/bundled-skills/transformers-js/SKILL.md +5 -669
- package/bundled-skills/transformers-js/references/detailed-guide.md +683 -0
- package/bundled-skills/travel-health-analyzer/SKILL.md +1 -0
- package/bundled-skills/trello-automation/SKILL.md +6 -0
- package/bundled-skills/trigger-dev/SKILL.md +2 -937
- package/bundled-skills/trigger-dev/references/detailed-guide.md +950 -0
- package/bundled-skills/trust-calibrator/SKILL.md +6 -0
- package/bundled-skills/tutorial-engineer/SKILL.md +6 -0
- package/bundled-skills/twilio-communications/SKILL.md +2 -1549
- package/bundled-skills/twilio-communications/references/detailed-guide.md +1574 -0
- package/bundled-skills/typescript-pro/SKILL.md +6 -0
- package/bundled-skills/ui-a11y/SKILL.md +6 -0
- package/bundled-skills/ui-component/SKILL.md +6 -0
- package/bundled-skills/ui-motion/SKILL.md +7 -1
- package/bundled-skills/ui-pattern/SKILL.md +6 -0
- package/bundled-skills/ui-review/SKILL.md +6 -0
- package/bundled-skills/ui-skills/SKILL.md +6 -0
- package/bundled-skills/ui-tokens/SKILL.md +6 -0
- package/bundled-skills/uniprot-database/SKILL.md +1 -0
- package/bundled-skills/unslop-commit/SKILL.md +1 -1
- package/bundled-skills/unslop-file/SKILL.md +1 -1
- package/bundled-skills/unslop-review/SKILL.md +1 -1
- package/bundled-skills/unsplash-integration/SKILL.md +6 -0
- package/bundled-skills/update-swiftui-apis/SKILL.md +1 -1
- package/bundled-skills/upstash-qstash/SKILL.md +2 -919
- package/bundled-skills/upstash-qstash/references/detailed-guide.md +932 -0
- package/bundled-skills/usage-based-pricing/SKILL.md +5 -395
- package/bundled-skills/usage-based-pricing/references/detailed-guide.md +407 -0
- package/bundled-skills/ux-audit/SKILL.md +6 -0
- package/bundled-skills/ux-flow/SKILL.md +6 -0
- package/bundled-skills/ux-persuasion-engineer/SKILL.md +6 -0
- package/bundled-skills/variant-analysis/SKILL.md +1 -0
- package/bundled-skills/varlock/SKILL.md +1 -0
- package/bundled-skills/varlock-claude-skill/SKILL.md +6 -0
- package/bundled-skills/vector-database-engineer/SKILL.md +6 -0
- package/bundled-skills/vector-database-engineer/resources/implementation-playbook.md +23 -0
- package/bundled-skills/vercel-deployment/SKILL.md +2 -650
- package/bundled-skills/vercel-deployment/references/detailed-guide.md +660 -0
- package/bundled-skills/vexor/SKILL.md +6 -0
- package/bundled-skills/vexor-cli/SKILL.md +1 -0
- package/bundled-skills/videodb/scripts/ws_listener.py +8 -1
- package/bundled-skills/visual-emotion-engineer/SKILL.md +6 -0
- package/bundled-skills/vizcom/SKILL.md +6 -0
- package/bundled-skills/voice-agents/SKILL.md +2 -867
- package/bundled-skills/voice-agents/references/detailed-guide.md +890 -0
- package/bundled-skills/voice-ai-development/SKILL.md +2 -583
- package/bundled-skills/voice-ai-development/references/detailed-guide.md +594 -0
- package/bundled-skills/voice-ai-engine-development/SKILL.md +2 -702
- package/bundled-skills/voice-ai-engine-development/references/detailed-guide.md +720 -0
- package/bundled-skills/warren-buffett/SKILL.md +2 -577
- package/bundled-skills/warren-buffett/references/detailed-guide.md +583 -0
- package/bundled-skills/web-performance-optimization/SKILL.md +2 -214
- package/bundled-skills/web-performance-optimization/references/detailed-guide.md +226 -0
- package/bundled-skills/web-scraper/SKILL.md +2 -728
- package/bundled-skills/web-scraper/references/detailed-guide.md +792 -0
- package/bundled-skills/webflow-automation/SKILL.md +6 -0
- package/bundled-skills/weightloss-analyzer/SKILL.md +1 -0
- package/bundled-skills/wellally-tech/SKILL.md +5 -367
- package/bundled-skills/wellally-tech/references/detailed-guide.md +379 -0
- package/bundled-skills/whatsapp-cloud-api/assets/boilerplate/nodejs/package-lock.json +1881 -0
- package/bundled-skills/whatsapp-cloud-api/assets/boilerplate/nodejs/package.json +3 -0
- package/bundled-skills/whatsapp-cloud-api/assets/boilerplate/python/.snyk +3 -0
- package/bundled-skills/wiki-architect/SKILL.md +6 -0
- package/bundled-skills/wiki-changelog/SKILL.md +6 -0
- package/bundled-skills/wiki-onboarding/SKILL.md +6 -0
- package/bundled-skills/wiki-qa/SKILL.md +6 -0
- package/bundled-skills/wiki-researcher/SKILL.md +6 -0
- package/bundled-skills/windows-privilege-escalation/SKILL.md +131 -0
- package/bundled-skills/windows-privilege-escalation/references/detailed-guide.md +397 -0
- package/bundled-skills/wireshark-analysis/SKILL.md +2 -419
- package/bundled-skills/wireshark-analysis/references/detailed-guide.md +429 -0
- package/bundled-skills/wjttc-builder/SKILL.md +1 -1
- package/bundled-skills/wjttc-tester/SKILL.md +1 -1
- package/bundled-skills/wordpress/SKILL.md +2 -572
- package/bundled-skills/wordpress/references/detailed-guide.md +582 -0
- package/bundled-skills/wordpress-penetration-testing/SKILL.md +68 -0
- package/bundled-skills/wordpress-penetration-testing/references/detailed-guide.md +555 -0
- package/bundled-skills/wordpress-plugin-development/SKILL.md +2 -474
- package/bundled-skills/wordpress-plugin-development/references/detailed-guide.md +485 -0
- package/bundled-skills/wordpress-theme-development/SKILL.md +2 -479
- package/bundled-skills/wordpress-theme-development/references/detailed-guide.md +490 -0
- package/bundled-skills/wordpress-woocommerce-development/SKILL.md +2 -605
- package/bundled-skills/wordpress-woocommerce-development/references/detailed-guide.md +615 -0
- package/bundled-skills/workflow-automation/SKILL.md +2 -875
- package/bundled-skills/workflow-automation/references/detailed-guide.md +902 -0
- package/bundled-skills/writing-great-skills/SKILL.md +5 -0
- package/bundled-skills/x-article-publisher-skill/SKILL.md +6 -0
- package/bundled-skills/x402-express-wrapper/SKILL.md +1 -0
- package/bundled-skills/xss-html-injection/SKILL.md +2 -389
- package/bundled-skills/xss-html-injection/references/detailed-guide.md +399 -0
- package/bundled-skills/yann-lecun/SKILL.md +2 -1431
- package/bundled-skills/yann-lecun/references/detailed-guide.md +1484 -0
- package/bundled-skills/yann-lecun-filosofia/SKILL.md +6 -0
- package/bundled-skills/yann-lecun-tecnico/SKILL.md +2 -485
- package/bundled-skills/yann-lecun-tecnico/references/detailed-guide.md +502 -0
- package/bundled-skills/youtube-seo-optimizer/SKILL.md +4 -884
- package/bundled-skills/youtube-seo-optimizer/references/detailed-guide.md +907 -0
- package/bundled-skills/zapier-make-patterns/SKILL.md +2 -728
- package/bundled-skills/zapier-make-patterns/references/detailed-guide.md +752 -0
- package/bundled-skills/zipai-optimizer/SKILL.md +7 -0
- package/bundled-skills/zoom-automation/SKILL.md +6 -0
- package/package.json +1 -1
- package/skills_index.json +541 -383
- package/bundled-skills/docs/AUDIT.md +0 -3
- package/bundled-skills/docs/BUNDLES.md +0 -3
- package/bundled-skills/docs/CATEGORIZATION_IMPLEMENTATION.md +0 -3
- package/bundled-skills/docs/CI_DRIFT_FIX.md +0 -3
- package/bundled-skills/docs/COMMUNITY_GUIDELINES.md +0 -3
- package/bundled-skills/docs/DATE_TRACKING_IMPLEMENTATION.md +0 -3
- package/bundled-skills/docs/EXAMPLES.md +0 -3
- package/bundled-skills/docs/FAQ.md +0 -3
- package/bundled-skills/docs/GETTING_STARTED.md +0 -3
- package/bundled-skills/docs/KIRO_INTEGRATION.md +0 -3
- package/bundled-skills/docs/QUALITY_BAR.md +0 -3
- package/bundled-skills/docs/README.md +0 -51
- package/bundled-skills/docs/SECURITY_GUARDRAILS.md +0 -3
- package/bundled-skills/docs/SEC_SKILLS.md +0 -3
- package/bundled-skills/docs/SKILLS_DATE_TRACKING.md +0 -3
- package/bundled-skills/docs/SKILL_ANATOMY.md +0 -3
- package/bundled-skills/docs/SKILL_TEMPLATE.md +0 -3
- package/bundled-skills/docs/SMART_AUTO_CATEGORIZATION.md +0 -3
- package/bundled-skills/docs/SOURCES.md +0 -3
- package/bundled-skills/docs/USAGE.md +0 -3
- package/bundled-skills/docs/VISUAL_GUIDE.md +0 -3
- package/bundled-skills/docs/WORKFLOWS.md +0 -3
- package/bundled-skills/docs/contributors/community-guidelines.md +0 -4
- package/bundled-skills/docs/contributors/examples.md +0 -760
- package/bundled-skills/docs/contributors/quality-bar.md +0 -104
- package/bundled-skills/docs/contributors/security-guardrails.md +0 -70
- package/bundled-skills/docs/contributors/skill-anatomy.md +0 -637
- package/bundled-skills/docs/contributors/skill-template.md +0 -93
- package/bundled-skills/docs/integrations/jetski-cortex.md +0 -282
- package/bundled-skills/docs/integrations/jetski-gemini-loader/README.md +0 -103
- package/bundled-skills/docs/integrations/jetski-gemini-loader/loader.mjs +0 -154
- package/bundled-skills/docs/integrations/jetski-gemini-loader/package.json +0 -1
- package/bundled-skills/docs/maintainers/aas-agent-first-control-plane-preview-profile.md +0 -63
- package/bundled-skills/docs/maintainers/aas-agent-first-control-plane-v1-design.md +0 -304
- package/bundled-skills/docs/maintainers/aas-agent-first-control-plane-v1-goal.md +0 -171
- package/bundled-skills/docs/maintainers/aas-agent-first-control-plane-v1-worklog.md +0 -104
- package/bundled-skills/docs/maintainers/audit.md +0 -89
- package/bundled-skills/docs/maintainers/backups/README-2026-06-02.md +0 -687
- package/bundled-skills/docs/maintainers/categorization-implementation.md +0 -160
- package/bundled-skills/docs/maintainers/ci-drift-fix.md +0 -64
- package/bundled-skills/docs/maintainers/date-tracking-implementation.md +0 -66
- package/bundled-skills/docs/maintainers/full-repo-audit-2026-05-23.md +0 -289
- package/bundled-skills/docs/maintainers/legacy-redirect-bridge.md +0 -46
- package/bundled-skills/docs/maintainers/merge-batch.md +0 -81
- package/bundled-skills/docs/maintainers/merging-prs.md +0 -79
- package/bundled-skills/docs/maintainers/pr-autonomy.md +0 -102
- package/bundled-skills/docs/maintainers/provenance-identity-exceptions.json +0 -14
- package/bundled-skills/docs/maintainers/release-notes-7.2.0.md +0 -32
- package/bundled-skills/docs/maintainers/release-process.md +0 -124
- package/bundled-skills/docs/maintainers/repo-growth-seo.md +0 -133
- package/bundled-skills/docs/maintainers/rollback-procedure.md +0 -43
- package/bundled-skills/docs/maintainers/security-findings-triage-2026-03-15.csv +0 -34
- package/bundled-skills/docs/maintainers/security-findings-triage-2026-03-15.md +0 -60
- package/bundled-skills/docs/maintainers/security-findings-triage-2026-03-18-addendum.md +0 -22
- package/bundled-skills/docs/maintainers/security-findings-triage-2026-03-29-addendum.md +0 -48
- package/bundled-skills/docs/maintainers/security-findings-triage-2026-03-29-refresh.csv +0 -34
- package/bundled-skills/docs/maintainers/security-findings-triage-2026-03-29-refresh.md +0 -86
- package/bundled-skills/docs/maintainers/skills-date-tracking.md +0 -228
- package/bundled-skills/docs/maintainers/skills-import-2026-03-21.md +0 -81
- package/bundled-skills/docs/maintainers/skills-update-guide.md +0 -92
- package/bundled-skills/docs/maintainers/smart-auto-categorization.md +0 -218
- package/bundled-skills/docs/plugin-submissions/aas-agent-mcp-builder/README.md +0 -19
- package/bundled-skills/docs/plugin-submissions/aas-agent-mcp-builder/evaluation-cases.json +0 -74
- package/bundled-skills/docs/plugin-submissions/aas-agent-mcp-builder/evaluation-results.json +0 -86
- package/bundled-skills/docs/plugin-submissions/aas-agent-mcp-builder/submission.json +0 -41
- package/bundled-skills/docs/sources/LICENSE-MICROSOFT +0 -21
- package/bundled-skills/docs/sources/microsoft-skills-attribution.json +0 -709
- package/bundled-skills/docs/sources/sources.md +0 -179
- package/bundled-skills/docs/users/aas-core.md +0 -225
- package/bundled-skills/docs/users/agent-overload-recovery.md +0 -54
- package/bundled-skills/docs/users/agentic-awesome-skills-vs-awesome-claude-skills.md +0 -44
- package/bundled-skills/docs/users/ai-agent-skills.md +0 -48
- package/bundled-skills/docs/users/best-claude-code-skills-github.md +0 -62
- package/bundled-skills/docs/users/best-cursor-skills-github.md +0 -62
- package/bundled-skills/docs/users/bundles.md +0 -1067
- package/bundled-skills/docs/users/claude-code-skills.md +0 -89
- package/bundled-skills/docs/users/codex-cli-skills.md +0 -88
- package/bundled-skills/docs/users/cursor-skills.md +0 -56
- package/bundled-skills/docs/users/discovery-manifest.md +0 -65
- package/bundled-skills/docs/users/faq.md +0 -521
- package/bundled-skills/docs/users/gemini-cli-skills.md +0 -56
- package/bundled-skills/docs/users/getting-started.md +0 -233
- package/bundled-skills/docs/users/kiro-integration.md +0 -304
- package/bundled-skills/docs/users/local-config.md +0 -152
- package/bundled-skills/docs/users/plugins.md +0 -201
- package/bundled-skills/docs/users/security-and-antivirus.md +0 -63
- package/bundled-skills/docs/users/security-skills.md +0 -1722
- package/bundled-skills/docs/users/skills-library-overview.md +0 -87
- package/bundled-skills/docs/users/skills-vs-mcp-tools.md +0 -108
- package/bundled-skills/docs/users/specialized-plugin-roadmap.md +0 -101
- package/bundled-skills/docs/users/usage.md +0 -465
- package/bundled-skills/docs/users/visual-guide.md +0 -515
- package/bundled-skills/docs/users/walkthrough.md +0 -46
- package/bundled-skills/docs/users/windows-truncation-recovery.md +0 -135
- package/bundled-skills/docs/users/workflows.md +0 -215
- package/bundled-skills/docs/vietnamese/AAS_CORE.vi.md +0 -28
- package/bundled-skills/docs/vietnamese/BUNDLES.vi.md +0 -124
- package/bundled-skills/docs/vietnamese/CONTRIBUTING.vi.md +0 -242
- package/bundled-skills/docs/vietnamese/EXAMPLES.vi.md +0 -56
- package/bundled-skills/docs/vietnamese/FAQ.vi.md +0 -195
- package/bundled-skills/docs/vietnamese/GETTING_STARTED.vi.md +0 -123
- package/bundled-skills/docs/vietnamese/QUALITY_BAR.vi.md +0 -69
- package/bundled-skills/docs/vietnamese/README.vi.md +0 -191
- package/bundled-skills/docs/vietnamese/SECURITY.vi.md +0 -19
- package/bundled-skills/docs/vietnamese/SECURITY_GUARDRAILS.vi.md +0 -51
- package/bundled-skills/docs/vietnamese/SKILLS_README.vi.md +0 -106
- package/bundled-skills/docs/vietnamese/SKILL_ANATOMY.vi.md +0 -633
- package/bundled-skills/docs/vietnamese/SOURCES.vi.md +0 -21
- package/bundled-skills/docs/vietnamese/TRANSLATION_PLAN.vi.md +0 -65
- package/bundled-skills/docs/vietnamese/VISUAL_GUIDE.vi.md +0 -511
- package/bundled-skills/docs/walkthrough.md +0 -3
|
@@ -0,0 +1,1775 @@
|
|
|
1
|
+
# Refactoring Imperative Code to fp-ts - Detailed Guide
|
|
2
|
+
|
|
3
|
+
> This file contains the detailed procedure and reference material extracted from `SKILL.md` for focused loading. The root skill defines activation, examples, safety constraints, and limitations.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
1. [Converting try-catch to Either/TaskEither](#1-converting-try-catch-to-eithertaskeither)
|
|
8
|
+
2. [Converting null checks to Option](#2-converting-null-checks-to-option)
|
|
9
|
+
3. [Converting callbacks to Task](#3-converting-callbacks-to-task)
|
|
10
|
+
4. [Converting class-based DI to Reader](#4-converting-class-based-di-to-reader)
|
|
11
|
+
5. [Converting imperative loops to functional operations](#5-converting-imperative-loops-to-functional-operations)
|
|
12
|
+
6. [Migrating Promise chains to TaskEither](#6-migrating-promise-chains-to-taskeither)
|
|
13
|
+
7. [Common Pitfalls](#7-common-pitfalls)
|
|
14
|
+
8. [Gradual Adoption Strategies](#8-gradual-adoption-strategies)
|
|
15
|
+
9. [When NOT to Refactor](#9-when-not-to-refactor)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## 1. Converting try-catch to Either/TaskEither
|
|
21
|
+
|
|
22
|
+
### The Problem with try-catch
|
|
23
|
+
|
|
24
|
+
Traditional try-catch blocks have several issues:
|
|
25
|
+
- Error handling is implicit and easy to forget
|
|
26
|
+
- The type system doesn't track which functions can throw
|
|
27
|
+
- Control flow is non-linear and harder to reason about
|
|
28
|
+
- Composing multiple fallible operations is verbose
|
|
29
|
+
|
|
30
|
+
### Pattern: Synchronous try-catch to Either
|
|
31
|
+
|
|
32
|
+
#### Before (Imperative)
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
function parseJSON(input: string): unknown {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(input);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw new Error(`Invalid JSON: ${error}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function validateUser(data: unknown): User {
|
|
44
|
+
try {
|
|
45
|
+
if (!data || typeof data !== 'object') {
|
|
46
|
+
throw new Error('Data must be an object');
|
|
47
|
+
}
|
|
48
|
+
const obj = data as Record<string, unknown>;
|
|
49
|
+
if (typeof obj.name !== 'string') {
|
|
50
|
+
throw new Error('Name is required');
|
|
51
|
+
}
|
|
52
|
+
if (typeof obj.age !== 'number') {
|
|
53
|
+
throw new Error('Age must be a number');
|
|
54
|
+
}
|
|
55
|
+
return { name: obj.name, age: obj.age };
|
|
56
|
+
} catch (error) {
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Usage with nested try-catch
|
|
62
|
+
function processUserInput(input: string): User | null {
|
|
63
|
+
try {
|
|
64
|
+
const data = parseJSON(input);
|
|
65
|
+
const user = validateUser(data);
|
|
66
|
+
return user;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error('Failed to process user:', error);
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### After (fp-ts Either)
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import * as E from 'fp-ts/Either';
|
|
78
|
+
import * as J from 'fp-ts/Json';
|
|
79
|
+
import { pipe } from 'fp-ts/function';
|
|
80
|
+
|
|
81
|
+
interface User {
|
|
82
|
+
name: string;
|
|
83
|
+
age: number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Use Json.parse which returns Either<Error, Json>
|
|
87
|
+
const parseJSON = (input: string): E.Either<Error, unknown> =>
|
|
88
|
+
pipe(
|
|
89
|
+
J.parse(input),
|
|
90
|
+
E.mapLeft((e) => new Error(`Invalid JSON: ${e}`))
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// Validation returns Either, making errors explicit in types
|
|
94
|
+
const validateUser = (data: unknown): E.Either<Error, User> => {
|
|
95
|
+
if (!data || typeof data !== 'object') {
|
|
96
|
+
return E.left(new Error('Data must be an object'));
|
|
97
|
+
}
|
|
98
|
+
const obj = data as Record<string, unknown>;
|
|
99
|
+
if (typeof obj.name !== 'string') {
|
|
100
|
+
return E.left(new Error('Name is required'));
|
|
101
|
+
}
|
|
102
|
+
if (typeof obj.age !== 'number') {
|
|
103
|
+
return E.left(new Error('Age must be a number'));
|
|
104
|
+
}
|
|
105
|
+
return E.right({ name: obj.name, age: obj.age });
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Compose with pipe and flatMap - errors propagate automatically
|
|
109
|
+
const processUserInput = (input: string): E.Either<Error, User> =>
|
|
110
|
+
pipe(
|
|
111
|
+
parseJSON(input),
|
|
112
|
+
E.flatMap(validateUser)
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Handle both cases explicitly
|
|
116
|
+
pipe(
|
|
117
|
+
processUserInput('{"name": "Alice", "age": 30}'),
|
|
118
|
+
E.match(
|
|
119
|
+
(error) => console.error('Failed to process user:', error.message),
|
|
120
|
+
(user) => console.log('User:', user)
|
|
121
|
+
)
|
|
122
|
+
);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Step-by-Step Refactoring Guide
|
|
126
|
+
|
|
127
|
+
1. **Identify the error type**: Determine what errors can occur and create appropriate error types
|
|
128
|
+
2. **Change return type**: From `T` to `Either<E, T>` where `E` is your error type
|
|
129
|
+
3. **Replace throw statements**: Convert `throw new Error(...)` to `E.left(new Error(...))`
|
|
130
|
+
4. **Replace return statements**: Convert `return value` to `E.right(value)`
|
|
131
|
+
5. **Remove try-catch blocks**: They're no longer needed
|
|
132
|
+
6. **Update callers**: Use `pipe` with `E.flatMap` to chain operations
|
|
133
|
+
|
|
134
|
+
### Pattern: Async try-catch to TaskEither
|
|
135
|
+
|
|
136
|
+
#### Before (Imperative)
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
async function fetchUser(id: string): Promise<User> {
|
|
140
|
+
try {
|
|
141
|
+
const response = await fetch(`/api/users/${id}`);
|
|
142
|
+
if (!response.ok) {
|
|
143
|
+
throw new Error(`HTTP error: ${response.status}`);
|
|
144
|
+
}
|
|
145
|
+
const data = await response.json();
|
|
146
|
+
return validateUser(data);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
throw new Error(`Failed to fetch user: ${error}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async function fetchUserPosts(userId: string): Promise<Post[]> {
|
|
153
|
+
try {
|
|
154
|
+
const response = await fetch(`/api/users/${userId}/posts`);
|
|
155
|
+
if (!response.ok) {
|
|
156
|
+
throw new Error(`HTTP error: ${response.status}`);
|
|
157
|
+
}
|
|
158
|
+
return await response.json();
|
|
159
|
+
} catch (error) {
|
|
160
|
+
throw new Error(`Failed to fetch posts: ${error}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Complex orchestration with try-catch
|
|
165
|
+
async function getUserWithPosts(id: string): Promise<{ user: User; posts: Post[] } | null> {
|
|
166
|
+
try {
|
|
167
|
+
const user = await fetchUser(id);
|
|
168
|
+
const posts = await fetchUserPosts(id);
|
|
169
|
+
return { user, posts };
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.error(error);
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### After (fp-ts TaskEither)
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
181
|
+
import * as E from 'fp-ts/Either';
|
|
182
|
+
import { pipe } from 'fp-ts/function';
|
|
183
|
+
|
|
184
|
+
// Wrap fetch in TaskEither
|
|
185
|
+
const fetchUser = (id: string): TE.TaskEither<Error, User> =>
|
|
186
|
+
pipe(
|
|
187
|
+
TE.tryCatch(
|
|
188
|
+
() => fetch(`/api/users/${id}`),
|
|
189
|
+
(reason) => new Error(`Network error: ${reason}`)
|
|
190
|
+
),
|
|
191
|
+
TE.flatMap((response) =>
|
|
192
|
+
response.ok
|
|
193
|
+
? TE.right(response)
|
|
194
|
+
: TE.left(new Error(`HTTP error: ${response.status}`))
|
|
195
|
+
),
|
|
196
|
+
TE.flatMap((response) =>
|
|
197
|
+
TE.tryCatch(
|
|
198
|
+
() => response.json(),
|
|
199
|
+
(reason) => new Error(`JSON parse error: ${reason}`)
|
|
200
|
+
)
|
|
201
|
+
),
|
|
202
|
+
TE.flatMap((data) => TE.fromEither(validateUser(data)))
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const fetchUserPosts = (userId: string): TE.TaskEither<Error, Post[]> =>
|
|
206
|
+
pipe(
|
|
207
|
+
TE.tryCatch(
|
|
208
|
+
() => fetch(`/api/users/${userId}/posts`),
|
|
209
|
+
(reason) => new Error(`Network error: ${reason}`)
|
|
210
|
+
),
|
|
211
|
+
TE.flatMap((response) =>
|
|
212
|
+
response.ok
|
|
213
|
+
? TE.right(response)
|
|
214
|
+
: TE.left(new Error(`HTTP error: ${response.status}`))
|
|
215
|
+
),
|
|
216
|
+
TE.flatMap((response) =>
|
|
217
|
+
TE.tryCatch(
|
|
218
|
+
() => response.json(),
|
|
219
|
+
(reason) => new Error(`JSON parse error: ${reason}`)
|
|
220
|
+
)
|
|
221
|
+
)
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
// Clean composition with automatic error propagation
|
|
225
|
+
const getUserWithPosts = (
|
|
226
|
+
id: string
|
|
227
|
+
): TE.TaskEither<Error, { user: User; posts: Post[] }> =>
|
|
228
|
+
pipe(
|
|
229
|
+
TE.Do,
|
|
230
|
+
TE.bind('user', () => fetchUser(id)),
|
|
231
|
+
TE.bind('posts', () => fetchUserPosts(id))
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
// Execute and handle results
|
|
235
|
+
const main = async () => {
|
|
236
|
+
const result = await getUserWithPosts('123')();
|
|
237
|
+
pipe(
|
|
238
|
+
result,
|
|
239
|
+
E.match(
|
|
240
|
+
(error) => console.error('Failed:', error.message),
|
|
241
|
+
({ user, posts }) => console.log('Success:', user, posts)
|
|
242
|
+
)
|
|
243
|
+
);
|
|
244
|
+
};
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Helper: tryCatch Utility
|
|
248
|
+
|
|
249
|
+
Create a reusable wrapper for functions that might throw:
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
import * as E from 'fp-ts/Either';
|
|
253
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
254
|
+
|
|
255
|
+
// For sync functions
|
|
256
|
+
const tryCatchSync = <A>(f: () => A): E.Either<Error, A> =>
|
|
257
|
+
E.tryCatch(f, (e) => (e instanceof Error ? e : new Error(String(e))));
|
|
258
|
+
|
|
259
|
+
// For async functions
|
|
260
|
+
const tryCatchAsync = <A>(f: () => Promise<A>): TE.TaskEither<Error, A> =>
|
|
261
|
+
TE.tryCatch(f, (e) => (e instanceof Error ? e : new Error(String(e))));
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
## 2. Converting null checks to Option
|
|
268
|
+
|
|
269
|
+
### The Problem with null/undefined
|
|
270
|
+
|
|
271
|
+
- TypeScript's strict null checks help, but null still spreads through code
|
|
272
|
+
- Chained property access requires verbose null guards
|
|
273
|
+
- The distinction between "missing" and "present but null" is unclear
|
|
274
|
+
- Easy to forget null checks leading to runtime errors
|
|
275
|
+
|
|
276
|
+
### Pattern: Simple null checks to Option
|
|
277
|
+
|
|
278
|
+
#### Before (Imperative)
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
interface Config {
|
|
282
|
+
database?: {
|
|
283
|
+
host?: string;
|
|
284
|
+
port?: number;
|
|
285
|
+
credentials?: {
|
|
286
|
+
username?: string;
|
|
287
|
+
password?: string;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function getDatabaseUrl(config: Config): string | null {
|
|
293
|
+
if (!config.database) {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
if (!config.database.host) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
const port = config.database.port ?? 5432;
|
|
300
|
+
|
|
301
|
+
let auth = '';
|
|
302
|
+
if (config.database.credentials) {
|
|
303
|
+
if (config.database.credentials.username && config.database.credentials.password) {
|
|
304
|
+
auth = `${config.database.credentials.username}:${config.database.credentials.password}@`;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return `postgres://${auth}${config.database.host}:${port}`;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Usage requires null check
|
|
312
|
+
const url = getDatabaseUrl(config);
|
|
313
|
+
if (url !== null) {
|
|
314
|
+
connectToDatabase(url);
|
|
315
|
+
} else {
|
|
316
|
+
console.error('Database URL not configured');
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
#### After (fp-ts Option)
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
import * as O from 'fp-ts/Option';
|
|
324
|
+
import { pipe } from 'fp-ts/function';
|
|
325
|
+
|
|
326
|
+
const getDatabaseUrl = (config: Config): O.Option<string> =>
|
|
327
|
+
pipe(
|
|
328
|
+
O.fromNullable(config.database),
|
|
329
|
+
O.flatMap((db) =>
|
|
330
|
+
pipe(
|
|
331
|
+
O.fromNullable(db.host),
|
|
332
|
+
O.map((host) => {
|
|
333
|
+
const port = db.port ?? 5432;
|
|
334
|
+
const auth = pipe(
|
|
335
|
+
O.fromNullable(db.credentials),
|
|
336
|
+
O.flatMap((creds) =>
|
|
337
|
+
pipe(
|
|
338
|
+
O.Do,
|
|
339
|
+
O.bind('username', () => O.fromNullable(creds.username)),
|
|
340
|
+
O.bind('password', () => O.fromNullable(creds.password)),
|
|
341
|
+
O.map(({ username, password }) => `${username}:${password}@`)
|
|
342
|
+
)
|
|
343
|
+
),
|
|
344
|
+
O.getOrElse(() => '')
|
|
345
|
+
);
|
|
346
|
+
return `postgres://${auth}${host}:${port}`;
|
|
347
|
+
})
|
|
348
|
+
)
|
|
349
|
+
)
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
// Usage is explicit about the optional nature
|
|
353
|
+
pipe(
|
|
354
|
+
getDatabaseUrl(config),
|
|
355
|
+
O.match(
|
|
356
|
+
() => console.error('Database URL not configured'),
|
|
357
|
+
(url) => connectToDatabase(url)
|
|
358
|
+
)
|
|
359
|
+
);
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Pattern: Array find operations
|
|
363
|
+
|
|
364
|
+
#### Before (Imperative)
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
interface User {
|
|
368
|
+
id: string;
|
|
369
|
+
name: string;
|
|
370
|
+
email: string;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function findUserById(users: User[], id: string): User | undefined {
|
|
374
|
+
return users.find((u) => u.id === id);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function getUserEmail(users: User[], id: string): string | null {
|
|
378
|
+
const user = findUserById(users, id);
|
|
379
|
+
if (!user) {
|
|
380
|
+
return null;
|
|
381
|
+
}
|
|
382
|
+
return user.email;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// Chained lookups get messy
|
|
386
|
+
function getManagerEmail(users: User[], employee: { managerId?: string }): string | null {
|
|
387
|
+
if (!employee.managerId) {
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
const manager = findUserById(users, employee.managerId);
|
|
391
|
+
if (!manager) {
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
return manager.email;
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
#### After (fp-ts Option)
|
|
399
|
+
|
|
400
|
+
```typescript
|
|
401
|
+
import * as O from 'fp-ts/Option';
|
|
402
|
+
import * as A from 'fp-ts/Array';
|
|
403
|
+
import { pipe } from 'fp-ts/function';
|
|
404
|
+
|
|
405
|
+
const findUserById = (users: User[], id: string): O.Option<User> =>
|
|
406
|
+
A.findFirst<User>((u) => u.id === id)(users);
|
|
407
|
+
|
|
408
|
+
const getUserEmail = (users: User[], id: string): O.Option<string> =>
|
|
409
|
+
pipe(
|
|
410
|
+
findUserById(users, id),
|
|
411
|
+
O.map((user) => user.email)
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
const getManagerEmail = (
|
|
415
|
+
users: User[],
|
|
416
|
+
employee: { managerId?: string }
|
|
417
|
+
): O.Option<string> =>
|
|
418
|
+
pipe(
|
|
419
|
+
O.fromNullable(employee.managerId),
|
|
420
|
+
O.flatMap((managerId) => findUserById(users, managerId)),
|
|
421
|
+
O.map((manager) => manager.email)
|
|
422
|
+
);
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### Step-by-Step Refactoring Guide
|
|
426
|
+
|
|
427
|
+
1. **Identify nullable values**: Find all `T | null`, `T | undefined`, or optional properties
|
|
428
|
+
2. **Wrap with fromNullable**: Convert nullable values to Option at system boundaries
|
|
429
|
+
3. **Change return types**: From `T | null` to `Option<T>`
|
|
430
|
+
4. **Replace null checks**: Use `O.map`, `O.flatMap`, `O.filter` instead of if statements
|
|
431
|
+
5. **Handle at boundaries**: Use `O.getOrElse`, `O.match`, or `O.toNullable` when interfacing with non-fp code
|
|
432
|
+
|
|
433
|
+
### Converting Between Option and Either
|
|
434
|
+
|
|
435
|
+
```typescript
|
|
436
|
+
import * as O from 'fp-ts/Option';
|
|
437
|
+
import * as E from 'fp-ts/Either';
|
|
438
|
+
import { pipe } from 'fp-ts/function';
|
|
439
|
+
|
|
440
|
+
// Option to Either: provide error for None case
|
|
441
|
+
const optionToEither = <E, A>(onNone: () => E) => (
|
|
442
|
+
option: O.Option<A>
|
|
443
|
+
): E.Either<E, A> =>
|
|
444
|
+
pipe(
|
|
445
|
+
option,
|
|
446
|
+
E.fromOption(onNone)
|
|
447
|
+
);
|
|
448
|
+
|
|
449
|
+
// Example
|
|
450
|
+
const findUser = (id: string): O.Option<User> => /* ... */;
|
|
451
|
+
|
|
452
|
+
const getUser = (id: string): E.Either<Error, User> =>
|
|
453
|
+
pipe(
|
|
454
|
+
findUser(id),
|
|
455
|
+
E.fromOption(() => new Error(`User ${id} not found`))
|
|
456
|
+
);
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
---
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
## 3. Converting callbacks to Task
|
|
463
|
+
|
|
464
|
+
### The Problem with Callbacks
|
|
465
|
+
|
|
466
|
+
- Callback hell makes code hard to read
|
|
467
|
+
- Error handling is inconsistent
|
|
468
|
+
- Difficult to compose and sequence
|
|
469
|
+
- No standard way to handle async operations
|
|
470
|
+
|
|
471
|
+
### Pattern: Node-style callbacks to Task
|
|
472
|
+
|
|
473
|
+
#### Before (Imperative)
|
|
474
|
+
|
|
475
|
+
```typescript
|
|
476
|
+
import * as fs from 'fs';
|
|
477
|
+
|
|
478
|
+
function readFileCallback(
|
|
479
|
+
path: string,
|
|
480
|
+
callback: (error: Error | null, data: string | null) => void
|
|
481
|
+
): void {
|
|
482
|
+
fs.readFile(path, 'utf-8', (err, data) => {
|
|
483
|
+
if (err) {
|
|
484
|
+
callback(err, null);
|
|
485
|
+
} else {
|
|
486
|
+
callback(null, data);
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
function processFile(
|
|
492
|
+
inputPath: string,
|
|
493
|
+
outputPath: string,
|
|
494
|
+
callback: (error: Error | null) => void
|
|
495
|
+
): void {
|
|
496
|
+
readFileCallback(inputPath, (err, data) => {
|
|
497
|
+
if (err) {
|
|
498
|
+
callback(err);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
const processed = data!.toUpperCase();
|
|
502
|
+
fs.writeFile(outputPath, processed, (writeErr) => {
|
|
503
|
+
if (writeErr) {
|
|
504
|
+
callback(writeErr);
|
|
505
|
+
} else {
|
|
506
|
+
callback(null);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// Callback hell
|
|
513
|
+
function processMultipleFiles(
|
|
514
|
+
files: Array<{ input: string; output: string }>,
|
|
515
|
+
callback: (error: Error | null) => void
|
|
516
|
+
): void {
|
|
517
|
+
let completed = 0;
|
|
518
|
+
let hasError = false;
|
|
519
|
+
|
|
520
|
+
files.forEach(({ input, output }) => {
|
|
521
|
+
if (hasError) return;
|
|
522
|
+
processFile(input, output, (err) => {
|
|
523
|
+
if (hasError) return;
|
|
524
|
+
if (err) {
|
|
525
|
+
hasError = true;
|
|
526
|
+
callback(err);
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
completed++;
|
|
530
|
+
if (completed === files.length) {
|
|
531
|
+
callback(null);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
#### After (fp-ts Task/TaskEither)
|
|
539
|
+
|
|
540
|
+
```typescript
|
|
541
|
+
import * as fs from 'fs/promises';
|
|
542
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
543
|
+
import * as A from 'fp-ts/Array';
|
|
544
|
+
import { pipe } from 'fp-ts/function';
|
|
545
|
+
|
|
546
|
+
// Wrap fs.promises in TaskEither
|
|
547
|
+
const readFile = (path: string): TE.TaskEither<Error, string> =>
|
|
548
|
+
TE.tryCatch(
|
|
549
|
+
() => fs.readFile(path, 'utf-8'),
|
|
550
|
+
(e) => (e instanceof Error ? e : new Error(String(e)))
|
|
551
|
+
);
|
|
552
|
+
|
|
553
|
+
const writeFile = (path: string, data: string): TE.TaskEither<Error, void> =>
|
|
554
|
+
TE.tryCatch(
|
|
555
|
+
() => fs.writeFile(path, data),
|
|
556
|
+
(e) => (e instanceof Error ? e : new Error(String(e)))
|
|
557
|
+
);
|
|
558
|
+
|
|
559
|
+
// Clean composition
|
|
560
|
+
const processFile = (
|
|
561
|
+
inputPath: string,
|
|
562
|
+
outputPath: string
|
|
563
|
+
): TE.TaskEither<Error, void> =>
|
|
564
|
+
pipe(
|
|
565
|
+
readFile(inputPath),
|
|
566
|
+
TE.map((data) => data.toUpperCase()),
|
|
567
|
+
TE.flatMap((processed) => writeFile(outputPath, processed))
|
|
568
|
+
);
|
|
569
|
+
|
|
570
|
+
// Process multiple files in parallel or sequence
|
|
571
|
+
const processMultipleFilesParallel = (
|
|
572
|
+
files: Array<{ input: string; output: string }>
|
|
573
|
+
): TE.TaskEither<Error, void[]> =>
|
|
574
|
+
pipe(
|
|
575
|
+
files,
|
|
576
|
+
A.traverse(TE.ApplicativePar)(({ input, output }) =>
|
|
577
|
+
processFile(input, output)
|
|
578
|
+
)
|
|
579
|
+
);
|
|
580
|
+
|
|
581
|
+
const processMultipleFilesSequential = (
|
|
582
|
+
files: Array<{ input: string; output: string }>
|
|
583
|
+
): TE.TaskEither<Error, void[]> =>
|
|
584
|
+
pipe(
|
|
585
|
+
files,
|
|
586
|
+
A.traverse(TE.ApplicativeSeq)(({ input, output }) =>
|
|
587
|
+
processFile(input, output)
|
|
588
|
+
)
|
|
589
|
+
);
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
### Pattern: Converting callback-based APIs
|
|
593
|
+
|
|
594
|
+
```typescript
|
|
595
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
596
|
+
|
|
597
|
+
// Generic callback-to-TaskEither converter
|
|
598
|
+
const fromCallback = <A>(
|
|
599
|
+
f: (callback: (error: Error | null, result: A | null) => void) => void
|
|
600
|
+
): TE.TaskEither<Error, A> =>
|
|
601
|
+
() =>
|
|
602
|
+
new Promise((resolve) => {
|
|
603
|
+
f((error, result) => {
|
|
604
|
+
if (error) {
|
|
605
|
+
resolve({ _tag: 'Left', left: error });
|
|
606
|
+
} else {
|
|
607
|
+
resolve({ _tag: 'Right', right: result as A });
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
// Usage
|
|
613
|
+
const readFileLegacy = (path: string): TE.TaskEither<Error, string> =>
|
|
614
|
+
fromCallback((cb) => fs.readFile(path, 'utf-8', cb));
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
---
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
## 4. Converting class-based DI to Reader
|
|
621
|
+
|
|
622
|
+
### The Problem with Class-based DI
|
|
623
|
+
|
|
624
|
+
- Tight coupling between classes and their dependencies
|
|
625
|
+
- Testing requires mocking entire class hierarchies
|
|
626
|
+
- Dependency injection containers add runtime complexity
|
|
627
|
+
- Hard to trace data flow through the application
|
|
628
|
+
|
|
629
|
+
### Pattern: Service classes to Reader
|
|
630
|
+
|
|
631
|
+
#### Before (Imperative with Classes)
|
|
632
|
+
|
|
633
|
+
```typescript
|
|
634
|
+
// Traditional class-based approach
|
|
635
|
+
interface Logger {
|
|
636
|
+
log(message: string): void;
|
|
637
|
+
error(message: string): void;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
interface UserRepository {
|
|
641
|
+
findById(id: string): Promise<User | null>;
|
|
642
|
+
save(user: User): Promise<void>;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
interface EmailService {
|
|
646
|
+
send(to: string, subject: string, body: string): Promise<void>;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
class UserService {
|
|
650
|
+
constructor(
|
|
651
|
+
private readonly logger: Logger,
|
|
652
|
+
private readonly userRepo: UserRepository,
|
|
653
|
+
private readonly emailService: EmailService
|
|
654
|
+
) {}
|
|
655
|
+
|
|
656
|
+
async updateEmail(userId: string, newEmail: string): Promise<void> {
|
|
657
|
+
this.logger.log(`Updating email for user ${userId}`);
|
|
658
|
+
|
|
659
|
+
const user = await this.userRepo.findById(userId);
|
|
660
|
+
if (!user) {
|
|
661
|
+
this.logger.error(`User ${userId} not found`);
|
|
662
|
+
throw new Error(`User ${userId} not found`);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
const oldEmail = user.email;
|
|
666
|
+
user.email = newEmail;
|
|
667
|
+
|
|
668
|
+
await this.userRepo.save(user);
|
|
669
|
+
|
|
670
|
+
await this.emailService.send(
|
|
671
|
+
oldEmail,
|
|
672
|
+
'Email Changed',
|
|
673
|
+
`Your email has been changed to ${newEmail}`
|
|
674
|
+
);
|
|
675
|
+
|
|
676
|
+
this.logger.log(`Email updated for user ${userId}`);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// Manual DI setup
|
|
681
|
+
const logger = new ConsoleLogger();
|
|
682
|
+
const userRepo = new PostgresUserRepository(dbConnection);
|
|
683
|
+
const emailService = new SmtpEmailService(smtpConfig);
|
|
684
|
+
const userService = new UserService(logger, userRepo, emailService);
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
#### After (fp-ts Reader)
|
|
688
|
+
|
|
689
|
+
```typescript
|
|
690
|
+
import * as R from 'fp-ts/Reader';
|
|
691
|
+
import * as RTE from 'fp-ts/ReaderTaskEither';
|
|
692
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
693
|
+
import { pipe } from 'fp-ts/function';
|
|
694
|
+
|
|
695
|
+
// Define the environment/dependencies as an interface
|
|
696
|
+
interface AppEnv {
|
|
697
|
+
logger: {
|
|
698
|
+
log: (message: string) => void;
|
|
699
|
+
error: (message: string) => void;
|
|
700
|
+
};
|
|
701
|
+
userRepo: {
|
|
702
|
+
findById: (id: string) => TE.TaskEither<Error, User | null>;
|
|
703
|
+
save: (user: User) => TE.TaskEither<Error, void>;
|
|
704
|
+
};
|
|
705
|
+
emailService: {
|
|
706
|
+
send: (to: string, subject: string, body: string) => TE.TaskEither<Error, void>;
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// Helper to access environment
|
|
711
|
+
const ask = RTE.ask<AppEnv, Error>();
|
|
712
|
+
|
|
713
|
+
// Service functions using ReaderTaskEither
|
|
714
|
+
const logInfo = (message: string): RTE.ReaderTaskEither<AppEnv, Error, void> =>
|
|
715
|
+
pipe(
|
|
716
|
+
ask,
|
|
717
|
+
RTE.map((env) => env.logger.log(message))
|
|
718
|
+
);
|
|
719
|
+
|
|
720
|
+
const logError = (message: string): RTE.ReaderTaskEither<AppEnv, Error, void> =>
|
|
721
|
+
pipe(
|
|
722
|
+
ask,
|
|
723
|
+
RTE.map((env) => env.logger.error(message))
|
|
724
|
+
);
|
|
725
|
+
|
|
726
|
+
const findUser = (id: string): RTE.ReaderTaskEither<AppEnv, Error, User | null> =>
|
|
727
|
+
pipe(
|
|
728
|
+
ask,
|
|
729
|
+
RTE.flatMapTaskEither((env) => env.userRepo.findById(id))
|
|
730
|
+
);
|
|
731
|
+
|
|
732
|
+
const saveUser = (user: User): RTE.ReaderTaskEither<AppEnv, Error, void> =>
|
|
733
|
+
pipe(
|
|
734
|
+
ask,
|
|
735
|
+
RTE.flatMapTaskEither((env) => env.userRepo.save(user))
|
|
736
|
+
);
|
|
737
|
+
|
|
738
|
+
const sendEmail = (
|
|
739
|
+
to: string,
|
|
740
|
+
subject: string,
|
|
741
|
+
body: string
|
|
742
|
+
): RTE.ReaderTaskEither<AppEnv, Error, void> =>
|
|
743
|
+
pipe(
|
|
744
|
+
ask,
|
|
745
|
+
RTE.flatMapTaskEither((env) => env.emailService.send(to, subject, body))
|
|
746
|
+
);
|
|
747
|
+
|
|
748
|
+
// The updateEmail function using Reader composition
|
|
749
|
+
const updateEmail = (
|
|
750
|
+
userId: string,
|
|
751
|
+
newEmail: string
|
|
752
|
+
): RTE.ReaderTaskEither<AppEnv, Error, void> =>
|
|
753
|
+
pipe(
|
|
754
|
+
logInfo(`Updating email for user ${userId}`),
|
|
755
|
+
RTE.flatMap(() => findUser(userId)),
|
|
756
|
+
RTE.flatMap((user) => {
|
|
757
|
+
if (!user) {
|
|
758
|
+
return pipe(
|
|
759
|
+
logError(`User ${userId} not found`),
|
|
760
|
+
RTE.flatMap(() => RTE.left(new Error(`User ${userId} not found`)))
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
const oldEmail = user.email;
|
|
764
|
+
const updatedUser = { ...user, email: newEmail };
|
|
765
|
+
|
|
766
|
+
return pipe(
|
|
767
|
+
saveUser(updatedUser),
|
|
768
|
+
RTE.flatMap(() =>
|
|
769
|
+
sendEmail(
|
|
770
|
+
oldEmail,
|
|
771
|
+
'Email Changed',
|
|
772
|
+
`Your email has been changed to ${newEmail}`
|
|
773
|
+
)
|
|
774
|
+
),
|
|
775
|
+
RTE.flatMap(() => logInfo(`Email updated for user ${userId}`))
|
|
776
|
+
);
|
|
777
|
+
})
|
|
778
|
+
);
|
|
779
|
+
|
|
780
|
+
// Build the environment
|
|
781
|
+
const createAppEnv = (): AppEnv => ({
|
|
782
|
+
logger: {
|
|
783
|
+
log: (msg) => console.log(`[INFO] ${msg}`),
|
|
784
|
+
error: (msg) => console.error(`[ERROR] ${msg}`),
|
|
785
|
+
},
|
|
786
|
+
userRepo: {
|
|
787
|
+
findById: (id) => TE.tryCatch(
|
|
788
|
+
() => postgresClient.query('SELECT * FROM users WHERE id = $1', [id]),
|
|
789
|
+
(e) => new Error(String(e))
|
|
790
|
+
),
|
|
791
|
+
save: (user) => TE.tryCatch(
|
|
792
|
+
() => postgresClient.query('UPDATE users SET email = $1 WHERE id = $2', [user.email, user.id]),
|
|
793
|
+
(e) => new Error(String(e))
|
|
794
|
+
),
|
|
795
|
+
},
|
|
796
|
+
emailService: {
|
|
797
|
+
send: (to, subject, body) => TE.tryCatch(
|
|
798
|
+
() => smtpClient.send({ to, subject, body }),
|
|
799
|
+
(e) => new Error(String(e))
|
|
800
|
+
),
|
|
801
|
+
},
|
|
802
|
+
});
|
|
803
|
+
|
|
804
|
+
// Run the program
|
|
805
|
+
const main = async () => {
|
|
806
|
+
const env = createAppEnv();
|
|
807
|
+
const result = await updateEmail('user-123', 'new@email.com')(env)();
|
|
808
|
+
|
|
809
|
+
pipe(
|
|
810
|
+
result,
|
|
811
|
+
E.match(
|
|
812
|
+
(error) => console.error('Failed:', error),
|
|
813
|
+
() => console.log('Success!')
|
|
814
|
+
)
|
|
815
|
+
);
|
|
816
|
+
};
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
### Testing with Reader
|
|
820
|
+
|
|
821
|
+
```typescript
|
|
822
|
+
// Easy to test with mock environment
|
|
823
|
+
const createTestEnv = (): AppEnv => {
|
|
824
|
+
const logs: string[] = [];
|
|
825
|
+
const savedUsers: User[] = [];
|
|
826
|
+
const sentEmails: Array<{ to: string; subject: string; body: string }> = [];
|
|
827
|
+
|
|
828
|
+
return {
|
|
829
|
+
logger: {
|
|
830
|
+
log: (msg) => logs.push(`[INFO] ${msg}`),
|
|
831
|
+
error: (msg) => logs.push(`[ERROR] ${msg}`),
|
|
832
|
+
},
|
|
833
|
+
userRepo: {
|
|
834
|
+
findById: (id) =>
|
|
835
|
+
TE.right(id === 'existing-user' ? { id, email: 'old@email.com', name: 'Test' } : null),
|
|
836
|
+
save: (user) => {
|
|
837
|
+
savedUsers.push(user);
|
|
838
|
+
return TE.right(undefined);
|
|
839
|
+
},
|
|
840
|
+
},
|
|
841
|
+
emailService: {
|
|
842
|
+
send: (to, subject, body) => {
|
|
843
|
+
sentEmails.push({ to, subject, body });
|
|
844
|
+
return TE.right(undefined);
|
|
845
|
+
},
|
|
846
|
+
},
|
|
847
|
+
};
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
// Test
|
|
851
|
+
describe('updateEmail', () => {
|
|
852
|
+
it('should update email and send notification', async () => {
|
|
853
|
+
const env = createTestEnv();
|
|
854
|
+
const result = await updateEmail('existing-user', 'new@email.com')(env)();
|
|
855
|
+
|
|
856
|
+
expect(E.isRight(result)).toBe(true);
|
|
857
|
+
// Assert on captured side effects
|
|
858
|
+
});
|
|
859
|
+
});
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
---
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
## 5. Converting imperative loops to functional operations
|
|
866
|
+
|
|
867
|
+
### Pattern: for loops to map/filter/reduce
|
|
868
|
+
|
|
869
|
+
#### Before (Imperative)
|
|
870
|
+
|
|
871
|
+
```typescript
|
|
872
|
+
interface Product {
|
|
873
|
+
id: string;
|
|
874
|
+
name: string;
|
|
875
|
+
price: number;
|
|
876
|
+
category: string;
|
|
877
|
+
inStock: boolean;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
function processProducts(products: Product[]): {
|
|
881
|
+
totalValue: number;
|
|
882
|
+
categoryCounts: Record<string, number>;
|
|
883
|
+
expensiveProducts: string[];
|
|
884
|
+
} {
|
|
885
|
+
let totalValue = 0;
|
|
886
|
+
const categoryCounts: Record<string, number> = {};
|
|
887
|
+
const expensiveProducts: string[] = [];
|
|
888
|
+
|
|
889
|
+
for (let i = 0; i < products.length; i++) {
|
|
890
|
+
const product = products[i];
|
|
891
|
+
|
|
892
|
+
// Skip out of stock
|
|
893
|
+
if (!product.inStock) {
|
|
894
|
+
continue;
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
// Sum total value
|
|
898
|
+
totalValue += product.price;
|
|
899
|
+
|
|
900
|
+
// Count categories
|
|
901
|
+
if (categoryCounts[product.category] === undefined) {
|
|
902
|
+
categoryCounts[product.category] = 0;
|
|
903
|
+
}
|
|
904
|
+
categoryCounts[product.category]++;
|
|
905
|
+
|
|
906
|
+
// Collect expensive products
|
|
907
|
+
if (product.price > 100) {
|
|
908
|
+
expensiveProducts.push(product.name);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
return { totalValue, categoryCounts, expensiveProducts };
|
|
913
|
+
}
|
|
914
|
+
```
|
|
915
|
+
|
|
916
|
+
#### After (fp-ts functional operations)
|
|
917
|
+
|
|
918
|
+
```typescript
|
|
919
|
+
import * as A from 'fp-ts/Array';
|
|
920
|
+
import * as R from 'fp-ts/Record';
|
|
921
|
+
import { pipe } from 'fp-ts/function';
|
|
922
|
+
import * as N from 'fp-ts/number';
|
|
923
|
+
import * as Monoid from 'fp-ts/Monoid';
|
|
924
|
+
|
|
925
|
+
const processProducts = (products: Product[]) => {
|
|
926
|
+
const inStockProducts = pipe(
|
|
927
|
+
products,
|
|
928
|
+
A.filter((p) => p.inStock)
|
|
929
|
+
);
|
|
930
|
+
|
|
931
|
+
const totalValue = pipe(
|
|
932
|
+
inStockProducts,
|
|
933
|
+
A.map((p) => p.price),
|
|
934
|
+
A.reduce(0, (acc, price) => acc + price)
|
|
935
|
+
);
|
|
936
|
+
|
|
937
|
+
const categoryCounts = pipe(
|
|
938
|
+
inStockProducts,
|
|
939
|
+
A.reduce({} as Record<string, number>, (acc, product) => ({
|
|
940
|
+
...acc,
|
|
941
|
+
[product.category]: (acc[product.category] ?? 0) + 1,
|
|
942
|
+
}))
|
|
943
|
+
);
|
|
944
|
+
|
|
945
|
+
const expensiveProducts = pipe(
|
|
946
|
+
inStockProducts,
|
|
947
|
+
A.filter((p) => p.price > 100),
|
|
948
|
+
A.map((p) => p.name)
|
|
949
|
+
);
|
|
950
|
+
|
|
951
|
+
return { totalValue, categoryCounts, expensiveProducts };
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
// Or using a single pass with foldMap for efficiency
|
|
955
|
+
import { Monoid as M } from 'fp-ts/Monoid';
|
|
956
|
+
|
|
957
|
+
interface ProductStats {
|
|
958
|
+
totalValue: number;
|
|
959
|
+
categoryCounts: Record<string, number>;
|
|
960
|
+
expensiveProducts: string[];
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
const productStatsMonoid: M<ProductStats> = {
|
|
964
|
+
empty: { totalValue: 0, categoryCounts: {}, expensiveProducts: [] },
|
|
965
|
+
concat: (a, b) => ({
|
|
966
|
+
totalValue: a.totalValue + b.totalValue,
|
|
967
|
+
categoryCounts: pipe(
|
|
968
|
+
a.categoryCounts,
|
|
969
|
+
R.union({ concat: (x, y) => x + y })(b.categoryCounts)
|
|
970
|
+
),
|
|
971
|
+
expensiveProducts: [...a.expensiveProducts, ...b.expensiveProducts],
|
|
972
|
+
}),
|
|
973
|
+
};
|
|
974
|
+
|
|
975
|
+
const processProductsSinglePass = (products: Product[]): ProductStats =>
|
|
976
|
+
pipe(
|
|
977
|
+
products,
|
|
978
|
+
A.filter((p) => p.inStock),
|
|
979
|
+
A.foldMap(productStatsMonoid)((product) => ({
|
|
980
|
+
totalValue: product.price,
|
|
981
|
+
categoryCounts: { [product.category]: 1 },
|
|
982
|
+
expensiveProducts: product.price > 100 ? [product.name] : [],
|
|
983
|
+
}))
|
|
984
|
+
);
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
### Pattern: Nested loops to flatMap
|
|
988
|
+
|
|
989
|
+
#### Before (Imperative)
|
|
990
|
+
|
|
991
|
+
```typescript
|
|
992
|
+
interface Order {
|
|
993
|
+
id: string;
|
|
994
|
+
items: OrderItem[];
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
interface OrderItem {
|
|
998
|
+
productId: string;
|
|
999
|
+
quantity: number;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
function getAllProductIds(orders: Order[]): string[] {
|
|
1003
|
+
const productIds: string[] = [];
|
|
1004
|
+
|
|
1005
|
+
for (const order of orders) {
|
|
1006
|
+
for (const item of order.items) {
|
|
1007
|
+
if (!productIds.includes(item.productId)) {
|
|
1008
|
+
productIds.push(item.productId);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
return productIds;
|
|
1014
|
+
}
|
|
1015
|
+
```
|
|
1016
|
+
|
|
1017
|
+
#### After (fp-ts)
|
|
1018
|
+
|
|
1019
|
+
```typescript
|
|
1020
|
+
import * as A from 'fp-ts/Array';
|
|
1021
|
+
import { pipe } from 'fp-ts/function';
|
|
1022
|
+
import * as S from 'fp-ts/Set';
|
|
1023
|
+
import * as Str from 'fp-ts/string';
|
|
1024
|
+
|
|
1025
|
+
const getAllProductIds = (orders: Order[]): string[] =>
|
|
1026
|
+
pipe(
|
|
1027
|
+
orders,
|
|
1028
|
+
A.flatMap((order) => order.items),
|
|
1029
|
+
A.map((item) => item.productId),
|
|
1030
|
+
A.uniq(Str.Eq)
|
|
1031
|
+
);
|
|
1032
|
+
|
|
1033
|
+
// Or using Set for better performance with large datasets
|
|
1034
|
+
const getAllProductIdsSet = (orders: Order[]): Set<string> =>
|
|
1035
|
+
pipe(
|
|
1036
|
+
orders,
|
|
1037
|
+
A.flatMap((order) => order.items),
|
|
1038
|
+
A.map((item) => item.productId),
|
|
1039
|
+
(ids) => new Set(ids)
|
|
1040
|
+
);
|
|
1041
|
+
```
|
|
1042
|
+
|
|
1043
|
+
### Pattern: while loops to recursion/unfold
|
|
1044
|
+
|
|
1045
|
+
#### Before (Imperative)
|
|
1046
|
+
|
|
1047
|
+
```typescript
|
|
1048
|
+
function paginate<T>(
|
|
1049
|
+
fetchPage: (cursor: string | null) => Promise<{ items: T[]; nextCursor: string | null }>
|
|
1050
|
+
): Promise<T[]> {
|
|
1051
|
+
const allItems: T[] = [];
|
|
1052
|
+
let cursor: string | null = null;
|
|
1053
|
+
|
|
1054
|
+
while (true) {
|
|
1055
|
+
const { items, nextCursor } = await fetchPage(cursor);
|
|
1056
|
+
allItems.push(...items);
|
|
1057
|
+
|
|
1058
|
+
if (nextCursor === null) {
|
|
1059
|
+
break;
|
|
1060
|
+
}
|
|
1061
|
+
cursor = nextCursor;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
return allItems;
|
|
1065
|
+
}
|
|
1066
|
+
```
|
|
1067
|
+
|
|
1068
|
+
#### After (fp-ts)
|
|
1069
|
+
|
|
1070
|
+
```typescript
|
|
1071
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
1072
|
+
import * as A from 'fp-ts/Array';
|
|
1073
|
+
import { pipe } from 'fp-ts/function';
|
|
1074
|
+
|
|
1075
|
+
interface Page<T> {
|
|
1076
|
+
items: T[];
|
|
1077
|
+
nextCursor: string | null;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
const paginate = <T>(
|
|
1081
|
+
fetchPage: (cursor: string | null) => TE.TaskEither<Error, Page<T>>
|
|
1082
|
+
): TE.TaskEither<Error, T[]> => {
|
|
1083
|
+
const go = (
|
|
1084
|
+
cursor: string | null,
|
|
1085
|
+
accumulated: T[]
|
|
1086
|
+
): TE.TaskEither<Error, T[]> =>
|
|
1087
|
+
pipe(
|
|
1088
|
+
fetchPage(cursor),
|
|
1089
|
+
TE.flatMap(({ items, nextCursor }) => {
|
|
1090
|
+
const newAccumulated = [...accumulated, ...items];
|
|
1091
|
+
return nextCursor === null
|
|
1092
|
+
? TE.right(newAccumulated)
|
|
1093
|
+
: go(nextCursor, newAccumulated);
|
|
1094
|
+
})
|
|
1095
|
+
);
|
|
1096
|
+
|
|
1097
|
+
return go(null, []);
|
|
1098
|
+
};
|
|
1099
|
+
|
|
1100
|
+
// Using unfold for generating sequences
|
|
1101
|
+
import * as RA from 'fp-ts/ReadonlyArray';
|
|
1102
|
+
|
|
1103
|
+
const range = (start: number, end: number): readonly number[] =>
|
|
1104
|
+
RA.unfold(start, (n) => (n <= end ? O.some([n, n + 1]) : O.none));
|
|
1105
|
+
```
|
|
1106
|
+
|
|
1107
|
+
---
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
## 6. Migrating Promise chains to TaskEither
|
|
1111
|
+
|
|
1112
|
+
### Pattern: Promise.then chains to pipe
|
|
1113
|
+
|
|
1114
|
+
#### Before (Imperative)
|
|
1115
|
+
|
|
1116
|
+
```typescript
|
|
1117
|
+
function fetchUserData(userId: string): Promise<UserProfile> {
|
|
1118
|
+
return fetch(`/api/users/${userId}`)
|
|
1119
|
+
.then((response) => {
|
|
1120
|
+
if (!response.ok) {
|
|
1121
|
+
throw new Error(`HTTP ${response.status}`);
|
|
1122
|
+
}
|
|
1123
|
+
return response.json();
|
|
1124
|
+
})
|
|
1125
|
+
.then((data) => validateUserData(data))
|
|
1126
|
+
.then((validData) => enrichUserProfile(validData))
|
|
1127
|
+
.catch((error) => {
|
|
1128
|
+
console.error('Failed to fetch user data:', error);
|
|
1129
|
+
throw error;
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
// Chained promises with conditionals
|
|
1134
|
+
function processOrder(orderId: string): Promise<OrderResult> {
|
|
1135
|
+
return getOrder(orderId)
|
|
1136
|
+
.then((order) => {
|
|
1137
|
+
if (order.status === 'cancelled') {
|
|
1138
|
+
throw new Error('Order is cancelled');
|
|
1139
|
+
}
|
|
1140
|
+
return order;
|
|
1141
|
+
})
|
|
1142
|
+
.then((order) => validateInventory(order))
|
|
1143
|
+
.then((validOrder) => processPayment(validOrder))
|
|
1144
|
+
.then((paidOrder) => shipOrder(paidOrder))
|
|
1145
|
+
.catch((error) => {
|
|
1146
|
+
logError(error);
|
|
1147
|
+
return { success: false, error: error.message };
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
#### After (fp-ts TaskEither)
|
|
1153
|
+
|
|
1154
|
+
```typescript
|
|
1155
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
1156
|
+
import * as E from 'fp-ts/Either';
|
|
1157
|
+
import { pipe } from 'fp-ts/function';
|
|
1158
|
+
|
|
1159
|
+
const fetchUserData = (userId: string): TE.TaskEither<Error, UserProfile> =>
|
|
1160
|
+
pipe(
|
|
1161
|
+
TE.tryCatch(
|
|
1162
|
+
() => fetch(`/api/users/${userId}`),
|
|
1163
|
+
(e) => new Error(`Network error: ${e}`)
|
|
1164
|
+
),
|
|
1165
|
+
TE.flatMap((response) =>
|
|
1166
|
+
response.ok
|
|
1167
|
+
? TE.tryCatch(
|
|
1168
|
+
() => response.json(),
|
|
1169
|
+
(e) => new Error(`Parse error: ${e}`)
|
|
1170
|
+
)
|
|
1171
|
+
: TE.left(new Error(`HTTP ${response.status}`))
|
|
1172
|
+
),
|
|
1173
|
+
TE.flatMap((data) => TE.fromEither(validateUserData(data))),
|
|
1174
|
+
TE.flatMap((validData) => enrichUserProfile(validData))
|
|
1175
|
+
);
|
|
1176
|
+
|
|
1177
|
+
// Conditionals are explicit
|
|
1178
|
+
const processOrder = (orderId: string): TE.TaskEither<Error, OrderResult> =>
|
|
1179
|
+
pipe(
|
|
1180
|
+
getOrder(orderId),
|
|
1181
|
+
TE.filterOrElse(
|
|
1182
|
+
(order) => order.status !== 'cancelled',
|
|
1183
|
+
() => new Error('Order is cancelled')
|
|
1184
|
+
),
|
|
1185
|
+
TE.flatMap(validateInventory),
|
|
1186
|
+
TE.flatMap(processPayment),
|
|
1187
|
+
TE.flatMap(shipOrder),
|
|
1188
|
+
TE.map((shipped) => ({ success: true, order: shipped })),
|
|
1189
|
+
TE.orElse((error) =>
|
|
1190
|
+
pipe(
|
|
1191
|
+
TE.fromIO(() => logError(error)),
|
|
1192
|
+
TE.map(() => ({ success: false, error: error.message }))
|
|
1193
|
+
)
|
|
1194
|
+
)
|
|
1195
|
+
);
|
|
1196
|
+
```
|
|
1197
|
+
|
|
1198
|
+
### Pattern: Promise.all to traverse
|
|
1199
|
+
|
|
1200
|
+
#### Before (Imperative)
|
|
1201
|
+
|
|
1202
|
+
```typescript
|
|
1203
|
+
async function fetchAllUsers(ids: string[]): Promise<User[]> {
|
|
1204
|
+
const promises = ids.map((id) => fetchUser(id));
|
|
1205
|
+
return Promise.all(promises);
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
// With error handling for individual items
|
|
1209
|
+
async function fetchUsersWithFallback(ids: string[]): Promise<Array<User | null>> {
|
|
1210
|
+
const promises = ids.map(async (id) => {
|
|
1211
|
+
try {
|
|
1212
|
+
return await fetchUser(id);
|
|
1213
|
+
} catch {
|
|
1214
|
+
return null;
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
return Promise.all(promises);
|
|
1218
|
+
}
|
|
1219
|
+
```
|
|
1220
|
+
|
|
1221
|
+
#### After (fp-ts)
|
|
1222
|
+
|
|
1223
|
+
```typescript
|
|
1224
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
1225
|
+
import * as A from 'fp-ts/Array';
|
|
1226
|
+
import * as T from 'fp-ts/Task';
|
|
1227
|
+
import { pipe } from 'fp-ts/function';
|
|
1228
|
+
|
|
1229
|
+
// Parallel execution - fails fast on first error
|
|
1230
|
+
const fetchAllUsers = (ids: string[]): TE.TaskEither<Error, User[]> =>
|
|
1231
|
+
pipe(
|
|
1232
|
+
ids,
|
|
1233
|
+
A.traverse(TE.ApplicativePar)(fetchUser)
|
|
1234
|
+
);
|
|
1235
|
+
|
|
1236
|
+
// Sequential execution
|
|
1237
|
+
const fetchAllUsersSequential = (ids: string[]): TE.TaskEither<Error, User[]> =>
|
|
1238
|
+
pipe(
|
|
1239
|
+
ids,
|
|
1240
|
+
A.traverse(TE.ApplicativeSeq)(fetchUser)
|
|
1241
|
+
);
|
|
1242
|
+
|
|
1243
|
+
// Collect successes, ignore failures (using Task instead of TaskEither)
|
|
1244
|
+
const fetchUsersWithFallback = (ids: string[]): T.Task<Array<User | null>> =>
|
|
1245
|
+
pipe(
|
|
1246
|
+
ids,
|
|
1247
|
+
A.traverse(T.ApplicativePar)((id) =>
|
|
1248
|
+
pipe(
|
|
1249
|
+
fetchUser(id),
|
|
1250
|
+
TE.match(
|
|
1251
|
+
() => null,
|
|
1252
|
+
(user) => user
|
|
1253
|
+
)
|
|
1254
|
+
)
|
|
1255
|
+
)
|
|
1256
|
+
);
|
|
1257
|
+
|
|
1258
|
+
// Or keep track of which failed
|
|
1259
|
+
const fetchUsersPartitioned = (
|
|
1260
|
+
ids: string[]
|
|
1261
|
+
): T.Task<{ successes: User[]; failures: Array<{ id: string; error: Error }> }> =>
|
|
1262
|
+
pipe(
|
|
1263
|
+
ids,
|
|
1264
|
+
A.traverse(T.ApplicativePar)((id) =>
|
|
1265
|
+
pipe(
|
|
1266
|
+
fetchUser(id),
|
|
1267
|
+
TE.bimap(
|
|
1268
|
+
(error) => ({ id, error }),
|
|
1269
|
+
(user) => user
|
|
1270
|
+
),
|
|
1271
|
+
(te) => te
|
|
1272
|
+
)
|
|
1273
|
+
),
|
|
1274
|
+
T.map(A.separate),
|
|
1275
|
+
T.map(({ left: failures, right: successes }) => ({ successes, failures }))
|
|
1276
|
+
);
|
|
1277
|
+
```
|
|
1278
|
+
|
|
1279
|
+
### Pattern: Promise.race to alternative
|
|
1280
|
+
|
|
1281
|
+
```typescript
|
|
1282
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
1283
|
+
import * as T from 'fp-ts/Task';
|
|
1284
|
+
import { pipe } from 'fp-ts/function';
|
|
1285
|
+
|
|
1286
|
+
// Race - first to complete wins
|
|
1287
|
+
const raceTaskEithers = <E, A>(
|
|
1288
|
+
tasks: Array<TE.TaskEither<E, A>>
|
|
1289
|
+
): TE.TaskEither<E, A> =>
|
|
1290
|
+
() => Promise.race(tasks.map((te) => te()));
|
|
1291
|
+
|
|
1292
|
+
// Try alternatives on failure (like Promise.any but typed)
|
|
1293
|
+
const tryAlternatives = <E, A>(
|
|
1294
|
+
primary: TE.TaskEither<E, A>,
|
|
1295
|
+
fallback: TE.TaskEither<E, A>
|
|
1296
|
+
): TE.TaskEither<E, A> =>
|
|
1297
|
+
pipe(
|
|
1298
|
+
primary,
|
|
1299
|
+
TE.orElse(() => fallback)
|
|
1300
|
+
);
|
|
1301
|
+
|
|
1302
|
+
// Chain of fallbacks
|
|
1303
|
+
const withFallbacks = <E, A>(
|
|
1304
|
+
tasks: Array<TE.TaskEither<E, A>>
|
|
1305
|
+
): TE.TaskEither<E, A> =>
|
|
1306
|
+
tasks.reduce((acc, task) => pipe(acc, TE.orElse(() => task)));
|
|
1307
|
+
```
|
|
1308
|
+
|
|
1309
|
+
---
|
|
1310
|
+
|
|
1311
|
+
|
|
1312
|
+
## 7. Common Pitfalls
|
|
1313
|
+
|
|
1314
|
+
### Pitfall 1: Forgetting to run Tasks
|
|
1315
|
+
|
|
1316
|
+
```typescript
|
|
1317
|
+
// WRONG: Task is not executed
|
|
1318
|
+
const fetchData = (): TE.TaskEither<Error, Data> => /* ... */;
|
|
1319
|
+
const result = fetchData(); // This is still a Task, not the result!
|
|
1320
|
+
|
|
1321
|
+
// CORRECT: Execute the Task
|
|
1322
|
+
const result = await fetchData()(); // Note the double invocation
|
|
1323
|
+
```
|
|
1324
|
+
|
|
1325
|
+
### Pitfall 2: Mixing async/await with fp-ts incorrectly
|
|
1326
|
+
|
|
1327
|
+
```typescript
|
|
1328
|
+
// WRONG: Breaking out of the fp-ts ecosystem
|
|
1329
|
+
const processData = async (input: string): Promise<Result> => {
|
|
1330
|
+
const parsed = parseInput(input); // Returns Either
|
|
1331
|
+
if (E.isLeft(parsed)) {
|
|
1332
|
+
throw new Error(parsed.left.message); // Don't do this!
|
|
1333
|
+
}
|
|
1334
|
+
return await fetchData(parsed.right)();
|
|
1335
|
+
};
|
|
1336
|
+
|
|
1337
|
+
// CORRECT: Stay in the ecosystem
|
|
1338
|
+
const processData = (input: string): TE.TaskEither<Error, Result> =>
|
|
1339
|
+
pipe(
|
|
1340
|
+
parseInput(input),
|
|
1341
|
+
TE.fromEither,
|
|
1342
|
+
TE.flatMap(fetchData)
|
|
1343
|
+
);
|
|
1344
|
+
```
|
|
1345
|
+
|
|
1346
|
+
### Pitfall 3: Using map when flatMap is needed
|
|
1347
|
+
|
|
1348
|
+
```typescript
|
|
1349
|
+
// WRONG: Results in nested Either
|
|
1350
|
+
const result: E.Either<Error, E.Either<Error, User>> = pipe(
|
|
1351
|
+
parseUserId(input), // E.Either<Error, string>
|
|
1352
|
+
E.map(fetchUser) // Returns E.Either<Error, User>, so we get nested Either
|
|
1353
|
+
);
|
|
1354
|
+
|
|
1355
|
+
// CORRECT: Use flatMap to flatten
|
|
1356
|
+
const result: E.Either<Error, User> = pipe(
|
|
1357
|
+
parseUserId(input),
|
|
1358
|
+
E.flatMap(fetchUser)
|
|
1359
|
+
);
|
|
1360
|
+
```
|
|
1361
|
+
|
|
1362
|
+
### Pitfall 4: Losing error information
|
|
1363
|
+
|
|
1364
|
+
```typescript
|
|
1365
|
+
// WRONG: Original error context is lost
|
|
1366
|
+
const fetchData = (): TE.TaskEither<Error, Data> =>
|
|
1367
|
+
pipe(
|
|
1368
|
+
TE.tryCatch(
|
|
1369
|
+
() => fetch('/api/data'),
|
|
1370
|
+
() => new Error('Failed') // Lost the original error!
|
|
1371
|
+
)
|
|
1372
|
+
);
|
|
1373
|
+
|
|
1374
|
+
// CORRECT: Preserve error context
|
|
1375
|
+
const fetchData = (): TE.TaskEither<Error, Data> =>
|
|
1376
|
+
pipe(
|
|
1377
|
+
TE.tryCatch(
|
|
1378
|
+
() => fetch('/api/data'),
|
|
1379
|
+
(reason) => new Error(`Network request failed: ${reason}`)
|
|
1380
|
+
)
|
|
1381
|
+
);
|
|
1382
|
+
|
|
1383
|
+
// BETTER: Use typed errors
|
|
1384
|
+
type FetchError =
|
|
1385
|
+
| { _tag: 'NetworkError'; cause: unknown }
|
|
1386
|
+
| { _tag: 'ParseError'; cause: unknown }
|
|
1387
|
+
| { _tag: 'ValidationError'; message: string };
|
|
1388
|
+
|
|
1389
|
+
const fetchData = (): TE.TaskEither<FetchError, Data> =>
|
|
1390
|
+
pipe(
|
|
1391
|
+
TE.tryCatch(
|
|
1392
|
+
() => fetch('/api/data'),
|
|
1393
|
+
(cause): FetchError => ({ _tag: 'NetworkError', cause })
|
|
1394
|
+
),
|
|
1395
|
+
TE.flatMap((response) =>
|
|
1396
|
+
TE.tryCatch(
|
|
1397
|
+
() => response.json(),
|
|
1398
|
+
(cause): FetchError => ({ _tag: 'ParseError', cause })
|
|
1399
|
+
)
|
|
1400
|
+
)
|
|
1401
|
+
);
|
|
1402
|
+
```
|
|
1403
|
+
|
|
1404
|
+
### Pitfall 5: Overusing fromNullable
|
|
1405
|
+
|
|
1406
|
+
```typescript
|
|
1407
|
+
// WRONG: Unnecessary wrapping and unwrapping
|
|
1408
|
+
const getName = (user: User | null): string => {
|
|
1409
|
+
const optUser = O.fromNullable(user);
|
|
1410
|
+
const name = pipe(optUser, O.map(u => u.name), O.toNullable);
|
|
1411
|
+
return name ?? 'Unknown';
|
|
1412
|
+
};
|
|
1413
|
+
|
|
1414
|
+
// CORRECT: Use Option only when you need its composition benefits
|
|
1415
|
+
const getName = (user: User | null): string => user?.name ?? 'Unknown';
|
|
1416
|
+
|
|
1417
|
+
// BETTER: Use Option when chaining multiple operations
|
|
1418
|
+
const getManagerName = (user: User | null): O.Option<string> =>
|
|
1419
|
+
pipe(
|
|
1420
|
+
O.fromNullable(user),
|
|
1421
|
+
O.flatMap(u => O.fromNullable(u.manager)),
|
|
1422
|
+
O.map(m => m.name)
|
|
1423
|
+
);
|
|
1424
|
+
```
|
|
1425
|
+
|
|
1426
|
+
### Pitfall 6: Not handling the left case
|
|
1427
|
+
|
|
1428
|
+
```typescript
|
|
1429
|
+
// WRONG: Ignoring potential errors
|
|
1430
|
+
const processUser = (input: string): User => {
|
|
1431
|
+
const result = parseUser(input); // E.Either<Error, User>
|
|
1432
|
+
return (result as E.Right<User>).right; // Unsafe cast!
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1435
|
+
// CORRECT: Always handle both cases
|
|
1436
|
+
const processUser = (input: string): User =>
|
|
1437
|
+
pipe(
|
|
1438
|
+
parseUser(input),
|
|
1439
|
+
E.getOrElse((error) => {
|
|
1440
|
+
console.error('Parse failed:', error);
|
|
1441
|
+
return defaultUser;
|
|
1442
|
+
})
|
|
1443
|
+
);
|
|
1444
|
+
```
|
|
1445
|
+
|
|
1446
|
+
---
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
## 8. Gradual Adoption Strategies
|
|
1450
|
+
|
|
1451
|
+
### Strategy 1: Start at the Boundaries
|
|
1452
|
+
|
|
1453
|
+
Begin by converting functions at the edges of your system:
|
|
1454
|
+
- API response handlers
|
|
1455
|
+
- Database query results
|
|
1456
|
+
- File system operations
|
|
1457
|
+
- User input validation
|
|
1458
|
+
|
|
1459
|
+
```typescript
|
|
1460
|
+
// Wrap external API calls first
|
|
1461
|
+
const fetchUserApi = (id: string): TE.TaskEither<ApiError, UserDto> =>
|
|
1462
|
+
pipe(
|
|
1463
|
+
TE.tryCatch(
|
|
1464
|
+
() => externalApiClient.getUser(id),
|
|
1465
|
+
(e) => ({ type: 'api_error' as const, cause: e })
|
|
1466
|
+
)
|
|
1467
|
+
);
|
|
1468
|
+
|
|
1469
|
+
// Internal code can stay imperative initially
|
|
1470
|
+
async function handleUserRequest(userId: string) {
|
|
1471
|
+
const result = await fetchUserApi(userId)();
|
|
1472
|
+
if (E.isRight(result)) {
|
|
1473
|
+
// Process user with existing code
|
|
1474
|
+
return processUser(result.right);
|
|
1475
|
+
} else {
|
|
1476
|
+
throw new Error(`API error: ${result.left.type}`);
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
```
|
|
1480
|
+
|
|
1481
|
+
### Strategy 2: Create Bridge Functions
|
|
1482
|
+
|
|
1483
|
+
Build helpers to convert between fp-ts and imperative code:
|
|
1484
|
+
|
|
1485
|
+
```typescript
|
|
1486
|
+
// Bridge from Either to thrown errors
|
|
1487
|
+
const unsafeUnwrap = <E, A>(either: E.Either<E, A>): A =>
|
|
1488
|
+
pipe(
|
|
1489
|
+
either,
|
|
1490
|
+
E.getOrElseW((e) => {
|
|
1491
|
+
throw e instanceof Error ? e : new Error(String(e));
|
|
1492
|
+
})
|
|
1493
|
+
);
|
|
1494
|
+
|
|
1495
|
+
// Bridge from thrown errors to Either
|
|
1496
|
+
const catchSync = <A>(f: () => A): E.Either<Error, A> =>
|
|
1497
|
+
E.tryCatch(f, (e) => (e instanceof Error ? e : new Error(String(e))));
|
|
1498
|
+
|
|
1499
|
+
// Bridge from Promise to TaskEither
|
|
1500
|
+
const fromPromise = <A>(p: Promise<A>): TE.TaskEither<Error, A> =>
|
|
1501
|
+
TE.tryCatch(() => p, (e) => (e instanceof Error ? e : new Error(String(e))));
|
|
1502
|
+
|
|
1503
|
+
// Bridge from TaskEither to Promise (throws on Left)
|
|
1504
|
+
const toPromise = <E, A>(te: TE.TaskEither<E, A>): Promise<A> =>
|
|
1505
|
+
te().then(E.getOrElseW((e) => { throw e; }));
|
|
1506
|
+
```
|
|
1507
|
+
|
|
1508
|
+
### Strategy 3: Module-by-Module Migration
|
|
1509
|
+
|
|
1510
|
+
1. **Pick a module** with clear boundaries
|
|
1511
|
+
2. **Add fp-ts types** to internal functions
|
|
1512
|
+
3. **Keep external API unchanged** initially
|
|
1513
|
+
4. **Test thoroughly** before moving on
|
|
1514
|
+
5. **Update external API** once internals are stable
|
|
1515
|
+
|
|
1516
|
+
```typescript
|
|
1517
|
+
// Phase 1: Internal functions use fp-ts
|
|
1518
|
+
// File: user-service.internal.ts
|
|
1519
|
+
export const validateUser = (data: unknown): E.Either<ValidationError, User> => /* ... */;
|
|
1520
|
+
export const enrichUser = (user: User): TE.TaskEither<Error, EnrichedUser> => /* ... */;
|
|
1521
|
+
|
|
1522
|
+
// File: user-service.ts (public API unchanged)
|
|
1523
|
+
export async function getUser(id: string): Promise<User> {
|
|
1524
|
+
const result = await pipe(
|
|
1525
|
+
fetchUser(id),
|
|
1526
|
+
TE.flatMap(validateUser >>> TE.fromEither),
|
|
1527
|
+
TE.flatMap(enrichUser)
|
|
1528
|
+
)();
|
|
1529
|
+
|
|
1530
|
+
if (E.isLeft(result)) {
|
|
1531
|
+
throw result.left;
|
|
1532
|
+
}
|
|
1533
|
+
return result.right;
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
// Phase 2: Update public API
|
|
1537
|
+
// File: user-service.ts
|
|
1538
|
+
export const getUser = (id: string): TE.TaskEither<UserError, User> =>
|
|
1539
|
+
pipe(
|
|
1540
|
+
fetchUser(id),
|
|
1541
|
+
TE.flatMap(validateUser >>> TE.fromEither),
|
|
1542
|
+
TE.flatMap(enrichUser)
|
|
1543
|
+
);
|
|
1544
|
+
```
|
|
1545
|
+
|
|
1546
|
+
### Strategy 4: Type-Driven Development
|
|
1547
|
+
|
|
1548
|
+
Use TypeScript's type system to guide the migration:
|
|
1549
|
+
|
|
1550
|
+
```typescript
|
|
1551
|
+
// Step 1: Change type signature first
|
|
1552
|
+
type OldGetUser = (id: string) => Promise<User | null>;
|
|
1553
|
+
type NewGetUser = (id: string) => TE.TaskEither<UserError, User>;
|
|
1554
|
+
|
|
1555
|
+
// Step 2: Compiler will show all call sites that need updating
|
|
1556
|
+
const getUser: NewGetUser = (id) => /* implement */;
|
|
1557
|
+
|
|
1558
|
+
// Step 3: Update call sites one by one
|
|
1559
|
+
// The compiler ensures you handle all cases
|
|
1560
|
+
```
|
|
1561
|
+
|
|
1562
|
+
### Strategy 5: Testing as Documentation
|
|
1563
|
+
|
|
1564
|
+
Write tests that demonstrate the expected behavior:
|
|
1565
|
+
|
|
1566
|
+
```typescript
|
|
1567
|
+
describe('UserService', () => {
|
|
1568
|
+
describe('getUser (fp-ts)', () => {
|
|
1569
|
+
it('returns Right with user on success', async () => {
|
|
1570
|
+
const result = await getUser('valid-id')();
|
|
1571
|
+
expect(E.isRight(result)).toBe(true);
|
|
1572
|
+
if (E.isRight(result)) {
|
|
1573
|
+
expect(result.right.id).toBe('valid-id');
|
|
1574
|
+
}
|
|
1575
|
+
});
|
|
1576
|
+
|
|
1577
|
+
it('returns Left with NotFound error for unknown id', async () => {
|
|
1578
|
+
const result = await getUser('unknown')();
|
|
1579
|
+
expect(E.isLeft(result)).toBe(true);
|
|
1580
|
+
if (E.isLeft(result)) {
|
|
1581
|
+
expect(result.left._tag).toBe('NotFound');
|
|
1582
|
+
}
|
|
1583
|
+
});
|
|
1584
|
+
});
|
|
1585
|
+
});
|
|
1586
|
+
```
|
|
1587
|
+
|
|
1588
|
+
---
|
|
1589
|
+
|
|
1590
|
+
|
|
1591
|
+
## 9. When NOT to Refactor
|
|
1592
|
+
|
|
1593
|
+
### Simple Synchronous Code
|
|
1594
|
+
|
|
1595
|
+
Don't refactor straightforward code that doesn't benefit from fp-ts:
|
|
1596
|
+
|
|
1597
|
+
```typescript
|
|
1598
|
+
// This is fine as-is
|
|
1599
|
+
function formatName(first: string, last: string): string {
|
|
1600
|
+
return `${first} ${last}`;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
// Don't do this - it adds complexity without benefit
|
|
1604
|
+
const formatName = (first: string, last: string): string =>
|
|
1605
|
+
pipe(
|
|
1606
|
+
first,
|
|
1607
|
+
(f) => `${f} ${last}`
|
|
1608
|
+
);
|
|
1609
|
+
```
|
|
1610
|
+
|
|
1611
|
+
### Performance-Critical Loops
|
|
1612
|
+
|
|
1613
|
+
fp-ts operations create intermediate arrays. For hot paths, keep imperative code:
|
|
1614
|
+
|
|
1615
|
+
```typescript
|
|
1616
|
+
// Keep this for performance-critical code processing millions of items
|
|
1617
|
+
function sumLargeArray(numbers: number[]): number {
|
|
1618
|
+
let sum = 0;
|
|
1619
|
+
for (let i = 0; i < numbers.length; i++) {
|
|
1620
|
+
sum += numbers[i];
|
|
1621
|
+
}
|
|
1622
|
+
return sum;
|
|
1623
|
+
}
|
|
1624
|
+
|
|
1625
|
+
// This creates intermediate arrays
|
|
1626
|
+
const sumWithFpts = (numbers: number[]): number =>
|
|
1627
|
+
pipe(numbers, A.reduce(0, (acc, n) => acc + n));
|
|
1628
|
+
```
|
|
1629
|
+
|
|
1630
|
+
### Third-Party Library Interfaces
|
|
1631
|
+
|
|
1632
|
+
When working with libraries that expect specific patterns:
|
|
1633
|
+
|
|
1634
|
+
```typescript
|
|
1635
|
+
// Express middleware must match Express's interface
|
|
1636
|
+
app.get('/users/:id', async (req, res) => {
|
|
1637
|
+
// Keep imperative here, convert at boundaries
|
|
1638
|
+
const result = await getUser(req.params.id)();
|
|
1639
|
+
|
|
1640
|
+
if (E.isLeft(result)) {
|
|
1641
|
+
res.status(404).json({ error: result.left.message });
|
|
1642
|
+
} else {
|
|
1643
|
+
res.json(result.right);
|
|
1644
|
+
}
|
|
1645
|
+
});
|
|
1646
|
+
```
|
|
1647
|
+
|
|
1648
|
+
### Code Touched by Non-FP Team Members
|
|
1649
|
+
|
|
1650
|
+
If your team isn't familiar with fp-ts, forced adoption will hurt productivity:
|
|
1651
|
+
|
|
1652
|
+
```typescript
|
|
1653
|
+
// If team doesn't know fp-ts, this is harder to maintain
|
|
1654
|
+
const processOrder = (order: Order): TE.TaskEither<Error, Result> =>
|
|
1655
|
+
pipe(
|
|
1656
|
+
validateOrder(order),
|
|
1657
|
+
TE.fromEither,
|
|
1658
|
+
TE.flatMap(enrichOrder),
|
|
1659
|
+
TE.flatMap(submitOrder)
|
|
1660
|
+
);
|
|
1661
|
+
|
|
1662
|
+
// Familiar to all TypeScript developers
|
|
1663
|
+
async function processOrder(order: Order): Promise<Result> {
|
|
1664
|
+
const validated = validateOrder(order);
|
|
1665
|
+
if (!validated.success) {
|
|
1666
|
+
throw new Error(validated.error);
|
|
1667
|
+
}
|
|
1668
|
+
const enriched = await enrichOrder(validated.data);
|
|
1669
|
+
return await submitOrder(enriched);
|
|
1670
|
+
}
|
|
1671
|
+
```
|
|
1672
|
+
|
|
1673
|
+
### Trivial Null Checks
|
|
1674
|
+
|
|
1675
|
+
Don't use Option for simple, one-off null checks:
|
|
1676
|
+
|
|
1677
|
+
```typescript
|
|
1678
|
+
// This is fine
|
|
1679
|
+
const name = user?.name ?? 'Anonymous';
|
|
1680
|
+
|
|
1681
|
+
// Overkill for simple cases
|
|
1682
|
+
const name = pipe(
|
|
1683
|
+
O.fromNullable(user),
|
|
1684
|
+
O.map((u) => u.name),
|
|
1685
|
+
O.getOrElse(() => 'Anonymous')
|
|
1686
|
+
);
|
|
1687
|
+
```
|
|
1688
|
+
|
|
1689
|
+
### When the Error Type Doesn't Matter
|
|
1690
|
+
|
|
1691
|
+
If you're going to throw/log anyway and don't need error composition:
|
|
1692
|
+
|
|
1693
|
+
```typescript
|
|
1694
|
+
// If this is your error handling anyway...
|
|
1695
|
+
try {
|
|
1696
|
+
await doSomething();
|
|
1697
|
+
} catch (e) {
|
|
1698
|
+
logger.error(e);
|
|
1699
|
+
throw e;
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
// ...then Either doesn't add much value
|
|
1703
|
+
const result = await doSomethingTE()();
|
|
1704
|
+
if (E.isLeft(result)) {
|
|
1705
|
+
logger.error(result.left);
|
|
1706
|
+
throw result.left;
|
|
1707
|
+
}
|
|
1708
|
+
```
|
|
1709
|
+
|
|
1710
|
+
### Test Code
|
|
1711
|
+
|
|
1712
|
+
Test code should be readable, not necessarily functional:
|
|
1713
|
+
|
|
1714
|
+
```typescript
|
|
1715
|
+
// Clear test code
|
|
1716
|
+
describe('UserService', () => {
|
|
1717
|
+
it('creates a user', async () => {
|
|
1718
|
+
const user = await createUser({ name: 'Alice' });
|
|
1719
|
+
expect(user.name).toBe('Alice');
|
|
1720
|
+
});
|
|
1721
|
+
});
|
|
1722
|
+
|
|
1723
|
+
// Unnecessarily complex
|
|
1724
|
+
describe('UserService', () => {
|
|
1725
|
+
it('creates a user', async () => {
|
|
1726
|
+
await pipe(
|
|
1727
|
+
createUser({ name: 'Alice' }),
|
|
1728
|
+
TE.map((user) => expect(user.name).toBe('Alice')),
|
|
1729
|
+
TE.getOrElse(() => T.of(fail('Should not fail')))
|
|
1730
|
+
)();
|
|
1731
|
+
});
|
|
1732
|
+
});
|
|
1733
|
+
```
|
|
1734
|
+
|
|
1735
|
+
---
|
|
1736
|
+
|
|
1737
|
+
|
|
1738
|
+
## Quick Reference: Imperative to fp-ts Mapping
|
|
1739
|
+
|
|
1740
|
+
| Imperative Pattern | fp-ts Equivalent |
|
|
1741
|
+
|-------------------|------------------|
|
|
1742
|
+
| `try { } catch { }` | `E.tryCatch()`, `TE.tryCatch()` |
|
|
1743
|
+
| `throw new Error()` | `E.left()`, `TE.left()` |
|
|
1744
|
+
| `return value` | `E.right()`, `TE.right()` |
|
|
1745
|
+
| `if (x === null)` | `O.fromNullable()`, `O.isNone()` |
|
|
1746
|
+
| `x ?? defaultValue` | `O.getOrElse()` |
|
|
1747
|
+
| `x?.property` | `O.map()`, `O.flatMap()` |
|
|
1748
|
+
| `array.map()` | `A.map()` |
|
|
1749
|
+
| `array.filter()` | `A.filter()` |
|
|
1750
|
+
| `array.reduce()` | `A.reduce()`, `A.foldMap()` |
|
|
1751
|
+
| `array.find()` | `A.findFirst()` |
|
|
1752
|
+
| `array.flatMap()` | `A.flatMap()` |
|
|
1753
|
+
| `Promise.then()` | `TE.map()`, `TE.flatMap()` |
|
|
1754
|
+
| `Promise.catch()` | `TE.orElse()`, `TE.mapLeft()` |
|
|
1755
|
+
| `Promise.all()` | `A.traverse(TE.ApplicativePar)` |
|
|
1756
|
+
| `async/await` | `TE.flatMap()` chain |
|
|
1757
|
+
| `new Class(deps)` | `R.asks()`, `RTE.ask()` |
|
|
1758
|
+
| `for...of` | `A.map()`, `A.reduce()` |
|
|
1759
|
+
| `while` | Recursion, `unfold()` |
|
|
1760
|
+
|
|
1761
|
+
---
|
|
1762
|
+
|
|
1763
|
+
|
|
1764
|
+
## Summary
|
|
1765
|
+
|
|
1766
|
+
Migrating to fp-ts is a journey, not a destination. Key principles:
|
|
1767
|
+
|
|
1768
|
+
1. **Start small**: Convert individual functions, not entire codebases
|
|
1769
|
+
2. **Be pragmatic**: Not everything needs to be functional
|
|
1770
|
+
3. **Type-driven**: Let the compiler guide your refactoring
|
|
1771
|
+
4. **Test thoroughly**: Each conversion should be verified
|
|
1772
|
+
5. **Document patterns**: Create team-specific guides for your codebase
|
|
1773
|
+
6. **Review benefits**: Ensure the added complexity provides value
|
|
1774
|
+
|
|
1775
|
+
The goal is more maintainable, type-safe code—not functional programming for its own sake.
|