@cubis/foundry 0.3.71 → 0.3.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -2
- package/dist/cli/core.js +9 -22
- package/dist/cli/core.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/core.ts +13 -22
- package/workflows/powers/accessibility/POWER.md +83 -94
- package/workflows/powers/accessibility/SKILL.md +82 -94
- package/workflows/powers/agent-design/POWER.md +201 -0
- package/workflows/powers/agent-design/SKILL.md +198 -0
- package/workflows/powers/agent-design/references/clarification-patterns.md +153 -0
- package/workflows/powers/agent-design/references/skill-testing.md +164 -0
- package/workflows/powers/agent-design/references/workflow-patterns.md +226 -0
- package/workflows/powers/agentic-eval/POWER.md +62 -0
- package/workflows/powers/agentic-eval/SKILL.md +59 -0
- package/workflows/powers/agentic-eval/references/rubric-and-regression-checklist.md +11 -0
- package/workflows/powers/api-designer/POWER.md +43 -71
- package/workflows/powers/api-designer/SKILL.md +43 -71
- package/workflows/powers/api-patterns/POWER.md +42 -56
- package/workflows/powers/api-patterns/SKILL.md +42 -57
- package/workflows/powers/architecture-designer/POWER.md +43 -60
- package/workflows/powers/architecture-designer/SKILL.md +43 -60
- package/workflows/powers/ask-questions-if-underspecified/POWER.md +51 -3
- package/workflows/powers/auth-architect/POWER.md +69 -0
- package/workflows/powers/auth-architect/SKILL.md +66 -0
- package/workflows/powers/auth-architect/references/session-token-policy-checklist.md +45 -0
- package/workflows/powers/behavioral-modes/POWER.md +100 -9
- package/workflows/powers/c-pro/POWER.md +105 -0
- package/workflows/powers/c-pro/SKILL.md +102 -0
- package/workflows/powers/c-pro/references/build-systems-and-toolchains.md +148 -0
- package/workflows/powers/c-pro/references/common-ub-and-portability.md +166 -0
- package/workflows/powers/c-pro/references/debugging-with-sanitizers.md +205 -0
- package/workflows/powers/c-pro/references/memory-safety-and-build-checklist.md +60 -0
- package/workflows/powers/c-pro/references/posix-and-platform-apis.md +244 -0
- package/workflows/powers/changelog-generator/POWER.md +127 -63
- package/workflows/powers/changelog-generator/SKILL.md +126 -63
- package/workflows/powers/ci-cd-pipelines/POWER.md +156 -0
- package/workflows/powers/ci-cd-pipelines/SKILL.md +153 -0
- package/workflows/powers/ci-cd-pipelines/references/github-actions-patterns.md +160 -0
- package/workflows/powers/ci-cd-pipelines/references/pipeline-security-checklist.md +57 -0
- package/workflows/powers/cli-developer/POWER.md +152 -95
- package/workflows/powers/cli-developer/SKILL.md +152 -95
- package/workflows/powers/cpp-pro/POWER.md +111 -0
- package/workflows/powers/cpp-pro/SKILL.md +108 -0
- package/workflows/powers/cpp-pro/references/concurrency-primitives.md +266 -0
- package/workflows/powers/cpp-pro/references/move-semantics-and-value-types.md +149 -0
- package/workflows/powers/cpp-pro/references/performance-and-profiling.md +191 -0
- package/workflows/powers/cpp-pro/references/raii-and-modern-cpp-checklist.md +87 -0
- package/workflows/powers/cpp-pro/references/template-and-concepts-patterns.md +205 -0
- package/workflows/powers/csharp-pro/POWER.md +47 -22
- package/workflows/powers/csharp-pro/SKILL.md +47 -22
- package/workflows/powers/dart-pro/POWER.md +68 -0
- package/workflows/powers/dart-pro/SKILL.md +65 -0
- package/workflows/powers/dart-pro/references/isolate-and-concurrency.md +180 -0
- package/workflows/powers/dart-pro/references/null-safety-and-async-patterns.md +133 -0
- package/workflows/powers/dart-pro/references/package-structure-and-linting.md +193 -0
- package/workflows/powers/dart-pro/references/sealed-records-patterns.md +173 -0
- package/workflows/powers/dart-pro/references/testing-and-mocking.md +235 -0
- package/workflows/powers/database-design/POWER.md +47 -33
- package/workflows/powers/database-design/SKILL.md +47 -33
- package/workflows/powers/database-optimizer/POWER.md +43 -64
- package/workflows/powers/database-optimizer/SKILL.md +43 -64
- package/workflows/powers/database-skills/POWER.md +59 -93
- package/workflows/powers/database-skills/SKILL.md +59 -93
- package/workflows/powers/debugging-strategies/POWER.md +69 -0
- package/workflows/powers/debugging-strategies/SKILL.md +66 -0
- package/workflows/powers/debugging-strategies/references/reproduce-isolate-verify-checklist.md +42 -0
- package/workflows/powers/deep-research/POWER.md +67 -0
- package/workflows/powers/deep-research/SKILL.md +64 -0
- package/workflows/powers/deep-research/references/multi-round-research-loop.md +80 -0
- package/workflows/powers/design-system-builder/POWER.md +130 -116
- package/workflows/powers/design-system-builder/SKILL.md +130 -116
- package/workflows/powers/devops-engineer/POWER.md +120 -57
- package/workflows/powers/devops-engineer/SKILL.md +120 -57
- package/workflows/powers/docker-kubernetes/POWER.md +94 -0
- package/workflows/powers/docker-kubernetes/SKILL.md +91 -0
- package/workflows/powers/docker-kubernetes/references/dockerfile-optimization-checklist.md +35 -0
- package/workflows/powers/docker-kubernetes/references/kubernetes-deployment-patterns.md +59 -0
- package/workflows/powers/documentation-templates/POWER.md +158 -127
- package/workflows/powers/documentation-templates/SKILL.md +158 -127
- package/workflows/powers/drizzle-expert/POWER.md +66 -0
- package/workflows/powers/drizzle-expert/SKILL.md +63 -0
- package/workflows/powers/drizzle-expert/references/runtime-pairing-matrix.md +16 -0
- package/workflows/powers/drizzle-expert/references/schema-and-migration-playbook.md +18 -0
- package/workflows/powers/error-ux-observability/POWER.md +144 -131
- package/workflows/powers/error-ux-observability/SKILL.md +143 -131
- package/workflows/powers/fastapi-expert/POWER.md +46 -60
- package/workflows/powers/fastapi-expert/SKILL.md +46 -60
- package/workflows/powers/firebase/POWER.md +65 -0
- package/workflows/powers/firebase/SKILL.md +62 -0
- package/workflows/powers/firebase/references/platform-routing.md +16 -0
- package/workflows/powers/firebase/references/rules-and-indexes-checklist.md +11 -0
- package/workflows/powers/flutter-design-system/POWER.md +63 -0
- package/workflows/powers/flutter-design-system/SKILL.md +60 -0
- package/workflows/powers/flutter-design-system/references/shared-widgets.md +29 -0
- package/workflows/powers/flutter-design-system/references/tokens-and-theme.md +34 -0
- package/workflows/powers/flutter-drift/POWER.md +65 -0
- package/workflows/powers/flutter-drift/SKILL.md +62 -0
- package/workflows/powers/flutter-drift/references/migrations.md +22 -0
- package/workflows/powers/flutter-drift/references/query-patterns.md +26 -0
- package/workflows/powers/flutter-feature/POWER.md +65 -0
- package/workflows/powers/flutter-feature/SKILL.md +62 -0
- package/workflows/powers/flutter-feature/references/architecture-rules.md +85 -0
- package/workflows/powers/flutter-feature/references/composite-provider.md +58 -0
- package/workflows/powers/flutter-feature/references/outbox-pattern.md +87 -0
- package/workflows/powers/flutter-feature/references/testing-patterns.md +218 -0
- package/workflows/powers/flutter-go-router/POWER.md +64 -0
- package/workflows/powers/flutter-go-router/SKILL.md +61 -0
- package/workflows/powers/flutter-go-router/references/guards-and-deeplinks.md +20 -0
- package/workflows/powers/flutter-go-router/references/typed-routes.md +27 -0
- package/workflows/powers/flutter-offline-sync/POWER.md +62 -0
- package/workflows/powers/flutter-offline-sync/SKILL.md +59 -0
- package/workflows/powers/flutter-offline-sync/references/outbox-full.md +44 -0
- package/workflows/powers/flutter-repository/POWER.md +64 -0
- package/workflows/powers/flutter-repository/SKILL.md +61 -0
- package/workflows/powers/flutter-repository/references/drift-patterns.md +21 -0
- package/workflows/powers/flutter-repository/references/retrofit-patterns.md +20 -0
- package/workflows/powers/flutter-riverpod/POWER.md +70 -0
- package/workflows/powers/flutter-riverpod/SKILL.md +67 -0
- package/workflows/powers/flutter-riverpod/references/async-and-mutations.md +19 -0
- package/workflows/powers/flutter-riverpod/references/async-lifecycle.md +19 -0
- package/workflows/powers/flutter-riverpod/references/provider-selection.md +20 -0
- package/workflows/powers/flutter-riverpod/references/testing.md +21 -0
- package/workflows/powers/flutter-riverpod/references/version-matrix.md +24 -0
- package/workflows/powers/flutter-state-machine/POWER.md +62 -0
- package/workflows/powers/flutter-state-machine/SKILL.md +59 -0
- package/workflows/powers/flutter-state-machine/references/app-state-contract.md +23 -0
- package/workflows/powers/flutter-state-machine/references/ui-rendering.md +14 -0
- package/workflows/powers/flutter-testing/POWER.md +64 -0
- package/workflows/powers/flutter-testing/SKILL.md +61 -0
- package/workflows/powers/flutter-testing/references/offline-sync-tests.md +16 -0
- package/workflows/powers/flutter-testing/references/test-layers.md +33 -0
- package/workflows/powers/frontend-code-review/POWER.md +137 -0
- package/workflows/powers/frontend-code-review/SKILL.md +134 -0
- package/workflows/powers/frontend-code-review/references/common-antipatterns.md +86 -0
- package/workflows/powers/frontend-code-review/references/performance-budgets.md +56 -0
- package/workflows/powers/frontend-code-review/references/review-checklists.md +47 -0
- package/workflows/powers/frontend-design/POWER.md +163 -362
- package/workflows/powers/frontend-design/SKILL.md +163 -362
- package/workflows/powers/game-development/POWER.md +57 -140
- package/workflows/powers/game-development/SKILL.md +57 -140
- package/workflows/powers/geo-fundamentals/POWER.md +64 -126
- package/workflows/powers/geo-fundamentals/SKILL.md +64 -127
- package/workflows/powers/git-workflow/POWER.md +135 -0
- package/workflows/powers/git-workflow/SKILL.md +132 -0
- package/workflows/powers/git-workflow/references/pr-review-checklist.md +63 -0
- package/workflows/powers/golang-pro/POWER.md +46 -35
- package/workflows/powers/golang-pro/SKILL.md +46 -35
- package/workflows/powers/graphql-architect/POWER.md +44 -62
- package/workflows/powers/graphql-architect/SKILL.md +44 -62
- package/workflows/powers/i18n-localization/POWER.md +118 -103
- package/workflows/powers/i18n-localization/SKILL.md +118 -103
- package/workflows/powers/java-pro/POWER.md +47 -22
- package/workflows/powers/java-pro/SKILL.md +47 -22
- package/workflows/powers/javascript-pro/POWER.md +47 -34
- package/workflows/powers/javascript-pro/SKILL.md +47 -34
- package/workflows/powers/kotlin-pro/POWER.md +46 -23
- package/workflows/powers/kotlin-pro/SKILL.md +46 -23
- package/workflows/powers/legacy-modernizer/POWER.md +43 -60
- package/workflows/powers/legacy-modernizer/SKILL.md +43 -60
- package/workflows/powers/mcp-builder/POWER.md +65 -0
- package/workflows/powers/mcp-builder/SKILL.md +62 -0
- package/workflows/powers/mcp-builder/references/testing-and-evals.md +17 -0
- package/workflows/powers/mcp-builder/references/transport-and-tool-design.md +17 -0
- package/workflows/powers/microservices-architect/POWER.md +43 -70
- package/workflows/powers/microservices-architect/SKILL.md +43 -70
- package/workflows/powers/mobile-design/POWER.md +110 -345
- package/workflows/powers/mobile-design/SKILL.md +110 -345
- package/workflows/powers/mongodb/POWER.md +67 -0
- package/workflows/powers/mongodb/SKILL.md +64 -0
- package/workflows/powers/mongodb/references/mongodb-checklist.md +20 -0
- package/workflows/powers/mysql/POWER.md +67 -0
- package/workflows/powers/mysql/SKILL.md +64 -0
- package/workflows/powers/mysql/references/mysql-checklist.md +20 -0
- package/workflows/powers/neki/POWER.md +67 -0
- package/workflows/powers/neki/SKILL.md +64 -0
- package/workflows/powers/neki/references/neki-checklist.md +18 -0
- package/workflows/powers/nestjs-expert/POWER.md +45 -91
- package/workflows/powers/nestjs-expert/SKILL.md +45 -91
- package/workflows/powers/nextjs-developer/POWER.md +51 -44
- package/workflows/powers/nextjs-developer/SKILL.md +51 -44
- package/workflows/powers/nodejs-best-practices/POWER.md +48 -29
- package/workflows/powers/nodejs-best-practices/SKILL.md +48 -29
- package/workflows/powers/observability/POWER.md +109 -0
- package/workflows/powers/observability/SKILL.md +106 -0
- package/workflows/powers/observability/references/alerting-and-slo-checklist.md +87 -0
- package/workflows/powers/observability/references/opentelemetry-setup-guide.md +121 -0
- package/workflows/powers/openai-docs/POWER.md +61 -0
- package/workflows/powers/openai-docs/SKILL.md +58 -0
- package/workflows/powers/openai-docs/references/official-source-playbook.md +10 -0
- package/workflows/powers/performance-profiling/POWER.md +61 -114
- package/workflows/powers/performance-profiling/SKILL.md +61 -114
- package/workflows/powers/php-pro/POWER.md +116 -0
- package/workflows/powers/php-pro/SKILL.md +113 -0
- package/workflows/powers/php-pro/references/architecture-and-di.md +239 -0
- package/workflows/powers/php-pro/references/modern-php-features.md +189 -0
- package/workflows/powers/php-pro/references/performance-and-deployment.md +197 -0
- package/workflows/powers/php-pro/references/php84-strict-typing-checklist.md +161 -0
- package/workflows/powers/php-pro/references/testing-and-static-analysis.md +235 -0
- package/workflows/powers/playwright-e2e/POWER.md +85 -0
- package/workflows/powers/playwright-e2e/SKILL.md +82 -0
- package/workflows/powers/playwright-e2e/references/locator-trace-flake-checklist.md +80 -0
- package/workflows/powers/postgres/POWER.md +67 -0
- package/workflows/powers/postgres/SKILL.md +64 -0
- package/workflows/powers/postgres/references/postgres-checklist.md +20 -0
- package/workflows/powers/prompt-engineer/POWER.md +47 -30
- package/workflows/powers/prompt-engineer/SKILL.md +47 -30
- package/workflows/powers/python-pro/POWER.md +47 -36
- package/workflows/powers/python-pro/SKILL.md +47 -36
- package/workflows/powers/react-best-practices/POWER.md +56 -33
- package/workflows/powers/react-best-practices/SKILL.md +56 -33
- package/workflows/powers/react-expert/POWER.md +47 -37
- package/workflows/powers/react-expert/SKILL.md +47 -37
- package/workflows/powers/redis/POWER.md +67 -0
- package/workflows/powers/redis/SKILL.md +64 -0
- package/workflows/powers/redis/references/redis-checklist.md +19 -0
- package/workflows/powers/ruby-pro/POWER.md +118 -0
- package/workflows/powers/ruby-pro/SKILL.md +115 -0
- package/workflows/powers/ruby-pro/references/modern-ruby-features.md +189 -0
- package/workflows/powers/ruby-pro/references/object-design-patterns.md +220 -0
- package/workflows/powers/ruby-pro/references/performance-and-profiling.md +224 -0
- package/workflows/powers/ruby-pro/references/ruby-concurrency-and-testing.md +190 -0
- package/workflows/powers/ruby-pro/references/testing-and-rspec.md +236 -0
- package/workflows/powers/rust-pro/POWER.md +45 -31
- package/workflows/powers/rust-pro/SKILL.md +45 -31
- package/workflows/powers/security-engineer/POWER.md +129 -0
- package/workflows/powers/security-engineer/SKILL.md +126 -0
- package/workflows/powers/seo-fundamentals/POWER.md +59 -102
- package/workflows/powers/seo-fundamentals/SKILL.md +59 -102
- package/workflows/powers/serverless-patterns/POWER.md +171 -0
- package/workflows/powers/serverless-patterns/SKILL.md +168 -0
- package/workflows/powers/skill-creator/POWER.md +90 -0
- package/workflows/powers/skill-creator/SKILL.md +87 -0
- package/workflows/powers/skill-creator/references/platform-formats.md +181 -0
- package/workflows/powers/skill-creator/references/schemas.md +430 -0
- package/workflows/powers/spec-miner/POWER.md +49 -57
- package/workflows/powers/spec-miner/SKILL.md +49 -57
- package/workflows/powers/sqlite/POWER.md +67 -0
- package/workflows/powers/sqlite/SKILL.md +64 -0
- package/workflows/powers/sqlite/references/sqlite-checklist.md +19 -0
- package/workflows/powers/sre-engineer/POWER.md +123 -64
- package/workflows/powers/sre-engineer/SKILL.md +123 -64
- package/workflows/powers/static-analysis/POWER.md +121 -77
- package/workflows/powers/static-analysis/SKILL.md +121 -77
- package/workflows/powers/stripe-best-practices/POWER.md +140 -17
- package/workflows/powers/stripe-best-practices/SKILL.md +139 -17
- package/workflows/powers/supabase/POWER.md +67 -0
- package/workflows/powers/supabase/SKILL.md +64 -0
- package/workflows/powers/supabase/references/supabase-checklist.md +19 -0
- package/workflows/powers/swift-pro/POWER.md +118 -0
- package/workflows/powers/swift-pro/SKILL.md +115 -0
- package/workflows/powers/swift-pro/references/concurrency-patterns.md +165 -0
- package/workflows/powers/swift-pro/references/protocol-and-generics.md +172 -0
- package/workflows/powers/swift-pro/references/sendable-and-isolation.md +116 -0
- package/workflows/powers/swift-pro/references/swift-concurrency-and-protocols.md +260 -0
- package/workflows/powers/swift-pro/references/testing-and-packages.md +192 -0
- package/workflows/powers/tailwind-patterns/POWER.md +71 -240
- package/workflows/powers/tailwind-patterns/SKILL.md +71 -240
- package/workflows/powers/testing-patterns/POWER.md +155 -10
- package/workflows/powers/testing-patterns/SKILL.md +155 -10
- package/workflows/powers/typescript-pro/POWER.md +47 -38
- package/workflows/powers/typescript-pro/SKILL.md +47 -38
- package/workflows/powers/vitess/POWER.md +67 -0
- package/workflows/powers/vitess/SKILL.md +64 -0
- package/workflows/powers/vitess/references/vitess-checklist.md +19 -0
- package/workflows/powers/vulnerability-scanner/POWER.md +146 -10
- package/workflows/powers/vulnerability-scanner/SKILL.md +146 -10
- package/workflows/powers/web-perf/POWER.md +43 -170
- package/workflows/powers/web-perf/SKILL.md +43 -170
- package/workflows/powers/webapp-testing/POWER.md +43 -164
- package/workflows/powers/webapp-testing/SKILL.md +43 -164
- package/workflows/workflows/agent-environment-setup/platforms/antigravity/rules/GEMINI.md +65 -42
- package/workflows/workflows/agent-environment-setup/platforms/claude/rules/CLAUDE.md +8 -6
- package/workflows/workflows/agent-environment-setup/platforms/codex/rules/AGENTS.md +65 -41
- package/workflows/workflows/agent-environment-setup/platforms/copilot/rules/copilot-instructions.md +8 -6
- package/workflows/workflows/agent-environment-setup/shared/rules/STEERING.md +9 -8
- package/workflows/workflows/agent-environment-setup/shared/rules/overrides/codex.md +1 -1
|
@@ -1,113 +1,157 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: static-analysis
|
|
3
|
-
description:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- Grep
|
|
10
|
-
- AskUserQuestion
|
|
11
|
-
- Task
|
|
12
|
-
- TaskCreate
|
|
13
|
-
- TaskList
|
|
14
|
-
- TaskUpdate
|
|
3
|
+
description: Configure and use static analysis tools including linters, formatters, type checkers, and custom rules to enforce code quality and consistency.
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
metadata:
|
|
6
|
+
author: cubis-foundry
|
|
7
|
+
version: "3.0"
|
|
8
|
+
compatibility: Claude Code, Codex, GitHub Copilot, Gemini CLI
|
|
15
9
|
---
|
|
16
10
|
|
|
17
|
-
#
|
|
11
|
+
# Static Analysis
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
## Purpose
|
|
20
14
|
|
|
21
|
-
|
|
15
|
+
Guide the setup and use of static analysis tools — linters, formatters, type checkers, and custom rules — to catch bugs early, enforce conventions, and maintain code quality automatically.
|
|
22
16
|
|
|
23
|
-
##
|
|
17
|
+
## When to Use
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
- Setting up linting and formatting for a new project
|
|
20
|
+
- Configuring ESLint, Prettier, Biome, or equivalent tools
|
|
21
|
+
- Writing custom lint rules for team conventions
|
|
22
|
+
- Fixing lint errors or understanding why a rule exists
|
|
23
|
+
- Integrating static analysis into CI/CD
|
|
24
|
+
- Choosing between competing tools
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
# 1. Verify CodeQL is installed
|
|
29
|
-
command -v codeql >/dev/null 2>&1 && codeql --version || echo "NOT INSTALLED"
|
|
26
|
+
## Instructions
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
ls -dt codeql_*.db 2>/dev/null | head -1
|
|
33
|
-
```
|
|
28
|
+
### Step 1 — Choose the Right Tools
|
|
34
29
|
|
|
35
|
-
|
|
30
|
+
| Language | Linter | Formatter | Type Checker |
|
|
31
|
+
| ------------- | ------------- | --------------- | ------------------ |
|
|
32
|
+
| TypeScript/JS | ESLint, Biome | Prettier, Biome | TypeScript (`tsc`) |
|
|
33
|
+
| Python | Ruff, Flake8 | Black, Ruff | mypy, pyright |
|
|
34
|
+
| Go | golangci-lint | gofmt | Go compiler |
|
|
35
|
+
| Rust | Clippy | rustfmt | Rust compiler |
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
**Recommended approach**:
|
|
38
38
|
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
- Performing comprehensive security audits with multiple query packs
|
|
39
|
+
- Biome for TypeScript/JS projects (replaces ESLint + Prettier, faster)
|
|
40
|
+
- Ruff for Python (replaces Flake8 + Black + isort, faster)
|
|
41
|
+
- Use the language's official formatter when available
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
### Step 2 — Configure Incrementally
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
- **CI/CD integration** - Use GitHub Actions documentation directly
|
|
48
|
-
- **Quick pattern searches** - Use Semgrep or grep for speed
|
|
49
|
-
- **No build capability** for compiled languages - Consider Semgrep instead
|
|
50
|
-
- **Single-file or lightweight analysis** - Semgrep is faster for simple pattern matching
|
|
45
|
+
**Start strict, relax as needed**:
|
|
51
46
|
|
|
52
|
-
|
|
47
|
+
1. Start with recommended preset (`"extends": ["recommended"]`)
|
|
48
|
+
2. Enable formatting rules (consistent style, no debates)
|
|
49
|
+
3. Enable correctness rules (actual bugs: unused vars, unreachable code)
|
|
50
|
+
4. Enable performance rules (avoidable perf issues)
|
|
51
|
+
5. Add custom rules specific to your team after the baseline is stable
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
**Don't**:
|
|
55
54
|
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
- **"build-mode=none is fine for compiled languages"** - It produces severely incomplete analysis. No interprocedural data flow through compiled code is traced. Only use as an absolute last resort and clearly flag the limitation.
|
|
60
|
-
- **"No findings means the code is secure"** - Zero findings can indicate poor database quality, missing models, or wrong query packs. Investigate before reporting clean results.
|
|
61
|
-
- **"I'll just run the default suite"** - The default suite varies by how CodeQL is invoked. Always explicitly specify the suite (e.g., `security-extended`) so results are reproducible.
|
|
55
|
+
- Enable everything at once on an existing codebase
|
|
56
|
+
- Disable rules because they're "annoying" without understanding them
|
|
57
|
+
- Use `// eslint-disable` without a comment explaining why
|
|
62
58
|
|
|
63
|
-
|
|
59
|
+
### Step 3 — Key Rules by Category
|
|
64
60
|
|
|
65
|
-
|
|
61
|
+
**Correctness** (catch bugs):
|
|
66
62
|
|
|
67
|
-
|
|
63
|
+
- No unused variables/imports
|
|
64
|
+
- No unreachable code
|
|
65
|
+
- No implicit type coercion in comparisons
|
|
66
|
+
- No floating promises (unhandled async)
|
|
67
|
+
- No shadowed variables in nested scopes
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|----------|---------|
|
|
71
|
-
| [build-database](workflows/build-database.md) | Create CodeQL database using 3 build methods in sequence |
|
|
72
|
-
| [create-data-extensions](workflows/create-data-extensions.md) | Detect or generate data extension models for project APIs |
|
|
73
|
-
| [run-analysis](workflows/run-analysis.md) | Select rulesets, execute queries, process results |
|
|
69
|
+
**Consistency** (enforce style):
|
|
74
70
|
|
|
71
|
+
- Consistent naming conventions (camelCase, PascalCase, SCREAMING_SNAKE)
|
|
72
|
+
- Consistent import ordering
|
|
73
|
+
- Consistent quote style and semicolons
|
|
74
|
+
- Consistent use of `const` vs `let`
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
**Security** (prevent vulnerabilities):
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
- No `eval()` or `Function()` constructor
|
|
79
|
+
- No `innerHTML` assignments (XSS risk)
|
|
80
|
+
- No hardcoded secrets or credentials
|
|
81
|
+
- No `any` type in TypeScript (use `unknown` for unknown types)
|
|
79
82
|
|
|
80
|
-
**
|
|
83
|
+
**Performance** (avoid waste):
|
|
81
84
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
- No unnecessary re-renders (React-specific)
|
|
86
|
+
- No synchronous file operations in async contexts
|
|
87
|
+
- No `console.log` in production code
|
|
88
|
+
|
|
89
|
+
### Step 4 — Integrate into Workflow
|
|
90
|
+
|
|
91
|
+
**Local development**:
|
|
92
|
+
|
|
93
|
+
- Editor integration (real-time feedback as you type)
|
|
94
|
+
- Format on save
|
|
95
|
+
- Pre-commit hook (lint-staged + husky or lefthook)
|
|
96
|
+
|
|
97
|
+
**CI/CD**:
|
|
98
|
+
|
|
99
|
+
- Run lint check on every PR
|
|
100
|
+
- Fail the build on lint errors (not warnings — fix or disable)
|
|
101
|
+
- Cache lint results between runs
|
|
91
102
|
|
|
92
|
-
|
|
93
|
-
|-----------|--------|
|
|
94
|
-
| No database exists | Execute build → extensions → analysis (full pipeline) |
|
|
95
|
-
| Database exists, no extensions | Execute extensions → analysis |
|
|
96
|
-
| Database exists, extensions exist | Ask user: run analysis on existing DB, or rebuild? |
|
|
97
|
-
| User says "just run analysis" or "skip extensions" | Run analysis only |
|
|
103
|
+
**Migration strategy** (existing codebase):
|
|
98
104
|
|
|
105
|
+
- Fix auto-fixable issues in one PR (formatting, import order)
|
|
106
|
+
- Enable new rules as warnings first, then promote to errors
|
|
107
|
+
- Fix rules incrementally by directory, not all at once
|
|
99
108
|
|
|
100
|
-
###
|
|
109
|
+
### Step 5 — Write Custom Rules
|
|
101
110
|
|
|
102
|
-
|
|
111
|
+
When team conventions aren't covered by existing rules:
|
|
103
112
|
|
|
113
|
+
**ESLint custom rule example** (no importing from internal paths):
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
module.exports = {
|
|
117
|
+
meta: {
|
|
118
|
+
type: "problem",
|
|
119
|
+
messages: { noInternal: "Do not import from internal modules" },
|
|
120
|
+
},
|
|
121
|
+
create(context) {
|
|
122
|
+
return {
|
|
123
|
+
ImportDeclaration(node) {
|
|
124
|
+
if (node.source.value.includes("/internal/")) {
|
|
125
|
+
context.report({ node, messageId: "noInternal" });
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
};
|
|
104
131
|
```
|
|
105
|
-
I can help with CodeQL analysis. What would you like to do?
|
|
106
132
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
133
|
+
## Output Format
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
## Tool Configuration
|
|
137
|
+
[config files and settings]
|
|
138
|
+
|
|
139
|
+
## Rules Enabled
|
|
140
|
+
[categorized list of rules with rationale]
|
|
141
|
+
|
|
142
|
+
## CI Integration
|
|
143
|
+
[pipeline step definition]
|
|
111
144
|
|
|
112
|
-
|
|
145
|
+
## Migration Plan
|
|
146
|
+
[how to adopt incrementally on existing code]
|
|
113
147
|
```
|
|
148
|
+
|
|
149
|
+
## Examples
|
|
150
|
+
|
|
151
|
+
**User**: "Set up ESLint and Prettier for our TypeScript React project"
|
|
152
|
+
|
|
153
|
+
**Response approach**: Recommend Biome as modern alternative. If staying with ESLint: configure with typescript-eslint, eslint-plugin-react, prettier integration. Show config file, ignore patterns, and pre-commit hook setup.
|
|
154
|
+
|
|
155
|
+
**User**: "We have 5000 lint errors — how do we fix this?"
|
|
156
|
+
|
|
157
|
+
**Response approach**: Auto-fix formatting issues first (one big PR). Establish baseline with current errors suppressed. Enable rules as warnings. Fix incrementally by directory. Add CI check that blocks new violations.
|
|
@@ -2,35 +2,158 @@
|
|
|
2
2
|
---
|
|
3
3
|
inclusion: manual
|
|
4
4
|
name: stripe-best-practices
|
|
5
|
-
description:
|
|
6
|
-
|
|
5
|
+
description: Implement Stripe payments, subscriptions, webhooks, checkout flows, and billing management with security and compliance best practices.
|
|
6
|
+
license: Apache-2.0
|
|
7
|
+
metadata:
|
|
8
|
+
author: cubis-foundry
|
|
9
|
+
version: "3.0"
|
|
10
|
+
compatibility: Claude Code, Codex, GitHub Copilot, Gemini CLI
|
|
7
11
|
---
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
# Stripe Best Practices
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
The [API Tour](https://docs.stripe.com/payments-api/tour.md)
|
|
13
|
-
Use the [Go Live Checklist](https://docs.stripe.com/get-started/checklist/go-live.md) before going live.
|
|
15
|
+
## Purpose
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
Guide implementation of Stripe payment integrations including one-time payments, subscriptions, webhook handling, and billing management with security and compliance best practices.
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
## When to Use
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
- Integrating Stripe Checkout or Payment Intents
|
|
22
|
+
- Building subscription billing with Stripe
|
|
23
|
+
- Handling Stripe webhooks securely
|
|
24
|
+
- Managing customers, invoices, and payment methods
|
|
25
|
+
- Implementing pricing pages and plan management
|
|
26
|
+
- Debugging failed payments or webhook issues
|
|
20
27
|
|
|
21
|
-
|
|
28
|
+
## Instructions
|
|
22
29
|
|
|
23
|
-
|
|
30
|
+
### Step 1 — Choose the Right Integration
|
|
24
31
|
|
|
25
|
-
|
|
32
|
+
| Pattern | Use When |
|
|
33
|
+
| -------------------------- | --------------------------------------------------------- |
|
|
34
|
+
| Stripe Checkout (hosted) | Fastest to ship, Stripe handles the UI and PCI compliance |
|
|
35
|
+
| Payment Element (embedded) | Custom UI needed, Stripe handles payment method logic |
|
|
36
|
+
| Payment Intents (API-only) | Full control, server-side payment flow |
|
|
37
|
+
| Stripe Billing | Recurring subscriptions with invoicing |
|
|
26
38
|
|
|
27
|
-
|
|
39
|
+
**Default to Stripe Checkout** unless you have a specific reason for embedded or API-only.
|
|
28
40
|
|
|
29
|
-
|
|
41
|
+
### Step 2 — Payment Flow Architecture
|
|
30
42
|
|
|
31
|
-
|
|
43
|
+
**Server-side creates, client-side confirms**:
|
|
32
44
|
|
|
33
|
-
|
|
45
|
+
```
|
|
46
|
+
Client Server Stripe
|
|
47
|
+
│ │ │
|
|
48
|
+
├─ "I want to pay" ──────►│ │
|
|
49
|
+
│ ├─ Create PaymentIntent ─►│
|
|
50
|
+
│ │◄─ client_secret ────────┤
|
|
51
|
+
│◄─ client_secret ────────┤ │
|
|
52
|
+
├─ confirmPayment() ─────────────────────────────►│
|
|
53
|
+
│◄─ result ──────────────────────────────────────-─┤
|
|
54
|
+
│ │◄─ webhook: succeeded ──┤
|
|
55
|
+
│ ├─ fulfill order ────────►│
|
|
56
|
+
```
|
|
34
57
|
|
|
35
|
-
|
|
58
|
+
**Rules**:
|
|
59
|
+
|
|
60
|
+
- Never trust the client for amounts or currency — set on the server
|
|
61
|
+
- Use idempotency keys for all server-side Stripe API calls
|
|
62
|
+
- Always handle the `payment_intent.succeeded` webhook for fulfillment
|
|
63
|
+
- Don't fulfill on client-side confirmation alone (user could close the tab)
|
|
64
|
+
|
|
65
|
+
### Step 3 — Webhook Handling
|
|
66
|
+
|
|
67
|
+
**Verify every webhook signature**:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const event = stripe.webhooks.constructEvent(
|
|
71
|
+
body, // raw request body
|
|
72
|
+
signature, // Stripe-Signature header
|
|
73
|
+
endpointSecret, // from Stripe dashboard
|
|
74
|
+
);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Essential webhook events**:
|
|
78
|
+
| Event | Action |
|
|
79
|
+
|-------|--------|
|
|
80
|
+
| `payment_intent.succeeded` | Fulfill the order |
|
|
81
|
+
| `payment_intent.payment_failed` | Notify user, retry logic |
|
|
82
|
+
| `customer.subscription.created` | Activate subscription |
|
|
83
|
+
| `customer.subscription.updated` | Update plan/features |
|
|
84
|
+
| `customer.subscription.deleted` | Deactivate subscription |
|
|
85
|
+
| `invoice.payment_failed` | Dunning: email user, retry |
|
|
86
|
+
| `invoice.paid` | Extend subscription period |
|
|
87
|
+
|
|
88
|
+
**Webhook best practices**:
|
|
89
|
+
|
|
90
|
+
- Return 200 immediately, process asynchronously
|
|
91
|
+
- Handle events idempotently (same event may be delivered multiple times)
|
|
92
|
+
- Log every event with its ID for debugging
|
|
93
|
+
- Set up webhook endpoint monitoring
|
|
94
|
+
|
|
95
|
+
### Step 4 — Subscription Management
|
|
96
|
+
|
|
97
|
+
**Subscription lifecycle**:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
trial → active → past_due → canceled
|
|
101
|
+
↓
|
|
102
|
+
unpaid → canceled
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Implementation**:
|
|
106
|
+
|
|
107
|
+
- Store `stripe_customer_id` and `stripe_subscription_id` in your database
|
|
108
|
+
- Sync subscription status from webhooks (not API polling)
|
|
109
|
+
- Implement dunning (failed payment retries): Stripe auto-retries, you handle UX
|
|
110
|
+
- Allow users to update payment method without canceling
|
|
111
|
+
- Prorate when changing plans mid-cycle
|
|
112
|
+
|
|
113
|
+
### Step 5 — Security & Compliance
|
|
114
|
+
|
|
115
|
+
**PCI Compliance**:
|
|
116
|
+
|
|
117
|
+
- Use Stripe Elements or Checkout — never handle raw card numbers
|
|
118
|
+
- No card data in your logs, database, or error messages
|
|
119
|
+
- Use HTTPS everywhere
|
|
120
|
+
|
|
121
|
+
**Fraud Prevention**:
|
|
122
|
+
|
|
123
|
+
- Enable Stripe Radar for automated fraud detection
|
|
124
|
+
- Verify billing address (AVS) and CVC
|
|
125
|
+
- Implement velocity checks (too many attempts in short time)
|
|
126
|
+
- Review high-risk payments manually
|
|
127
|
+
|
|
128
|
+
**Testing**:
|
|
129
|
+
|
|
130
|
+
- Use test mode API keys (never production keys in development)
|
|
131
|
+
- Use Stripe test card numbers (4242... for success, 4000... for declines)
|
|
132
|
+
- Test webhook handling with Stripe CLI: `stripe listen --forward-to localhost:3000/webhooks`
|
|
133
|
+
|
|
134
|
+
## Output Format
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
## Payment Integration
|
|
138
|
+
[architecture and flow]
|
|
139
|
+
|
|
140
|
+
## Implementation
|
|
141
|
+
[code with security considerations]
|
|
142
|
+
|
|
143
|
+
## Webhook Setup
|
|
144
|
+
[events to handle and processing logic]
|
|
145
|
+
|
|
146
|
+
## Testing Plan
|
|
147
|
+
[test scenarios and test card numbers]
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Examples
|
|
151
|
+
|
|
152
|
+
**User**: "Set up Stripe Checkout for our SaaS pricing page with monthly and annual plans"
|
|
153
|
+
|
|
154
|
+
**Response approach**: Create Stripe Products and Prices for each plan. Server route creates Checkout Session with correct price ID. Redirect to Stripe Checkout. Handle `checkout.session.completed` webhook. Store customer and subscription IDs. Build subscription management page.
|
|
155
|
+
|
|
156
|
+
**User**: "Handle failed payments for our subscription service"
|
|
157
|
+
|
|
158
|
+
**Response approach**: Implement dunning flow. Handle `invoice.payment_failed` webhook. Email customer with payment update link. Configure Stripe retry schedule. Handle `customer.subscription.updated` with `status: past_due`. Implement grace period before cancellation.
|
|
36
159
|
````
|
|
@@ -1,34 +1,156 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: stripe-best-practices
|
|
3
|
-
description:
|
|
4
|
-
|
|
3
|
+
description: Implement Stripe payments, subscriptions, webhooks, checkout flows, and billing management with security and compliance best practices.
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
metadata:
|
|
6
|
+
author: cubis-foundry
|
|
7
|
+
version: "3.0"
|
|
8
|
+
compatibility: Claude Code, Codex, GitHub Copilot, Gemini CLI
|
|
5
9
|
---
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
# Stripe Best Practices
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
The [API Tour](https://docs.stripe.com/payments-api/tour.md)
|
|
11
|
-
Use the [Go Live Checklist](https://docs.stripe.com/get-started/checklist/go-live.md) before going live.
|
|
13
|
+
## Purpose
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
Guide implementation of Stripe payment integrations including one-time payments, subscriptions, webhook handling, and billing management with security and compliance best practices.
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
## When to Use
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
- Integrating Stripe Checkout or Payment Intents
|
|
20
|
+
- Building subscription billing with Stripe
|
|
21
|
+
- Handling Stripe webhooks securely
|
|
22
|
+
- Managing customers, invoices, and payment methods
|
|
23
|
+
- Implementing pricing pages and plan management
|
|
24
|
+
- Debugging failed payments or webhook issues
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
## Instructions
|
|
20
27
|
|
|
21
|
-
|
|
28
|
+
### Step 1 — Choose the Right Integration
|
|
22
29
|
|
|
23
|
-
|
|
30
|
+
| Pattern | Use When |
|
|
31
|
+
| -------------------------- | --------------------------------------------------------- |
|
|
32
|
+
| Stripe Checkout (hosted) | Fastest to ship, Stripe handles the UI and PCI compliance |
|
|
33
|
+
| Payment Element (embedded) | Custom UI needed, Stripe handles payment method logic |
|
|
34
|
+
| Payment Intents (API-only) | Full control, server-side payment flow |
|
|
35
|
+
| Stripe Billing | Recurring subscriptions with invoicing |
|
|
24
36
|
|
|
25
|
-
|
|
37
|
+
**Default to Stripe Checkout** unless you have a specific reason for embedded or API-only.
|
|
26
38
|
|
|
27
|
-
|
|
39
|
+
### Step 2 — Payment Flow Architecture
|
|
28
40
|
|
|
29
|
-
|
|
41
|
+
**Server-side creates, client-side confirms**:
|
|
30
42
|
|
|
31
|
-
|
|
43
|
+
```
|
|
44
|
+
Client Server Stripe
|
|
45
|
+
│ │ │
|
|
46
|
+
├─ "I want to pay" ──────►│ │
|
|
47
|
+
│ ├─ Create PaymentIntent ─►│
|
|
48
|
+
│ │◄─ client_secret ────────┤
|
|
49
|
+
│◄─ client_secret ────────┤ │
|
|
50
|
+
├─ confirmPayment() ─────────────────────────────►│
|
|
51
|
+
│◄─ result ──────────────────────────────────────-─┤
|
|
52
|
+
│ │◄─ webhook: succeeded ──┤
|
|
53
|
+
│ ├─ fulfill order ────────►│
|
|
54
|
+
```
|
|
32
55
|
|
|
33
|
-
|
|
56
|
+
**Rules**:
|
|
34
57
|
|
|
58
|
+
- Never trust the client for amounts or currency — set on the server
|
|
59
|
+
- Use idempotency keys for all server-side Stripe API calls
|
|
60
|
+
- Always handle the `payment_intent.succeeded` webhook for fulfillment
|
|
61
|
+
- Don't fulfill on client-side confirmation alone (user could close the tab)
|
|
62
|
+
|
|
63
|
+
### Step 3 — Webhook Handling
|
|
64
|
+
|
|
65
|
+
**Verify every webhook signature**:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const event = stripe.webhooks.constructEvent(
|
|
69
|
+
body, // raw request body
|
|
70
|
+
signature, // Stripe-Signature header
|
|
71
|
+
endpointSecret, // from Stripe dashboard
|
|
72
|
+
);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Essential webhook events**:
|
|
76
|
+
| Event | Action |
|
|
77
|
+
|-------|--------|
|
|
78
|
+
| `payment_intent.succeeded` | Fulfill the order |
|
|
79
|
+
| `payment_intent.payment_failed` | Notify user, retry logic |
|
|
80
|
+
| `customer.subscription.created` | Activate subscription |
|
|
81
|
+
| `customer.subscription.updated` | Update plan/features |
|
|
82
|
+
| `customer.subscription.deleted` | Deactivate subscription |
|
|
83
|
+
| `invoice.payment_failed` | Dunning: email user, retry |
|
|
84
|
+
| `invoice.paid` | Extend subscription period |
|
|
85
|
+
|
|
86
|
+
**Webhook best practices**:
|
|
87
|
+
|
|
88
|
+
- Return 200 immediately, process asynchronously
|
|
89
|
+
- Handle events idempotently (same event may be delivered multiple times)
|
|
90
|
+
- Log every event with its ID for debugging
|
|
91
|
+
- Set up webhook endpoint monitoring
|
|
92
|
+
|
|
93
|
+
### Step 4 — Subscription Management
|
|
94
|
+
|
|
95
|
+
**Subscription lifecycle**:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
trial → active → past_due → canceled
|
|
99
|
+
↓
|
|
100
|
+
unpaid → canceled
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Implementation**:
|
|
104
|
+
|
|
105
|
+
- Store `stripe_customer_id` and `stripe_subscription_id` in your database
|
|
106
|
+
- Sync subscription status from webhooks (not API polling)
|
|
107
|
+
- Implement dunning (failed payment retries): Stripe auto-retries, you handle UX
|
|
108
|
+
- Allow users to update payment method without canceling
|
|
109
|
+
- Prorate when changing plans mid-cycle
|
|
110
|
+
|
|
111
|
+
### Step 5 — Security & Compliance
|
|
112
|
+
|
|
113
|
+
**PCI Compliance**:
|
|
114
|
+
|
|
115
|
+
- Use Stripe Elements or Checkout — never handle raw card numbers
|
|
116
|
+
- No card data in your logs, database, or error messages
|
|
117
|
+
- Use HTTPS everywhere
|
|
118
|
+
|
|
119
|
+
**Fraud Prevention**:
|
|
120
|
+
|
|
121
|
+
- Enable Stripe Radar for automated fraud detection
|
|
122
|
+
- Verify billing address (AVS) and CVC
|
|
123
|
+
- Implement velocity checks (too many attempts in short time)
|
|
124
|
+
- Review high-risk payments manually
|
|
125
|
+
|
|
126
|
+
**Testing**:
|
|
127
|
+
|
|
128
|
+
- Use test mode API keys (never production keys in development)
|
|
129
|
+
- Use Stripe test card numbers (4242... for success, 4000... for declines)
|
|
130
|
+
- Test webhook handling with Stripe CLI: `stripe listen --forward-to localhost:3000/webhooks`
|
|
131
|
+
|
|
132
|
+
## Output Format
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
## Payment Integration
|
|
136
|
+
[architecture and flow]
|
|
137
|
+
|
|
138
|
+
## Implementation
|
|
139
|
+
[code with security considerations]
|
|
140
|
+
|
|
141
|
+
## Webhook Setup
|
|
142
|
+
[events to handle and processing logic]
|
|
143
|
+
|
|
144
|
+
## Testing Plan
|
|
145
|
+
[test scenarios and test card numbers]
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Examples
|
|
149
|
+
|
|
150
|
+
**User**: "Set up Stripe Checkout for our SaaS pricing page with monthly and annual plans"
|
|
151
|
+
|
|
152
|
+
**Response approach**: Create Stripe Products and Prices for each plan. Server route creates Checkout Session with correct price ID. Redirect to Stripe Checkout. Handle `checkout.session.completed` webhook. Store customer and subscription IDs. Build subscription management page.
|
|
153
|
+
|
|
154
|
+
**User**: "Handle failed payments for our subscription service"
|
|
155
|
+
|
|
156
|
+
**Response approach**: Implement dunning flow. Handle `invoice.payment_failed` webhook. Email customer with payment update link. Configure Stripe retry schedule. Handle `customer.subscription.updated` with `status: past_due`. Implement grace period before cancellation.
|