agentleFS
buildpad-aibuildpad-ai/skills/add-customer-onboarding/SKILL.md

add-customer-onboarding

Skill1 starsChanged 47 days agoMITView on GitHub

Let strangers sign up, verify their email, create their own customer and land in it, on an Engine project with Customer_Tenants and Self-onboarding on.

  • Reads credentials

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. About 0 are common, 9 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

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

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

    Read .buildpad/project.json at the project root.

    line 13
  2. Very specific:

    If a folder named supabase at the project root holds a file named config.toml, or holds a folder named migrations that holds a file whose …

    line 18
  3. Very specific:

    Read .buildpad/project.json.

    line 63
  4. Distinctive:

    Do not open an environment file to find it, and do not call a tool that returns project credentials.

    line 74
  5. Very specific:

    Write .buildpad/onboarding-answer.json exactly as shown, UTF-8, with a trailing newline.

    line 77
  6. Very specific:

    If the app has no lib/auth/tenants.ts with settleTenant, build the sign-in of the mode customer-tenants first, with the add-multitenancy …

    line 92
  7. Very specific:

    Look for a server function that sends one message (sendMail, sendEmail, a provider SDK client under lib/).

    line 99
  8. Distinctive:

    Not found: ask: "Which mail provider sends this app's email (for example Amazon SES, Resend, Postmark, SendGrid, or an SMTP server)?

    line 103
  9. Distinctive:

    Found: use the app's existing captcha.

    line 113
  10. Distinctive:

    Not found: ask which one the developer uses (for example Cloudflare Turnstile, hCaptcha, reCAPTCHA).

    line 114
  11. Distinctive:

    No captcha: stop with "The sign-up page needs a bot check.

    line 118
  12. Distinctive:

    Never open an environment file to check that it is set.

    line 135
  13. Very specific:

    If the repository has an amplify.yml whose build commands lack BUILDPAD_ONBOARDING_KEY, add the Platform's exact line before the build …

    line 139
  14. Very specific:

    Add one line of the same form for each other server-only variable the flow reads: the mail provider's credentials, the bot check's secret …

    line 147
  15. Distinctive:

    No customer can be created until the project has a published Release.

    line 158
  16. Distinctive:

    Read neither fact. The Refusals table maps the Engine's answers when either is missing.

    line 167
  17. Distinctive:

    Ask the developer for the app's name as people see it.

    line 172

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill 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
SKILL.md

Add Customer Onboarding

<!-- backend-gate:begin v1 -->

Establish the backend first. A Buildpad project's backend is either the Buildpad Engine or Supabase, and some parts of this file hold for one of them only. Before you act on anything in this file, find the backend with these steps, in order, and stop at the first step that answers:

  1. Read .buildpad/project.json at the project root. If it is JSON and its field backend is "engine" or "supabase", that is the backend. If .buildpad/backend-answer.json names the other backend, tell the developer the two files disagree, and follow .buildpad/project.json.
  2. Otherwise read .buildpad/backend-answer.json in the same way; if its backend is "engine" or "supabase", that is the backend.
  3. If a folder named supabase at the project root holds a file named config.toml, or holds a folder named migrations that holds a file whose name ends in .sql, the backend is Supabase.
  4. Otherwise ask the developer once: "Is this project's backend the Buildpad Engine or Supabase?" Write the answer to .buildpad/backend-answer.json as {"buildpadBackendAnswer": 1, "backend": "engine"} or {"buildpadBackendAnswer": 1, "backend": "supabase"}, and ask the developer to commit that file. Do not add it to .gitignore. Never write .buildpad/project.json.

To find the backend, do not open an environment file (.env, .env.*) or an MCP configuration file, and do not call a tool that returns project credentials.

