# AGENTS.md — Business guardrails

This file is for coding agents (Cursor, Claude Code, Codex, Copilot, whatever ships next).
Architecture docs tell you how the code is shaped. This tells you how the **business** is
shaped, so you stop inventing features for users who do not exist and stop quietly changing
prices, limits and plan gates.

Read this before you write a feature. Read the four files below before you write a feature
that touches users, money, or what we say publicly.

## Read order

1. `ICP.md` — who we serve and, more importantly, who we reject.
2. `ENTITLEMENTS.json` — the only source of truth for plans, limits and paid features.
3. `ASSUMPTIONS.md` — the unverified bets the product currently rests on.
4. `DECISION_LOG.md` — what we already decided, what we predicted, and when we review it.
5. This file.

If those files disagree with each other, that is a bug. Stop and write a Proposed entry in
`DECISION_LOG.md` instead of picking a side on your own.

## The five rules

1. **No feature without a decision.** If the change adds a screen, a plan gate, a pricing
   number, a limit, or a segment we serve, there must be a matching entry in
   `DECISION_LOG.md` (status: Accepted or Proposed). If there isn't one, add a Proposed
   entry in the same PR and say so in the PR description. Do not invent product strategy
   because a task was ambiguous.

2. **Plans and limits come from `ENTITLEMENTS.json` only.** Never hardcode "3 projects",
   "$19", "14-day trial" or a feature flag name in a component, an API route, a migration
   or a test fixture. Import or read the file. If the shape you need is missing, extend the
   JSON with a documented key and update both readers in the same PR.

3. **Do not build for a user who is not in `ICP.md`.** "A user might want..." is not a
   requirement. If a task asks for something that serves the rejected list, surface the
   conflict before writing code. This is the single biggest source of wasted weeks.

4. **Never change a price, a limit, a trial length or a grandfathering rule silently.** Those
   changes require a decision entry with a predicted outcome and a review date. They also
   require a note in the PR about who is affected: existing paying users, trial users, or
   only new signups.

5. **When you are unsure, write down the assumption.** If you ship something that depends on
   a belief nobody has tested ("people will connect Stripe on day one"), add a row to
   `ASSUMPTIONS.md` with a kill date. Unwritten assumptions become permanent features.

## Pricing contract: one file, two readers

`ENTITLEMENTS.json` is read by two places, and they must never drift:

- **The marketing pricing page** renders plan names, prices, intervals, limits and the
  feature comparison from the JSON at build/request time. It may format values; it may not
  own them.
- **The application** reads the same JSON (directly or through one generated
  `lib/entitlements.ts`) to decide what a workspace can do: gates, counters, upgrade
  prompts. Server-side enforcement is the source of truth; the UI only reflects it.

Rules for both readers:

- Prices are integers in the smallest currency unit (cents). Format for display, never store
  formatted strings.
- Limits use `null` for unlimited. `0` means the feature is not included.
- Feature keys are stable strings (`sso`, `custom_domain`, `api_access`). Renaming a key is a
  breaking change and needs a migration note.
- A plan that is hidden (`"visible": false`) can still be sold to grandfathered users. Hidden
  is not deleted.
- Trials are described in the JSON once (`trial_days`, `requires_card`). Do not add a second
  trial definition in code.

When you change the file, run the pricing page and the app against it and confirm the numbers
match. A marketing page that promises a limit the API does not enforce is a support ticket
and, eventually, a refund.

## If you are asked to "just add a plan" or "change the limit"

1. Open `ENTITLEMENTS.json`. Change the data. Do not touch component copy.
2. Check every place that reads the file: pricing page, upgrade modal, settings billing tab,
   server-side gate. None of them should need a code change.
3. If one of them does need a code change, that reader was hardcoding. Fix the reader, not the
   JSON shape.
4. Add a decision entry: context, options, decision, predicted outcome, review date.
5. Note in the PR who this affects and whether existing users are grandfathered.

## Do not touch without an explicit human decision

- Billing webhooks and invoice logic.
- The entitlements schema or the meaning of an existing feature key.
- Trial length, card requirements, or refund policy.
- Anything that changes what an existing paying customer can do.

If a task requires one of these, stop and ask. "The ticket said so" is not a decision entry.

## Definition of done for any feature PR

- [ ] A decision entry exists (Accepted or Proposed) and is linked in the PR.
- [ ] No price, limit, plan name or trial length is hardcoded; all come from `ENTITLEMENTS.json`.
- [ ] The feature serves a segment named in `ICP.md`.
- [ ] Any new unverified belief is in `ASSUMPTIONS.md` with a kill date.
- [ ] The pricing page and the app still agree, verified by reading both.
- [ ] If the change is user-visible, one sentence in the PR explains what a customer will
      notice and what they will not.

## Where these files live

Keep the folder at `docs/business/`. Coding agents look for `AGENTS.md` and `CLAUDE.md` at the
repository root, so add a one-line pointer at the root (or use Claude Code's `@` import):

```
# Root AGENTS.md
Business rules: @docs/business/AGENTS.md
```

```
# Root CLAUDE.md
@docs/business/CLAUDE.md
```

If your tool does not support imports, copy the two files to the root and keep the canonical
copy here. Either way, there is one canonical copy and no third version.
