agentleFS
StripeKnown publisherstripe/stripe-commercetools-connect-app/CLAUDE.md

stripe-commercetools-connect-app

CLAUDE.md18 starsChanged 51 days agoMITView on GitHub

commercetools Connect connector integrating Stripe Payment Element with subscriptions, mixed cart support, price synchronization, and express checkout. Stack: Node.js/TypeScript + commercetools + Stripe v20 Type: Connector - Support Version: 4.0.1 There is no root package.json — run these from processor/ or enabler/ individually.

  • Installs packages

The file

We split this CLAUDE.md into the rules it gives an agent

9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read context/ARCHITECTURE.md — components, flows, and boundaries (subscriptions, mixed carts, price/coupon sync)

    line 28
  2. Very specific:

    Read context/known-issues.md — known bugs and active restrictions, referenced as KI-### throughout this file

    line 29
  3. Very specific:

    Read context/failure-modes.md — how the connector degrades when Stripe or commercetools misbehaves

    line 30
  4. Very specific:

    Read the relevant context/business-rules/ file for the domain being touched

    line 31
  5. Distinctive:

    No card data stored — Payment Method IDs only

    line 84
  6. Very specific:

    Add a new payment method to createComponentBuilder without fixing the hardcoded empty supportedMethods map first (KI-025)

    line 113
  7. Distinctive:

    Delete and recreate a Stripe coupon because Stripe reports it unusable — the coupon id is the CT discount code id, and Stripe hands a …

    line 114
  8. Very specific:

    Write max_redemptions onto a Stripe coupon — the usage cap is enforced by commercetools, and mirroring it is what made Stripe mark coupons …

    line 115
  9. Very specific:

    Call cancelSubscription() and assume CT is updated afterward — today it only cancels in Stripe.

    line 116

≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

ct-connect-stripe-composable

commercetools Connect connector integrating Stripe Payment Element with subscriptions, mixed cart support, price synchronization, and express checkout.

Overview

Stack: Node.js/TypeScript + commercetools + Stripe v20 Type: Connector - Support Version: 4.0.1

Structure

ct-connect-stripe-composable/
  processor/          # Backend — Stripe API + CT payment + subscription management
  enabler/            # Frontend — Stripe Payment Element wrapper
  docs/               # Architecture diagrams and documentation
  context/
    ARCHITECTURE.md   # System overview: components, flows, boundaries
    business-rules/   # Invariants and documented rules
    workflows/        # Detailed process flows
    decisions/        # Key decisions and their rationale (ADRs)
    reference/        # External API/SDK reference docs

Before Every Task

  1. Read context/ARCHITECTURE.md — components, flows, and boundaries (subscriptions, mixed carts, price/coupon sync)
  2. Read context/known-issues.md — known bugs and active restrictions, referenced as KI-### throughout this file
  3. Read context/failure-modes.md — how the connector degrades when Stripe or commercetools misbehaves
  4. Read the relevant context/business-rules/ file for the domain being touched

Commands

There is no root package.json — run these from processor/ or enabler/ individually.

# Install
npm install

# Build
npm run build

# Test (processor's `test` already runs with --collect-coverage; enabler's does not)
npm run test

# Lint
npm run lint

# Local dev (processor)
cd processor && npm run start:dev

Stack

  • Runtime: Node.js
  • Language: TypeScript
  • CT SDK: @commercetools/platform-sdk (transitive via connect-payments-sdk)
  • Stripe SDK: stripe@^20.1.0
  • CT Connect SDK: @commercetools/connect-payments-sdk
  • Test framework: Jest

Business Rules

RuleContext docSource
Payment Intent creation and capture—processor/src/services/stripe-payment.service.ts
Subscription creation and managementcontext/business-rules/subscription-lifecycle.mdprocessor/src/services/stripe-subscription.service.ts
Customer session managementcontext/workflows/process-customer-session.mdprocessor/src/services/stripe-customer.service.ts
Express Checkout shipping synccontext/workflows/process-shipping.mdprocessor/src/services/stripe-shipping.service.ts
Coupon and discount sync (CT → Stripe)context/business-rules/coupon-sync.mdprocessor/src/services/stripe-coupon.service.ts
CT payment object creation—processor/src/services/ct-payment-creation.service.ts
Mixed cart handling (subscription + one-time)context/business-rules/mixed-carts.mdprocessor/src/services/stripe-subscription.service.ts
Subscription price synchronizationcontext/business-rules/price-sync.mdprocessor/src/services/stripe-subscription.service.ts
Multicapture and multirefundcontext/business-rules/multi-operations.mdprocessor/src/services/stripe-payment.service.ts
Launchpad purchase order integrationcontext/business-rules/launchpad-integration.mdprocessor/src/custom-types/custom-types.ts
Stripe Tax integrationcontext/business-rules/tax-integration.mdprocessor/src/constants.ts