Then follow only the parts for that backend. A part starts at a line that holds only a comment whose text is buildpad + -backend: engine or buildpad + -backend: supabase, and ends at the next line that holds only a comment whose text is /buildpad + -backend. A comment that merely mentions a backend is not a part. A file whose first line, after any front matter, holds only a comment whose text is buildpad + -backend-file: engine (or supabase) holds for that backend only, and so does every file in a folder named engine-only or supabase-only. Skip the other backend's parts and copy no code from them; everything else holds for both. On an Engine project, when this file says that something is not available, tell the developer so and stop: do not build a substitute.

<!-- backend-gate:end -->

On a Supabase project. Customers that sign themselves up need a Buildpad Engine project with Customer tenants. Tell the developer so and stop.

<!-- buildpad-backend: engine -->

Step 1. The backend

The backend is the Buildpad Engine (the procedure above). Go on to step 2.

On an Engine project with Customer_Tenants each customer of the application is a tenant of its own, and the project's tenant is the Blueprint every customer is copied from. Establish the tenancy mode as the add-multitenancy skill says: from the field tenancy of .buildpad/project.json, else from .buildpad/tenancy-answer.json. In the mode customer-tenants that skill's guide engine-customer-tenants replaces what ES-3, ES-4, ES-5, ES-7 and ES-9 say about the project's tenant; in the mode scope they hold as written.

Step 2. The tenancy mode

Establish the tenancy mode with the add-multitenancy skill's Tenancy check.

In the mode scope:

On an Engine project in the mode scope a workspace that a person creates for themselves, as a scope node they own in the project's one tenant, is not available: no route lets a person who is not an administrator create a scope node or give roles at one. Tell the developer so and stop: build no substitute, and never give the application an administrator's credential to create one. Customers that sign themselves up, each a tenant of its own, are available in the mode customer-tenants, with the add-customer-onboarding skill.

In the mode customer-tenants, go on to step 3.

Step 3. Whether customers may sign themselves up

Establish whether customers may sign themselves up. Find it with these steps, in order, and stop at the first step that answers:

  1. Read .buildpad/project.json. If its field selfOnboarding is true or false, that is the answer. If .buildpad/onboarding-answer.json says otherwise, tell the developer the two files disagree and follow .buildpad/project.json: a kit downloaded before sign-up was turned on says false, and the developer downloads the kit again or sets the field.
  2. Otherwise read .buildpad/onboarding-answer.json in the same way.
  3. Otherwise ask the developer once: "Has a project Admin turned on customer sign-up (Self-onboarding) for this project on the Buildpad platform's Customers page?" Write the answer to .buildpad/onboarding-answer.json as {"buildpadOnboardingAnswer": 1, "selfOnboarding": true} or {"buildpadOnboardingAnswer": 1, "selfOnboarding": false}, and ask the developer to commit that file. Never write .buildpad/project.json.

Do not open an environment file to find it, and do not call a tool that returns project credentials.

A file that is not JSON, or whose selfOnboarding is missing or not a boolean, gives no answer. Write .buildpad/onboarding-answer.json exactly as shown, UTF-8, with a trailing newline.

On an Engine project with Customer_Tenants customers sign themselves up only while the project's Self_Onboarding is on, which selfOnboarding in .buildpad/project.json says. While it is off, tell the developer that a project Admin turns it on from the Platform's Customers page, and stop. While it is on, build it with the add-customer-onboarding skill: the application's own server routes call the Engine's sign-up, verification and customer routes with BUILDPAD_ONBOARDING_KEY, read on the server only and never sent to a browser. Never put the host administrator's credential or a call to /api/tenants in the application.

The answer false stops here, as the paragraph above says. A project Admin can turn sign-up on only once a host administrator has turned on the premium flag Customer self-onboarding for the project. With the answer true, go on with steps 4 to 11.

Self-onboarding is Development's only. Where the project also has customers in Production, a Platform member creates each of them on the Customers page, and Production's application offers no sign-up: the Platform sets the key to off on the production branch (step 7). The same code serves both, so build the flow once.

Step 4. Sign-in comes first

If the app has no lib/auth/tenants.ts with settleTenant, build the sign-in of the mode customer-tenants first, with the add-multitenancy skill's guide engine-customer-tenants (section 5), then come back. This flow changes two things in that sign-in (the reference file, section 8).

