AI agent workflow for SaaS
A practical AI agent workflow for SaaS codebases: context, plan, edit, verify, summarize and decide the next product action.

Put it into practice
What you will produce
A scoped implementation plan, a focused diff, and evidence for the affected user flow and tenant isolation.
- 01
Define the user-visible contract
Write down the expected input, output, failure behavior and tenant boundary for this SaaS change using product requirements or existing behavior as evidence.
Expected result: Acceptance criteria independent of any implementation proposal.
- 02
Map affected layers
Trace the route or action into domain logic and persistence; identify authorization checks, validation and data access that could cross account boundaries.
Expected result: A short change map showing the relevant code paths and security-sensitive seams.
- 03
Implement the narrow path
Ask the agent for the smallest change that satisfies the criteria, preserving existing conventions; require it to call out any assumption about authorization or stored data.
Expected result: A reviewable patch whose behavior and tenant scope can be inspected.
- 04
Verify behavior and isolation
Run the affected regression check and exercise the user-scoped path with two accounts where relevant; inspect both success and denied or invalid cases.
Expected result: Evidence that the intended user flow works without exposing another account's data.
Acceptance checks
- Acceptance criteria come from product behavior, not the generated implementation.
- Authorization and tenant-scoped queries are inspected on the changed path.
- The relevant regression check passes, including invalid or denied behavior.
- Two-account isolation is exercised when user-owned data is involved.
Limits and trade-offs
Generated tests can repeat the implementation's assumptions. Confirm the expected behavior and security boundary independently.
Official sources
Use the shipping loop
Related guides
Building AI agents that actually work
Most 'agents' are brittle pipelines dressed up with AI. Here's the anatomy of a reliable agent, three patterns that hold up in production, and when to use n8n vs code.
Everyone is building agents. Most of them break on the third run. One common failure mode is asking the model to handle too many responsibilities without clear checks. Architecture, model behavior and external dependencies can all contribute to failures. Here's what I've learned building agents that actually run week after week. The anatomy of a reliable agent Every agent that works has three parts, and only one of them should involve AI. Trigger something deterministic starts the agent. A schedule, a webhook, a file drop, a form submission. Not "whenever the AI decides it's time." Context the agent gathers what it needs before calling the AI. The document, the data, the user preferences, the constraints. The AI call happens with full context, not halfway through discovery. Action after the AI produces output, something deterministic happens with it. It gets saved, sent, logged, or published. The action step doesn't retry or…
Read the guidePrompt vs Workflow vs Agent
Everyone is calling everything an agent. Here's what actually separates the three, and why it matters when you're building.
The word "agent" is everywhere. So is "workflow". People use them interchangeably, which means everyone is confused and half the things called agents are just prompts with extra steps. Here's a clean mental model I use. It's not the academic definition it's the practical one. A prompt A prompt is a single call to an LLM. Input goes in, output comes out. That's it. No loops. No decisions. No tools. One round trip. Most "AI features" shipped in 2023 were prompts. They're underrated a well crafted prompt can do a lot. But they're fundamentally one shot and stateless. A workflow A workflow is a sequence of steps some of which may call an LLM executed in a predetermined order. The structure is defined by the developer, not the LLM. Example: a content repurposing workflow. 1. Receive a LinkedIn post (trigger) 2. Call Claude to rewrite as a Twitter thread 3.…
Read the guideMy n8n Workflow for Repurposing Content
I write one LinkedIn post. Claude + n8n turns it into a Twitter thread, a newsletter paragraph, and a blog draft. Here's the exact setup.
I was spending time each week repurposing content. One idea, written four times for four formats. It's the kind of work that feels productive but isn't. You're not thinking you're rewriting. So I automated it. The problem My content flow looked like this: 1. Write a LinkedIn post 2. Rewrite as a Twitter/X thread 3. Extract a paragraph for the newsletter 4. Expand into a blog post draft Every week. Same formats. Same cognitive overhead. The solution: one post, four outputs Now I write the LinkedIn post. I paste it into a form. n8n does the rest. Here's the full flow. Step 1: Trigger A simple webhook in n8n. I have a tiny form (Notion form, or even a plain curl command) that sends the post content to the webhook URL. Alternatively: a Gmail trigger that watches for emails from myself with subject [CONTENT] . Whatever is lowest friction for…
Read the guide