Skip to content
SaaSFunnelsHelp

Build with your agent · Build

How it works with your app

What the SaaSFunnels setup writes in your repository, how your agent wires a Funnel into your code and events, how it tests in your real app, and why keys never go in a prompt.

On this page

Your agent works in two places at once: your repository, where it changes your code, and your SaaSFunnels workspace, where it builds the Funnel. This page explains what lands where.

What lands in your repository

npx saasfunnels init writes .saasfunnels/config.json. It holds your workspace settings for the CLI and never a secret, so it's safe to commit.

npx saasfunnels agent install writes two playbooks: one for building Funnels and one for finding your app's events. Where they go depends on your agent:

TargetFiles
claude-code.claude/skills/saasfunnels-funnels/SKILL.md and .claude/skills/saasfunnels-event-discovery/SKILL.md
codexThe same two skills under .agents/skills/
cursor.cursor/rules/saasfunnels-funnels.mdc and the event-discovery rule next to it
markdownSAASFUNNELS-FUNNELS.md and SAASFUNNELS_DIRECT_API.md, for any other agent

Commit them so everyone on your team, and every agent, follows the same steps. Run the command again after you update saasfunnels to get the latest playbooks.

The install code

Funnels show through the SaaSFunnels install code: one snippet in your site or app. If it isn't there yet, your agent adds it as your framework expects, and checks that SaaSFunnels sees it.

If a site isn't allowed to load SaaSFunnels yet, your agent gives you a link that opens Settings → Install code with the site filled in. Nothing changes until an owner or admin saves it.

You can also start from the app:

  • In Finish setup → Add the snippet, select Copy AI install prompt. Turn on Include MCP setup instructions to have the prompt connect your agent too. Send to my developer emails the steps instead.
  • In SettingsInstall code, open the ⋯ menu and choose Set up with an agent.

How a Funnel opens in your app

Many Funnels need no code: they open on page load, after a scroll or time on page, or when someone's about to leave. Others start from something in your app, like a Cancel subscription button or a limit being reached. For those, your agent:

  1. Looks at how the Funnel opens, and keeps its audience, placement, Offer and goal as they are.
  2. Finds the right place in your code: the button, the route or the moment in your backend.
  3. Adds the smallest change that opens the Funnel there, such as an attribute on your own button or a track call.
  4. Tells SaaSFunnels what it added, so Studio shows the entry as connected.

If no Funnel opens, your button still does what it always did.

To hand this to your agent from Studio, open the Funnel's Who sees it, and when panel. On an entry that needs code, select Set up, then Install with coding agent, and copy the instructions into your agent.

Events

SaaSFunnels uses events from your app to decide when a Funnel opens and who sees it, and to count results.

  • npx saasfunnels setup run reads your app and finds your events, features and plans. It asks before sending anything and sends only what it found, never your source code. See Let SaaSFunnels read your app.
  • When your agent adds a new event, it can say how SaaSFunnels should read it, as you would in Settings → Data.
  • npx saasfunnels events validate checks an event before you ship it. It's handy in CI; see CI event validation.

Testing in your real app

Before asking you to publish, your agent tests the Funnel where it will really run:

  • In your app. It opens the draft in your running app with a one-time test link, triggers the entry and confirms the Funnel opened. Visitors never see the draft.
  • With Studio's Funnel test. It runs the same test as Run test in Studio, which checks that the right people see the Funnel and that each step works, and tells your agent whether the draft is ready to publish.

Both show up in Studio, so you can see what passed.

Payments stay on the server

Offers use your real plans and prices from Stripe. When a customer pays in a Funnel, SaaSFunnels confirms the payment with Stripe on the server. Nothing in the browser, and nothing your agent writes, decides what a customer paid for. If your Funnel takes payments through your own backend, see Payment actions.

Keys never go in a prompt

  • The MCP server signs in with your SaaSFunnels account. There's no key to paste.
  • npx saasfunnels login saves its key to ~/.config/saasfunnels/credentials.json, readable only by you, and never prints it.
  • The playbooks and the in-app prompts use placeholders, never real keys.
  • Server keys belong in your server's environment or secret manager. Never paste one into a chat with an agent, a prompt, a public repository or logs.

What's next

Design anything