Step 5. Mail_Sender

Look for a server function that sends one message (sendMail, sendEmail, a provider SDK client under lib/).

  • Found: wrap it as sendMail({to, subject, text, html}) in lib/mail/send.ts.
  • Not found: ask: "Which mail provider sends this app's email (for example Amazon SES, Resend, Postmark, SendGrid, or an SMTP server)? It needs a verified sending domain, and its credentials (an API key, or the SMTP host, port, user and password) set in the app's server environment." With an answer, write lib/mail/send.ts for that provider with import "server-only", reading its credentials from server variables the developer names.
  • No provider: say "Verification mail needs a mail provider; this flow cannot be built without one" and stop.

Step 6. Bot check

  • Found: use the app's existing captcha.
  • Not found: ask which one the developer uses (for example Cloudflare Turnstile, hCaptcha, reCAPTCHA). Then write lib/onboarding/human-check.ts (import "server-only") with verifyHuman(token, address): Promise<boolean> against that vendor's verify endpoint. Its secret goes in a server variable; its public site key may carry NEXT_PUBLIC_.
  • No captcha: stop with "The sign-up page needs a bot check; without one a script spends the project's sign-up budget and your mail provider's reputation."

Step 7. The key

The Buildpad platform sets BUILDPAD_ONBOARDING_KEY in the app's hosting when a project Admin turns sign-up on, or shows it once on the Customers page for another host. It is a server variable: never give it a NEXT_PUBLIC_ prefix and never read it in a client component.

The value off, in any case, means no key, as an unset or empty value does. The Platform sets it on the production branch, because Amplify drops an empty value. With no key the app offers no sign-up: the sign-in page shows no link to it, its pages are not found, and its routes answer 404 before anything else (the reference file, sections 2 and 10).

The Platform manages this variable, and BUILDPAD_SIGNUP_MAIL beside it: never set, change or remove either with amplify_set_env_vars, which refuses them.

Never open an environment file to check that it is set.

Step 8. amplify.yml

If the repository has an amplify.yml whose build commands lack BUILDPAD_ONBOARDING_KEY, add the Platform's exact line before the build command:

        # Self-onboarding: the app's server reads the onboarding key at run time. Server only; never NEXT_PUBLIC_.
        - '[ -z "$BUILDPAD_ONBOARDING_KEY" ] || echo "BUILDPAD_ONBOARDING_KEY=$BUILDPAD_ONBOARDING_KEY" >> .env.production'

Add one line of the same form for each other server-only variable the flow reads: the mail provider's credentials, the bot check's secret and HOST_ORIGIN (the reference file, section 10, lists them). Tell the developer to set those variables, and the bot check's public site key, on the Amplify app before the next deployment (the amplify-env-vars skill). The app reads them only after that deployment. On another host, tell the developer to set each there, the secrets as server-only variables. amplify.yml is not an environment file, so you may open it. Leave a BUILDPAD_SIGNUP_MAIL line as it is: it belongs to mail the Engine sends, which this flow does not use.

Step 9. The Release and the Engine version

No customer can be created until the project has a published Release; the Engine answers 409 until then. Turning sign-up on publishes Release 1, and from then on every new customer is created from the latest published Release, not from the Blueprint as it is. A change made in the Blueprint after that reaches no customer until a later Release is published, and the Platform offers later Releases only once Releases are available. Tell the developer so, and that the structure new customers need is built in the Blueprint before sign-up is turned on. Sign-up also needs the Engine release the Platform names on the Customers page; the Platform turns sign-up on only for a project that runs it.

Read neither fact. The Refusals table maps the Engine's answers when either is missing.

Step 10. Build

Ask the developer for the app's name as people see it; the pages and the mail use it.

Build the flow as the reference file says: the module that holds the key, the client address, the four routes, the three pages, and the four changes to the sign-in of step 4 (the login route, the sign-in page, settleTenant and the middleware). Build the pages' forms with the app's own form components, as the project's rules require; the reference shows plain elements only to keep the logic visible.