Conventions

  • Idempotency keys required on all Stripe write operations
  • Amounts always in cents (integer)
  • Webhook handlers respond 200 immediately, process async
  • No card data stored — Payment Method IDs only
  • CT payment version tracked for optimistic locking
  • Subscription product attributes use stripeConnector_ prefix
  • Price sync source of truth: Stripe for subscription lifecycle, CT for prices
  • Mixed carts: one-time items billed on first subscription invoice

Decisions

  • Stripe Payment Element for PCI compliance reduction
  • Server-side Payment Intent confirmation for 3DS support
  • CT payment object as source of truth for transaction state
  • Multi-capture opt-in via STRIPE_ENABLE_MULTI_OPERATIONS=true
  • Subscription price sync opt-in via STRIPE_SUBSCRIPTION_PRICE_SYNC_ENABLED=true
  • Express Checkout address changes trigger CT shipping rate recalculation

Coding Rules

  • Idempotency keys for price/subscription creation must derive from stable CT identifiers (CT price ID + variant SKU) — never Date.now() or another timestamp (KI-013)
  • Cart freeze/unfreeze failures on subscription creation must abort the operation, not continue silently — a failed freeze leaves the cart editable mid-subscription (KI-008)
  • CT product type updates must use update-in-place (add missing fields, remove stale) — never delete-then-create, a failed create after delete permanently removes the type (KI-012)
  • A cart may contain at most one subscription line item — reject additional ones at subscription creation, do not process them silently (KI-018, business-rules/mixed-carts.md Rule 4)
  • Any reuse of an existing Stripe Price (line item or shipping) must verify the amount still matches the current CT price, not just that the price is active (KI-021)
  • A CT discount code is translated to a Stripe coupon only when its DiscountCodeInfo.state is MatchesCart — commercetools is the authority on whether a code applies, and the connector never re-derives that from the code's own configuration (KI-055, business-rules/coupon-sync.md Rule 3)

What Claude Must Never Do

  • Catch a Stripe or CT error inside processSubscriptionEventPaid/Charged/Failed (or any webhook handler) and return HTTP 200 anyway (KI-002, KI-003)
  • Register a new subscription webhook event without keeping enabled_events (actions.ts) and the route dispatcher case in sync — the two must always match. charge.updated is a live example of the mismatch (route handler exists, but it is not registered in actions.ts), a bug to fix, not a pattern to copy. (customer.subscription.deleted was the same kind of gap and is now fixed — registered + handled; see KI-009 RESOLVED / the KI-010 residual.)
  • Resolve "the" refund from a list call (refunds.list(limit: 2)[0]) without correlating to the actual webhook event's own refund object — near-simultaneous refunds can misattribute amount/ID (KI-023)
  • Add a new payment method to createComponentBuilder without fixing the hardcoded empty supportedMethods map first (KI-025)
  • Delete and recreate a Stripe coupon because Stripe reports it unusable — the coupon id is the CT discount code id, and Stripe hands a recreated id a fresh redemption counter. Only configuration divergence from commercetools may trigger a re-sync (KI-055, business-rules/coupon-sync.md Rule 4)
  • Write max_redemptions onto a Stripe coupon — the usage cap is enforced by commercetools, and mirroring it is what made Stripe mark coupons invalid on exhaustion in the first place (KI-055, ADR-018)
  • Call cancelSubscription() and assume CT is updated afterward — today it only cancels in Stripe; CT stays frozen with a stale subscription ID until this is fixed (KI-010)

Skills

See @../.claude/SKILLS-REFERENCE.md

Context

  • Architecture: context/ARCHITECTURE.md
  • Business rules: context/business-rules/
  • Workflows: context/workflows/
  • Decisions: context/decisions/
  • Known issues: context/known-issues.md
  • Failure modes: context/failure-modes.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.