@vocdoni/skills 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +5 -15
- package/CHANGELOG.md +26 -0
- package/README.md +32 -21
- package/bin/install.js +22 -5
- package/package.json +2 -1
- package/plugins/agentic-dev/.claude-plugin/plugin.json +2 -2
- package/plugins/agentic-dev/agents/model-router.md +105 -0
- package/plugins/agentic-dev/skills/subagent-driven-development/SKILL.md +22 -12
- package/plugins/agentic-dev/skills/subagent-driven-development/references/audits.md +20 -13
- package/plugins/agentic-dev/skills/subagent-driven-development/references/dispatch.md +37 -1
- package/plugins/agentic-dev/skills/subagent-driven-development/references/ledger.md +5 -3
- package/plugins/agentic-dev/skills/subagent-driven-development/references/model-catalog.md +118 -0
- package/plugins/agentic-dev/skills/subagent-driven-development/references/models.md +93 -70
- package/plugins/agentic-dev/skills/subagent-driven-development/scripts/init-workspace.sh +1 -1
- package/plugins/agentic-dev/skills/subagent-driven-development/scripts/model-inventory.sh +140 -0
- package/plugins/claude-pi-subagent/plugins/pi-subagent/package-lock.json +6 -6
- package/plugins/vocdoni-comments/.claude-plugin/plugin.json +2 -2
- package/plugins/vocdoni-comments/hooks/hooks.json +28 -0
- package/plugins/vocdoni-comments/hooks/session-start.sh +45 -0
- package/plugins/vocdoni-contributing/.claude-plugin/plugin.json +3 -2
- package/plugins/vocdoni-contributing/hooks/hooks.json +14 -2
- package/plugins/vocdoni-contributing/hooks/session-start.sh +18 -6
- package/plugins/vocdoni-contributing/skills/contributing/SKILL.md +26 -2
- package/plugins/vocdoni-stripe/.claude-plugin/plugin.json +0 -22
- package/plugins/vocdoni-stripe/skills/stripe-subscription/SKILL.md +0 -276
- package/plugins/vocdoni-stripe/skills/stripe-subscription/references/backend-contract.md +0 -142
- package/plugins/vocdoni-stripe/skills/stripe-subscription/references/product-templates.md +0 -132
- package/plugins/vocdoni-stripe/skills/stripe-subscription/references/stripe-cli.md +0 -212
- package/plugins/vocdoni-stripe/skills/stripe-subscription/scripts/clone-product.sh +0 -247
- package/plugins/vocdoni-stripe/skills/stripe-subscription/scripts/stripe-json.sh +0 -223
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
"description": "Injects the vocdoni-contributing rules (issue tracking, stacked PRs for epics, PR/MR descriptions, issues, reviews, commits) into every session by reading the skill body from SKILL.md",
|
|
2
|
+
"description": "Injects the vocdoni-contributing rules (issue tracking, stacked PRs for epics, PR/MR descriptions, issues, reviews, review threads, commits) into every session and into every subagent except read-only and forked ones, by reading the skill body from SKILL.md",
|
|
3
3
|
"hooks": {
|
|
4
4
|
"SessionStart": [
|
|
5
5
|
{
|
|
6
6
|
"hooks": [
|
|
7
7
|
{
|
|
8
8
|
"type": "command",
|
|
9
|
-
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh\"",
|
|
9
|
+
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh\" SessionStart",
|
|
10
|
+
"timeout": 10
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"SubagentStart": [
|
|
16
|
+
{
|
|
17
|
+
"matcher": "^(?!(Explore|Plan|claude-code-guide|statusline-setup|fork)$)",
|
|
18
|
+
"hooks": [
|
|
19
|
+
{
|
|
20
|
+
"type": "command",
|
|
21
|
+
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh\" SubagentStart",
|
|
10
22
|
"timeout": 10
|
|
11
23
|
}
|
|
12
24
|
]
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# SessionStart hook for
|
|
2
|
+
# SessionStart and SubagentStart hook for vocdoni-contributing.
|
|
3
3
|
#
|
|
4
|
-
# Injects the contributing skill body (SKILL.md
|
|
5
|
-
# rules for tracking work in an issue, PR/MR descriptions, issues, reviews and commits apply even
|
|
6
|
-
#
|
|
4
|
+
# Injects the contributing skill body (SKILL.md, frontmatter dropped) into every session and subagent, so
|
|
5
|
+
# rules for tracking work in an issue, PR/MR descriptions, issues, reviews and commits apply even as one step
|
|
6
|
+
# of a task and the skill's description never matches. Reads the body from SKILL.md so there is one source of truth.
|
|
7
7
|
#
|
|
8
8
|
# Prints hookSpecificOutput JSON on stdout. Reads no input, writes nothing on error, never blocks, always exits 0.
|
|
9
9
|
# Plain bash 3.2 so it runs on stock macOS.
|
|
10
10
|
|
|
11
|
+
# Claude Code runs this for SessionStart and SubagentStart; the output must name the event it answers.
|
|
12
|
+
case "${1:-}" in
|
|
13
|
+
SubagentStart) event=SubagentStart ;;
|
|
14
|
+
*) event=SessionStart ;;
|
|
15
|
+
esac
|
|
16
|
+
|
|
11
17
|
script_dir=$(cd "$(dirname "$0")" 2>/dev/null && pwd)
|
|
12
18
|
|
|
13
19
|
skill=""
|
|
@@ -29,9 +35,15 @@ json_escape() {
|
|
|
29
35
|
printf '%s' "$1" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e "s/$tab/\\\\t/g" | awk '{ printf "%s%s", (NR > 1 ? "\\n" : ""), $0 }'
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
if [ "$event" = SubagentStart ]; then
|
|
39
|
+
msg="The vocdoni-contributing plugin is installed. Follow these rules for every commit message and anything you write to the git host. Finding or opening the tracking issue and opening the PR belong to the session that delegated to you: skip those steps unless your task asks for them.
|
|
40
|
+
|
|
41
|
+
$body"
|
|
42
|
+
else
|
|
43
|
+
msg="The vocdoni-contributing plugin is installed. Follow these rules whenever you start a change in a repository or write or post to the git host, even as one step of a larger task:
|
|
33
44
|
|
|
34
45
|
$body"
|
|
46
|
+
fi
|
|
35
47
|
|
|
36
|
-
printf '{"hookSpecificOutput":{"hookEventName":"
|
|
48
|
+
printf '{"hookSpecificOutput":{"hookEventName":"%s","additionalContext":"%s"}}\n' "$event" "$(json_escape "$msg")"
|
|
37
49
|
exit 0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: contributing
|
|
3
|
-
description: Use whenever starting work on a change in a repository, or writing or posting a pull request or merge request description, an issue, a code review, a review comment or a commit message, on GitHub, GitLab or any other git host, through gh, glab or the web, including as one step of a larger task, and when an epic issue needs several pull requests. Sets how to tie the work to an issue (find one, or open one before the PR), how to stack an epic's PRs on each other with gh stack instead of opening them all against the base branch, how to introduce yourself
|
|
3
|
+
description: Use whenever starting work on a change in a repository, or writing or posting a pull request or merge request description, an issue, a code review, a review comment or a commit message, or answering review comments on a pull request, on GitHub, GitLab or any other git host, through gh, glab or the web, including as one step of a larger task, and when an epic issue needs several pull requests. Sets how to tie the work to an issue (find one, or open one before the PR), how to stack an epic's PRs on each other with gh stack instead of opening them all against the base branch, how to introduce yourself and say whether the user asked for or reviewed the post, length limits and structure for PRs, issues and reviews, how to post a review, and how to reply to and resolve the review threads you address.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Contributing
|
|
@@ -9,7 +9,14 @@ These rules cover the issue that tracks your work and everything you write on th
|
|
|
9
9
|
|
|
10
10
|
## Introduce yourself
|
|
11
11
|
|
|
12
|
-
Start every PR description, issue, review and comment you post with one line saying which model you are and
|
|
12
|
+
Start every PR description, issue, review and comment you post with one line saying which model you are and how `{owner}` stands behind the post. `{owner}` is the login of the host CLI's user (`gh api user -q .login`, `glab api user | jq -r .username`), else `git config user.name`.
|
|
13
|
+
|
|
14
|
+
- The user asked for this post in their own words in this conversation, or approved its text: "This is {model} speaking on behalf of {owner}."
|
|
15
|
+
- Anything else: "This is {model}, working from {owner}'s account. {owner} has not asked for or reviewed this message."
|
|
16
|
+
|
|
17
|
+
Judge each post separately. When the user asks for a PR, only the PR is asked for: the tracking issue you open for it and your later replies to reviewers are not, so they take the second line. So does anything you post while the user is away (a loop, a scheduled or headless run). Showing the user the text before you post it makes it the first line. If you can't tell which applies, use the second line.
|
|
18
|
+
|
|
19
|
+
<important>Don't sign off at the end.</important>
|
|
13
20
|
|
|
14
21
|
Don't add a `Co-authored-by` trailer for yourself to commits. The person running you answers for the change.
|
|
15
22
|
|
|
@@ -48,3 +55,20 @@ Keep issues under ~15 lines of markdown too, code blocks included. Open with the
|
|
|
48
55
|
Each finding takes about three sentences: what's wrong, what it breaks, and the fix. Don't walk through every step of the reasoning or restate what the diff shows. Mark nits with "Nit:" and keep them shorter still. The review's summary body follows the same rule.
|
|
49
56
|
|
|
50
57
|
Post a review you were asked to publish as a review, not as a plain comment, and mark it "Approve" or "Request changes" depending on its outcome (on GitLab: approve, or leave the blocking threads unresolved). Write a bare `@name` only for a real login you mean to notify.
|
|
58
|
+
|
|
59
|
+
When you answer review comments on your own PR, close each thread you handled: reply in it with the fix (the commit, or one line on what changed) or with why you are not making the change, then resolve it. Resolve it either way, so the user doesn't have to resolve every thread by hand. Leave threads you didn't handle open, and never resolve threads on a PR you are reviewing. These thread replies skip the introduction line. On GitHub, resolving takes the GraphQL API:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
# unresolved threads on PR N, with their IDs
|
|
63
|
+
gh api graphql -F owner='{owner}' -F repo='{repo}' -F pr=N -f query='
|
|
64
|
+
query($owner:String!,$repo:String!,$pr:Int!){repository(owner:$owner,name:$repo){pullRequest(number:$pr){
|
|
65
|
+
reviewThreads(first:100){nodes{id isResolved path line comments(first:1){nodes{body}}}}}}}' \
|
|
66
|
+
--jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved | not)'
|
|
67
|
+
# reply in a thread, then resolve it
|
|
68
|
+
gh api graphql -F id=PRRT_xxx -f body='Fixed in abc1234.' -f query='
|
|
69
|
+
mutation($id:ID!,$body:String!){addPullRequestReviewThreadReply(input:{pullRequestReviewThreadId:$id,body:$body}){comment{id}}}'
|
|
70
|
+
gh api graphql -F id=PRRT_xxx -f query='
|
|
71
|
+
mutation($id:ID!){resolveReviewThread(input:{threadId:$id}){thread{isResolved}}}'
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
On GitLab, reply with `glab api -X POST "projects/:id/merge_requests/N/discussions/<discussion_id>/notes" -f body='...'`, then resolve with `glab api -X PUT "projects/:id/merge_requests/N/discussions/<discussion_id>?resolved=true"`.
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vocdoni-stripe",
|
|
3
|
-
"version": "0.1.1",
|
|
4
|
-
"description": "Stripe operations for the Vocdoni SaaS, run through the Stripe CLI (or a Stripe MCP server). Creates subscriptions for existing customers with the org-address metadata the backend needs, clones per-customer Custom / Integrator Starter plan products from the catalog templates, handles discounts and payment collection, and always confirms before writing. Ships an environment-guarding CLI wrapper, a product-cloning script and a verified reference of what the SaaS backend reads from Stripe.",
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "Vocdoni",
|
|
7
|
-
"url": "https://vocdoni.io"
|
|
8
|
-
},
|
|
9
|
-
"homepage": "https://github.com/vocdoni/skills",
|
|
10
|
-
"repository": "https://github.com/vocdoni/skills",
|
|
11
|
-
"license": "AGPL-3.0-or-later",
|
|
12
|
-
"keywords": [
|
|
13
|
-
"claude-code",
|
|
14
|
-
"skills",
|
|
15
|
-
"vocdoni",
|
|
16
|
-
"stripe",
|
|
17
|
-
"billing",
|
|
18
|
-
"subscriptions",
|
|
19
|
-
"saas",
|
|
20
|
-
"stripe-cli"
|
|
21
|
-
]
|
|
22
|
-
}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: stripe-subscription
|
|
3
|
-
description: Creates a Stripe subscription for an existing Vocdoni SaaS customer, including per-customer "Custom" and "Integrator Starter" plans cloned from template products, with the org-address metadata the backend needs, an optional discount, and a chosen payment-collection mode. Use this whenever the user wants to give an organization a plan, assign or create a subscription, make a subscription free or discounted, set up a custom or integrator plan for a client, or asks anything about creating subscriptions, coupons, or plan products in Stripe for Vocdoni, even if they only mention a customer email, a product name, or a 0x organization address.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Stripe subscription for a Vocdoni org
|
|
7
|
-
|
|
8
|
-
You are about to move real money settings on a live billing account. The
|
|
9
|
-
workflow below is shaped by mistakes that already happened once: the CLI
|
|
10
|
-
silently pointing at a sandbox instead of live, a subscription created for a
|
|
11
|
-
customer without a card (it dies `incomplete` after 23 hours), a discount
|
|
12
|
-
applied after creation so the first invoice had to be patched by hand, and a
|
|
13
|
-
coupon left open for anyone to reuse. Every step exists to make one of those
|
|
14
|
-
impossible.
|
|
15
|
-
|
|
16
|
-
Work through the phases in order. Never write to Stripe before the user has
|
|
17
|
-
confirmed the table in Phase 3.
|
|
18
|
-
|
|
19
|
-
## Phase 0: preflight
|
|
20
|
-
|
|
21
|
-
**Tooling.** You need `jq` (the scripts and every cookbook command parse
|
|
22
|
-
JSON with it) and one of:
|
|
23
|
-
|
|
24
|
-
- The Stripe CLI, installed and with a started session. Check with
|
|
25
|
-
`scripts/stripe-json.sh env` (without `STRIPE_ENV` it only reports the
|
|
26
|
-
account and mode; the environment is chosen in Phase 1). If it fails it prints what is missing and how
|
|
27
|
-
to fix it: install `jq`, install the CLI, `stripe login`, and
|
|
28
|
-
`stripe agent setup` to install the Stripe CLI agent skill. Install what
|
|
29
|
-
you can yourself (a package manager the user already uses is fine) and ask
|
|
30
|
-
the user for anything that needs their credentials or privileges. Do not
|
|
31
|
-
continue until it prints a mode.
|
|
32
|
-
- A connected Stripe MCP server (tools named `mcp__…stripe…`) with its skill.
|
|
33
|
-
The phases are the same; `references/stripe-cli.md` maps every CLI call to
|
|
34
|
-
the MCP equivalent and says which calls still need the CLI.
|
|
35
|
-
|
|
36
|
-
**Environment.** The environment is an input like any other, collected in
|
|
37
|
-
Phase 1 and shown in the confirmation table; do not infer it from what the CLI
|
|
38
|
-
happens to be pointing at. Once known, prefix every Stripe command with it and
|
|
39
|
-
with the account name `env` printed (`STRIPE_ENV=live STRIPE_ACCOUNT_NAME='…'
|
|
40
|
-
scripts/stripe-json.sh …`, same for `clone-product.sh`; the mode alone cannot
|
|
41
|
-
tell two live accounts apart):
|
|
42
|
-
agent shells usually do not keep an `export` between tool calls, and the
|
|
43
|
-
wrapper refuses to run without it rather than guess. Run every Stripe command
|
|
44
|
-
through `scripts/stripe-json.sh`, which reads the CLI's own banner to check
|
|
45
|
-
the mode and refuses on mismatch. If it reports a mismatch, compare against
|
|
46
|
-
the environment the user chose, not against whatever the error suggests. The CLI keeps one active account and a
|
|
47
|
-
`stripe switch` in another terminal changes it under you, so run
|
|
48
|
-
`scripts/stripe-json.sh env` again right before Phase 4. On mismatch tell the
|
|
49
|
-
user to run `! stripe switch` (it is interactive) and re-check.
|
|
50
|
-
|
|
51
|
-
**Sandbox is not isolated.** A sandbox account is wired to the dev and
|
|
52
|
-
staging backends through its webhook endpoints, so every write there changes
|
|
53
|
-
real org records in those backends. List them with
|
|
54
|
-
`webhook_endpoints list` and show the enabled URLs in the confirmation table.
|
|
55
|
-
When any is enabled, a subscription created for an org address moves that org
|
|
56
|
-
to the new plan in each of those backends at once, and canceling or deleting
|
|
57
|
-
it afterwards does not bring the previous plan back. Only use an org address
|
|
58
|
-
the user has confirmed is disposable in every listed backend, and do not
|
|
59
|
-
create "test" subscriptions to clean up later: there is no cleanup.
|
|
60
|
-
|
|
61
|
-
Read `references/stripe-cli.md` now for the command cookbook. Read
|
|
62
|
-
`references/backend-contract.md` if you need to know why a field matters.
|
|
63
|
-
|
|
64
|
-
## Phase 1: collect the minimum
|
|
65
|
-
|
|
66
|
-
Six things are required. Take what the user gave, then ask for the rest in a
|
|
67
|
-
single `AskUserQuestion` call (one question per missing item):
|
|
68
|
-
|
|
69
|
-
0. **Environment**: `live` or `sandbox`. Ask unless the user said it; offer
|
|
70
|
-
`live` first since that is what a real customer request means, but never
|
|
71
|
-
assume it silently. Whatever the answer, it is what `STRIPE_ENV` gets and
|
|
72
|
-
what the confirmation table shows.
|
|
73
|
-
1. **Customer**: email (or `cus_…` id). The customer must already exist.
|
|
74
|
-
2. **Org type**: integrator or regular. The new subscription replaces the
|
|
75
|
-
org's plan in the backend, and an integrator org is often on
|
|
76
|
-
`Integrator Free`, which has no Stripe subscription, so Stripe cannot tell
|
|
77
|
-
you. Take it from the user's wording ("integrator", "Integrator Free",
|
|
78
|
-
"managed orgs") or from an existing subscription on a product with
|
|
79
|
-
`integratorLimits.maxManagedOrgs > 0`; otherwise ask. Never guess regular.
|
|
80
|
-
3. **Product**: a catalog name (`Free`, `Starter`, `Professional`, `Custom`,
|
|
81
|
-
`Integrator Starter`, `Integrator Free`) or a `prod_…` id. `Custom` and
|
|
82
|
-
`Integrator Starter` are templates and go through Phase 2b. The product
|
|
83
|
-
keeps the org's type unless the user explicitly asks to change it: for an
|
|
84
|
-
integrator org, "upgrade", "custom plan" or no product at all means a copy
|
|
85
|
-
of `Integrator Starter`, never plain `Custom`; for a regular org, `Custom`.
|
|
86
|
-
A product of the other type is a type change: show it as such in the
|
|
87
|
-
Phase 3 table and only proceed if the user named that product.
|
|
88
|
-
4. **Billing interval**: `yearly` or `monthly` (or a `price_…` id). If the user
|
|
89
|
-
said nothing and the product's default price is yearly, propose yearly.
|
|
90
|
-
5. **Organization address**: `0x` + 40 hex chars. It becomes the subscription
|
|
91
|
-
metadata key `address`, the only thing linking the subscription to the org
|
|
92
|
-
in the backend. A missing or malformed value makes every webhook for that
|
|
93
|
-
subscription fail forever, so validate the shape before doing anything
|
|
94
|
-
else.
|
|
95
|
-
|
|
96
|
-
## Phase 2: resolve and validate (read-only)
|
|
97
|
-
|
|
98
|
-
- **Customer**: `customers list --email <email>`. Exactly one match, or stop
|
|
99
|
-
and report what you found. Note name, currency, `invoice_settings.default_payment_method`
|
|
100
|
-
and `payment_methods list --customer` (together they decide the collection
|
|
101
|
-
default: a card that is attached but not the customer's default is only
|
|
102
|
-
charged if you pass it as the subscription's `default_payment_method`).
|
|
103
|
-
A customer metadata `address` pointing to another org is not a blocker and
|
|
104
|
-
not a sign of the wrong customer (one customer may own several orgs'
|
|
105
|
-
subscriptions); note it in the Phase 3 table and leave it untouched.
|
|
106
|
-
- **Product and price**: search by name, then filter to the exact name because
|
|
107
|
-
search is a substring match and `Custom - someone@…` copies would otherwise
|
|
108
|
-
win. Then `prices list --product <id> --active` and pick the recurring price
|
|
109
|
-
for the chosen interval. Show amount, currency, nickname.
|
|
110
|
-
- **One org, one subscription**: list every non-canceled subscription
|
|
111
|
-
(active, trialing, past_due, unpaid, paused, incomplete), every page, and compare `metadata.address` case-insensitively
|
|
112
|
-
(see the cookbook; use the list, not search, because search lags by up to a
|
|
113
|
-
minute). If one exists,
|
|
114
|
-
stop and name it: the user should update or cancel that one instead.
|
|
115
|
-
- **Org type matches the product**: read the resolved product's
|
|
116
|
-
`integratorLimits`. An integrator org given a product without
|
|
117
|
-
`integratorLimits.maxManagedOrgs > 0` (plain `Custom`, `Starter`,
|
|
118
|
-
`Professional`) stops being an integrator, and a regular org given an
|
|
119
|
-
integrator product becomes one. If that does not match the Phase 1 type
|
|
120
|
-
and the user did not name the product explicitly, switch to the matching
|
|
121
|
-
template before going further.
|
|
122
|
-
- **Customer's other subscriptions**: warn, do not block.
|
|
123
|
-
- **Currency**: the price currency must match the customer's currency when the
|
|
124
|
-
customer already has one, or Stripe rejects the create.
|
|
125
|
-
|
|
126
|
-
## Phase 2b: template flow (Custom / Integrator Starter)
|
|
127
|
-
|
|
128
|
-
The backend reads plan limits from the product's metadata, so a customized
|
|
129
|
-
plan needs its own product. Read `references/product-templates.md` and:
|
|
130
|
-
|
|
131
|
-
1. Resolve the template by exact name and show its `organization`, `features`,
|
|
132
|
-
`votingTypes` (and `integratorLimits`) blocks as pretty JSON.
|
|
133
|
-
2. Ask what to change: per-block overrides (for example `2FAemail: 10000`), the
|
|
134
|
-
yearly/monthly amounts (custom plans are negotiated; default is the template
|
|
135
|
-
amount), a short client label for names, and the org email (defaults to the
|
|
136
|
-
customer email). Show a before/after of every block you change.
|
|
137
|
-
3. Run `scripts/clone-product.sh … --dry-run` and include its output in the
|
|
138
|
-
Phase 3 table so the user sees the exact product and prices to be created.
|
|
139
|
-
4. After confirmation, run it without `--dry-run`. It writes the copy with
|
|
140
|
-
`visibility=private`, `orgAddress`, `orgEmail`, `copiedFrom`, `copiedAt`,
|
|
141
|
-
creates one price per interval the template has (yearly and/or monthly),
|
|
142
|
-
and never sets a default price.
|
|
143
|
-
5. Read the product back and check: all metadata blocks parse as JSON, visibility
|
|
144
|
-
is private, one active recurring price per template interval, and for integrator copies
|
|
145
|
-
`integratorLimits.maxManagedOrgs > 0`. Then continue with its price.
|
|
146
|
-
|
|
147
|
-
## Phase 3: confirmation table
|
|
148
|
-
|
|
149
|
-
Render one table with everything chosen, then everything optional that is
|
|
150
|
-
still at its default, and ask a single `AskUserQuestion`: "Create it as shown?"
|
|
151
|
-
with options `Yes`, `Change something`. On `Change something`, collect the
|
|
152
|
-
change, re-render, ask again. Never proceed on silence or an implicit yes.
|
|
153
|
-
|
|
154
|
-
```
|
|
155
|
-
| Setting | Value |
|
|
156
|
-
|--------------------|---------------------------------------------------|
|
|
157
|
-
| Environment | live · Account Name |
|
|
158
|
-
| Backends notified | every enabled webhook endpoint URL |
|
|
159
|
-
| Customer | cus_xxx · Client Name · client@example.org |
|
|
160
|
-
| Product | prod_xxx · Professional |
|
|
161
|
-
| Org plan change | Integrator Free → Professional (not integrator) |
|
|
162
|
-
| Price | price_xxx · yearly · 1 890,00 EUR |
|
|
163
|
-
| metadata.address | 0x0000000000000000000000000000000000000000 |
|
|
164
|
-
| Customer address | 0x… (another org, left untouched) (or: empty) |
|
|
165
|
-
| Org billing email | becomes client@example.org (the customer email) |
|
|
166
|
-
| --- not defined (defaults) --- |
|
|
167
|
-
| Collection | send_invoice, due in 30 days (no card on file) |
|
|
168
|
-
| Discount | none |
|
|
169
|
-
| Trial | none |
|
|
170
|
-
| Start / anchor | now |
|
|
171
|
-
| Scheduled cancel | none |
|
|
172
|
-
| Description / meta | none |
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
What each optional row means and its alternatives:
|
|
176
|
-
|
|
177
|
-
- **Collection**. Default `send_invoice` with `days_until_due=30` when the
|
|
178
|
-
customer has no default payment method, else `charge_automatically`. If
|
|
179
|
-
the customer has saved payment methods but none is the default, ask which
|
|
180
|
-
one to charge and pass it as `default_payment_method`; without it Stripe
|
|
181
|
-
has nothing to charge and the subscription is left `incomplete`.
|
|
182
|
-
Alternatives: the other one, or a **checkout link** (a hosted Checkout
|
|
183
|
-
Session the customer pays; Stripe then creates the subscription itself, so
|
|
184
|
-
Phase 5 verifies the session instead). `charge_automatically` with no card
|
|
185
|
-
needs `payment_behavior=default_incomplete` and the user must know the
|
|
186
|
-
subscription expires in 23 hours unless the invoice gets paid.
|
|
187
|
-
- **Discount**. Only when the user asks for one. Before creating anything,
|
|
188
|
-
look for an existing fit: `coupons list` (valid, same percent/amount and
|
|
189
|
-
duration, redemptions left) and, if the user named a code,
|
|
190
|
-
`promotion_codes list --active`. Show matches in a small table and let the
|
|
191
|
-
user pick one or "create new". Otherwise create a single-use coupon
|
|
192
|
-
(`max_redemptions=1`, name tied to the client and reason). Either way it is
|
|
193
|
-
passed on the create call through `discounts[0][coupon]` so the first invoice
|
|
194
|
-
is already discounted; there is nothing to patch afterwards and nothing to
|
|
195
|
-
delete later. If the user does not want a discount, skip the lookup.
|
|
196
|
-
- **Trial**: `trial_period_days` or `trial_end`. If the chosen price carries
|
|
197
|
-
`freeTrialDays` metadata (copied onto a cloned price from its template),
|
|
198
|
-
that metadata alone does not create a Stripe trial — it is read by other
|
|
199
|
-
parts of the Vocdoni stack, not by `subscriptions create`. Ask the user
|
|
200
|
-
whether this subscription should also get that many days as a real Stripe
|
|
201
|
-
trial, or the customer is billed immediately.
|
|
202
|
-
- **Start / anchor**: `backdate_start_date`, `billing_cycle_anchor`.
|
|
203
|
-
- **Scheduled cancel**: `cancel_at` or `cancel_at_period_end`.
|
|
204
|
-
- **Description / extra metadata**: `description`, extra `metadata[...]`.
|
|
205
|
-
Never add customer metadata; the backend writes the customer's `address`
|
|
206
|
-
itself when it is empty and leaves an existing one alone.
|
|
207
|
-
|
|
208
|
-
## Phase 4: execute
|
|
209
|
-
|
|
210
|
-
1. `scripts/stripe-json.sh env` again. Stop on mismatch.
|
|
211
|
-
2. Template flow: `clone-product.sh` for real, then the read-back checks.
|
|
212
|
-
3. Discount: create the coupon now if a new one was chosen; capture its id.
|
|
213
|
-
4. `subscriptions create` with every chosen flag in one call (or
|
|
214
|
-
`checkout sessions create` for the link mode). See the cookbook for the
|
|
215
|
-
exact flags.
|
|
216
|
-
5. `send_invoice`: finalize the first invoice right away
|
|
217
|
-
(`invoices finalize_invoice`), but only if the create response's
|
|
218
|
-
`latest_invoice` exists and is still `draft`. A trial's zero invoice is
|
|
219
|
-
already `paid`, and a future `billing_cycle_anchor` may leave no invoice
|
|
220
|
-
at all; finalizing those fails after the subscription already exists, so
|
|
221
|
-
skip this step instead. A zero-total invoice becomes `paid` on the
|
|
222
|
-
spot; a real one gets a `hosted_invoice_url`. Finalizing by hand does not
|
|
223
|
-
email it: run `invoices send_invoice` too if the customer should get
|
|
224
|
-
Stripe's email. `finalize_invoice` and `send_invoice` each return a
|
|
225
|
-
different token in that URL for the same invoice; hand the customer the
|
|
226
|
-
one from whichever call you made last (or from the Phase 5 read-back),
|
|
227
|
-
not the finalize-time one if you also sent it.
|
|
228
|
-
|
|
229
|
-
Destructive CLI commands (`delete`, `delete_*`, `cancel`, `void_invoice`,
|
|
230
|
-
`mark_uncollectible`, `detach`) can prompt interactively and hang inside an
|
|
231
|
-
agent; the wrapper refuses them without `--confirm`, so always pass it.
|
|
232
|
-
|
|
233
|
-
## Phase 5: verify and report
|
|
234
|
-
|
|
235
|
-
Re-read from Stripe; never report from the create response.
|
|
236
|
-
`subscriptions retrieve <id> -d expand[0]=discounts -d expand[1]=latest_invoice`
|
|
237
|
-
(plus `coupons retrieve` for the discount row, since the discount only
|
|
238
|
-
carries the coupon id, and `products retrieve` and `prices list` for a cloned
|
|
239
|
-
product) and print:
|
|
240
|
-
|
|
241
|
-
```
|
|
242
|
-
| Item | Value |
|
|
243
|
-
|-------------------|---------------------------------------------------------|
|
|
244
|
-
| Subscription | sub_xxx · active |
|
|
245
|
-
| Customer | cus_xxx · Client Name · client@example.org |
|
|
246
|
-
| Product | prod_xxx · Professional (or: copy of Custom, private) |
|
|
247
|
-
| Price | price_xxx · yearly · 1 890,00 EUR |
|
|
248
|
-
| metadata.address | 0x0000000000000000000000000000000000000000 |
|
|
249
|
-
| Discount | coupon_xxx · 100% · forever · redeemed 1/1 (or none) |
|
|
250
|
-
| First invoice | in_xxx · paid · total 0,00 EUR · hosted URL |
|
|
251
|
-
| Collection | send_invoice · due in 30 days |
|
|
252
|
-
| Current period | until 2027-01-01 |
|
|
253
|
-
| Environment | live |
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
Follow with two or three sentences: what happens next (invoice emailed if you
|
|
257
|
-
sent it, link to hand over, backend picks a cloned product up on the
|
|
258
|
-
`product.updated` webhook fired by its activation, or at the next restart), and anything left at a default the user should know about
|
|
259
|
-
(for example, a free subscription still emits zero-value invoices in revenue
|
|
260
|
-
reports).
|
|
261
|
-
|
|
262
|
-
## When to stop instead of continuing
|
|
263
|
-
|
|
264
|
-
- The environment check fails or flips between phases.
|
|
265
|
-
- The customer is missing or ambiguous, the product name matches several
|
|
266
|
-
active products, or the address is malformed.
|
|
267
|
-
- Another active subscription already carries that address.
|
|
268
|
-
- The environment is sandbox, it has enabled webhook endpoints, and the user
|
|
269
|
-
has not confirmed the org address is disposable in those backends.
|
|
270
|
-
- The org is an integrator and the chosen product is not, and the user has
|
|
271
|
-
not confirmed the downgrade.
|
|
272
|
-
- The user asked for something this skill does not do: changing an existing
|
|
273
|
-
subscription, refunds, cancellations. Say so and offer the CLI command.
|
|
274
|
-
|
|
275
|
-
Related: [[stripe-best-practices]] for general Stripe API choices,
|
|
276
|
-
[[stripe-docs]] to look up a parameter this skill does not cover.
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# What the SaaS backend reads from Stripe
|
|
2
|
-
|
|
3
|
-
Verified against `saas-backend` (`stripe/service.go`, `stripe/webhook.go`,
|
|
4
|
-
`stripe/client.go`, `db/plans.go`, `subscriptions/subscriptions.go`) in
|
|
5
|
-
September 2026. Re-check the line references if the backend has moved on.
|
|
6
|
-
|
|
7
|
-
## Products are plans
|
|
8
|
-
|
|
9
|
-
Stripe is the single source of truth for plans; Mongo `plans` is a cache.
|
|
10
|
-
|
|
11
|
-
| Product metadata key | Required | Parsed as | Effect |
|
|
12
|
-
| -------------------- | ------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
13
|
-
| `organization` | yes (marker) | JSON object | plan limits: `teamMembers`, `subOrgs`, `maxProcesses`, `maxCensus`, `maxVotes`, `maxDaysDuration`, `customURL`, `drafts`, `customPlan` |
|
|
14
|
-
| `votingTypes` | yes (marker) | JSON object | `single`, `multiple`, `approval`, `cumulative`, `ranked`, `weighted` |
|
|
15
|
-
| `features` | yes (marker) | JSON object | `anonymous`, `overwrite`, `liveResults`, `2FAsms`, `2FAemail`, `personalization`, `emailReminder`, `whiteLabel`, `liveStreaming`, `phoneSupport` |
|
|
16
|
-
| `integratorLimits` | no | JSON object | `maxManagedOrgs`; the plan is an integrator plan only when it is `> 0` |
|
|
17
|
-
| `visibility` | no | string | exactly `private` hides the plan from `GET /plans`. Nothing else: a private plan is still fetchable by id and usable at checkout |
|
|
18
|
-
|
|
19
|
-
- A product missing any of the three marker keys is silently not a plan
|
|
20
|
-
(`service.go` `planProductMarkerKeys`, `isPlanProduct`).
|
|
21
|
-
- A marker present but not valid JSON makes the product skip with a warning.
|
|
22
|
-
- Only **active** products are listed (`client.go` `ListProducts`).
|
|
23
|
-
- `orgAddress`, `orgEmail`, `copiedFrom`, `copiedAt` (and the older
|
|
24
|
-
`restoredFrom` / `restoredAt` from a one-off migration) are **not read**.
|
|
25
|
-
They exist so a human can tell which customer a copy belongs to and where it
|
|
26
|
-
came from. Keep writing them.
|
|
27
|
-
|
|
28
|
-
## Prices
|
|
29
|
-
|
|
30
|
-
`GetProductPrices` lists **active** prices of the product. In
|
|
31
|
-
`processProductToPlan`:
|
|
32
|
-
|
|
33
|
-
- recurring interval `year` becomes the yearly price and amount, `month` the
|
|
34
|
-
monthly ones; other intervals and one-time prices are ignored;
|
|
35
|
-
- if several prices share an interval the last one listed wins, so keep one
|
|
36
|
-
active price per interval on a plan product;
|
|
37
|
-
- yearly price metadata `freeTrialDays` (integer) is honoured;
|
|
38
|
-
- the catalog **default plan** marker is `Default=true` on the metadata of the
|
|
39
|
-
product's `default_price`. Never set a default price on a per-customer copy.
|
|
40
|
-
|
|
41
|
-
Lookup keys are not used: the "lookup key" in the checkout endpoint is the
|
|
42
|
-
product id.
|
|
43
|
-
|
|
44
|
-
## Subscriptions
|
|
45
|
-
|
|
46
|
-
The only subscription metadata key read is **`address`**
|
|
47
|
-
(`webhook.go` `parseSubscriptionFromEvent`). It is parsed with
|
|
48
|
-
`common.HexToAddress`, so matching is case-insensitive and the `0x` prefix is
|
|
49
|
-
optional; garbage silently becomes the zero address.
|
|
50
|
-
|
|
51
|
-
On `customer.subscription.*` events:
|
|
52
|
-
|
|
53
|
-
- missing/zero address: error `subscription missing address metadata`;
|
|
54
|
-
- address with no organization: error `organization … not found`;
|
|
55
|
-
- product not in the plan cache: error `plan with Stripe ID … not found`.
|
|
56
|
-
|
|
57
|
-
Every error returns HTTP 500 to Stripe, the event is not marked processed, and
|
|
58
|
-
Stripe retries it for days. So a wrong address is not "no-op", it is a
|
|
59
|
-
permanently failing webhook.
|
|
60
|
-
|
|
61
|
-
On success the org gets `PlanID`, `StripeSubscriptionID`, `BillingPeriod`,
|
|
62
|
-
`StartDate`, `RenewalDate`, `Active` (only when status is `active`) and
|
|
63
|
-
`Email` (the Stripe customer email).
|
|
64
|
-
|
|
65
|
-
The previous plan is overwritten, not stacked or remembered. That includes a
|
|
66
|
-
plan the org holds with no Stripe subscription behind it (the free integrator
|
|
67
|
-
plan assigned at `integrator: true` creation), and a later cancel or delete of
|
|
68
|
-
the new subscription does not restore it. Every endpoint subscribed to the
|
|
69
|
-
account applies this, so a sandbox subscription rewrites the org in dev and
|
|
70
|
-
staging alike.
|
|
71
|
-
|
|
72
|
-
## Customers
|
|
73
|
-
|
|
74
|
-
The subscription metadata `address` is the only link between a subscription
|
|
75
|
-
and an org. The customer's metadata `address` is never read to route a
|
|
76
|
-
subscription; one Stripe customer may own subscriptions for several orgs.
|
|
77
|
-
|
|
78
|
-
After saving the org, the handler stamps the **customer** metadata `address`
|
|
79
|
-
with the org address, but only when it is empty. What happens when it is
|
|
80
|
-
already set depends on the backend version:
|
|
81
|
-
|
|
82
|
-
- `main` (since dd58581, #704; not in a release tag yet): it logs
|
|
83
|
-
"customer metadata address mismatch" if the value differs and carries on.
|
|
84
|
-
The webhook succeeds and the existing value is left untouched.
|
|
85
|
-
- v3.1.2 and older: it returns an error when the customer has any `address`,
|
|
86
|
-
even the same one. The org was already saved, so the data is correct, but
|
|
87
|
-
Stripe gets a 500 and retries the event. Noisy in webhook logs, harmless
|
|
88
|
-
for data; mention it if the user wonders about failing webhooks.
|
|
89
|
-
|
|
90
|
-
Either way, do not set customer metadata `address` by hand, before or after
|
|
91
|
-
creating the subscription, and do not treat an existing value pointing to
|
|
92
|
-
another org as a sign of the wrong customer.
|
|
93
|
-
|
|
94
|
-
The org's subscription `Email` is always overwritten with the Stripe customer
|
|
95
|
-
email, so a customer email that differs from the org manager's replaces it.
|
|
96
|
-
|
|
97
|
-
## How a new product reaches the backend
|
|
98
|
-
|
|
99
|
-
- On startup the backend syncs every active plan product (`InitializeStripeService`);
|
|
100
|
-
a failure is logged, not fatal.
|
|
101
|
-
- At runtime it reacts to `product.created`, `product.updated`,
|
|
102
|
-
`product.deleted` webhooks (`handleProductUpsert`, `handleProductDelete`).
|
|
103
|
-
It re-fetches the product to expand `default_price`. A product that goes
|
|
104
|
-
inactive or loses a marker is removed from the cache.
|
|
105
|
-
- `price.*` events are **not** handled. Create prices before the last product
|
|
106
|
-
update, or touch the product afterwards (`clone-product.sh` does this).
|
|
107
|
-
|
|
108
|
-
So a product created by hand shows up immediately only if the live webhook
|
|
109
|
-
endpoint subscribes to `product.*`; otherwise at the next backend restart.
|
|
110
|
-
|
|
111
|
-
## Integrator plans
|
|
112
|
-
|
|
113
|
-
`Subscriptions.IsIntegrator` is true when the org has its own
|
|
114
|
-
`IntegratorLimits.MaxManagedOrgs > 0`, or when its subscription is active and
|
|
115
|
-
the plan's `IntegratorLimits.MaxManagedOrgs > 0`. Name is irrelevant.
|
|
116
|
-
|
|
117
|
-
**The free integrator plan is found structurally**, nothing else:
|
|
118
|
-
`db/plans.go` `FreeIntegratorPlan` does a `FindOne` on
|
|
119
|
-
`integratorLimits.maxManagedOrgs > 0 AND monthlyPrice == 0 AND yearlyPrice == 0`.
|
|
120
|
-
No env var, config key or product id is involved at runtime (the
|
|
121
|
-
`STRIPE_FREE_INTEGRATOR_PRODUCT_ID` variable and the hardcoded id in
|
|
122
|
-
migration 0014 only rewrite old integer plan ids once, at migration time).
|
|
123
|
-
`Integrator Starter` and `Custom` are not referenced anywhere in code either;
|
|
124
|
-
every plan is generic.
|
|
125
|
-
|
|
126
|
-
Consequences:
|
|
127
|
-
|
|
128
|
-
- An org created with `integrator: true` (`POST /organizations`) fails with
|
|
129
|
-
`404` code `40023` "subscription plan not found: free integrator plan not
|
|
130
|
-
available" when no such plan exists, and nothing is persisted. Creating an
|
|
131
|
-
active product with the three markers, `integratorLimits.maxManagedOrgs > 0`
|
|
132
|
-
and either no recurring prices or zero-amount ones fixes it with no code
|
|
133
|
-
change; `visibility=private` keeps it out of the catalog.
|
|
134
|
-
- `FindOne` has no ordering, so two matching plans make the choice random.
|
|
135
|
-
Never put `integratorLimits` on the default `Free` plan, and never let an
|
|
136
|
-
integrator product be active while it still has no prices (a paid
|
|
137
|
-
`Integrator Starter` copy with zero prices matches the selector).
|
|
138
|
-
`clone-product.sh` creates copies inactive and activates them after their
|
|
139
|
-
prices exist for this reason.
|
|
140
|
-
- `DefaultPlan()` (the `Default=true` default-price marker on the `Free`
|
|
141
|
-
product) is checked before the integrator branch for every org creation,
|
|
142
|
-
so a broken default plan fails all signups with `400` code `40022`.
|