Step 11. Review

Review against the security-and-hardening skill's checks. For this flow they are:

  • BUILDPAD_ONBOARDING_KEY is read only in one server-only module (lib/onboarding/engine.ts), never with a NEXT_PUBLIC_ prefix and never in a client component; no client component imports anything under lib/onboarding/.
  • The sign-up route checks the bot-check token before it calls the Engine.
  • The sign-up page shows the same text for a new and an existing address.

Refusals

Keyed by the Engine's status and code. The person-facing text never repeats the Engine's message.

RouteEngine answerCauseThe page saysNext
any401 TOKEN_INVALIDThe key is missing, unknown or revoked (on the create route it may also be an expired session: the route refreshes the session once and retries before treating it as the key)"Sign-up is not available right now."Log onboarding.key_invalid for the developer; no retry
any403 FORBIDDEN on sign-up, resend or verifySign-ups are turned off (Stop sign-ups or turned off)"Sign-ups are closed right now."No retry
any404The project's Engine is older than the release that serves sign-up"Sign-up is not available right now."Log onboarding.engine_too_old; the developer asks the project Admin
any429 REQUESTS_EXCEEDEDA budget: per key, per address, resend per person, or verify failures"Too many attempts. Try again in N minutes." (from Retry-After)After Retry-After
signup, resend400 INVALID_PAYLOADA malformed address or a password over 72 bytes"Enter a valid email address." / "Use a shorter password."The person corrects it
verify400 INVALID_TOKENThe code is unknown, used or expired"This link has expired or was already used."Resend
loginGoTrue email_not_confirmedNot yet verified"Confirm your email first."Resend
customers401 UNAUTHENTICATEDNo session(redirect)Sign in
customers403 FORBIDDENSign-ups are off (or, rarely, the person is not verified)"Creating companies is closed right now."No retry
customers403 QUOTA_EXCEEDEDThe project's customer limit is reached"Sign-ups are full right now. Contact <app>'s team."No retry
customers409 CONFLICT, message MsgOnboardingNoReleaseNo published Release yet"Companies cannot be created yet. Try again later."Log onboarding.no_release
customers409 CONFLICT, message MsgOnboardingPerIdentityThe person's company limit (per_identity), or a same-id request that raced the first"You have reached the number of companies you can create."The route first looks for its own id among the person's tenants and lands there when it is found; otherwise no retry
customers409 CONFLICT, message MsgOnboardingIDTakenThe id belongs to another tenant(never seen by a person: the form makes a new id and resubmits once)New id, once
customers503 SERVICE_UNAVAILABLEThe template-copy lock's deadline"Creating your company is taking longer than usual…"Same id: 2 s (route), 5 s, 10 s (form)
any(none: the app's own setup; 404)No key in the running app: BUILDPAD_ONBOARDING_KEY is unset, empty or off (Production's branch)"Sign-up is not available right now." (the pages are not found, and the sign-in page shows no link)Log onboarding.not_configured; on Development, the amplify.yml line and a new deployment; on Production, expected
any5xx other, or no answerThe Engine is down"Something went wrong. Try again."The person retries

The three 409s on the create route share the code CONFLICT and carry no extensions. The module tells them apart by a fixed prefix of the Engine's message:

  • "This project has no published release yet" → no Release (MsgOnboardingNoRelease);
  • "You have reached the limit of" → the company limit (MsgOnboardingPerIdentity);
  • "Another customer already has that id." → the id (MsgOnboardingIDTaken).

Any other 409 shows "We could not create your company. Try again later." The message is never shown to the person. This is the one place the flow reads an Engine message: until the Engine gives each of these refusals a code of its own, the prefix is the only way to tell them apart.

Reference

  • Customer self-onboarding: the flow: the files, the module that holds the key, the client address, the routes and pages, the changes to sign-in, and the amplify.yml line.
<!-- /buildpad-backend -->

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.