Skip to Content

Your agent can build you auth. And that's the problem.

When you ask an AI agent to set up social login, you win on day 1 and start losing on day 400. When to let it build it and when not to.
April 27, 2026 by
Your agent can build you auth. And that's the problem.
Wilfredo Fernando Pastor Avila
| No comments yet

It's Friday at 5pm. You give your agent the Google and GitHub OAuth credentials and tell it: "add social login for me". By 7pm there's a green commit, the flow works, and your landing page has three new buttons. You feel you won the day.

What your agent didn't tell you is that it has just written, inside your repo, a miniature identity system. And from now on that system is yours: yours when Google rotates a scope, yours when passkeys show up, yours when the first serious client asks you for SAML, yours when audit asks for a log you don't know where it lives.

This article is about when that is exactly what you want, and when it is the most expensive technical debt you'll take on this year. The rule applies to auth, but it's the same for billing, observability, transactional email and almost any layer that evolves under external pressure.

The invisible code your agent just wrote

When an agent "implements social login" for you, what it concretely did is generate the OAuth callback, decide a session format, write logic to refresh tokens, decide what happens if the same email comes from two different providers, set up a recovery flow, and leave user storage in the database you already had at hand.

None of that shows up in Friday's demo. The demo only shows "click button → enter the product". But behind that click, your repo has grown in several layers that are now your responsibility:

  • Provider layer: OAuth integration with Google, GitHub, Microsoft, Apple, whatever. Each with its quirks and deprecations.
  • Identity layer: how a user is modeled, how two accounts that are the same person get linked, what happens with an unverified email, what you do with duplicates.
  • Session layer: tokens, refresh, rotation, revocation, expiration, multiple devices.
  • Operations layer: audit logs, rate limiting on auth endpoints, incident handling, recovery when a user loses access.

The agent generated them in an afternoon because each one, in isolation, is textbook code. The problem is that the combination of the four is where the real difficulty lives, and that combination now sits in your repo with no one maintaining it apart from you and the agent you call again later.

Principle: An agent doesn't solve auth. It transcribes auth for you. The difference shows when something changes.

Day 1 is free. The problem is day 400

The right question isn't "how long does it take to ship?". The right question is "how much does it cost to maintain this over the next year?". And nobody asks you that when you see Friday's green commit.

You ask it yourself eight months later, when the provider changes a scope and half your users can't log in on Monday. You ask it when passkeys appear and your product competes with one that already supports them. You ask it when an attacker finds a CVE in the library your agent used, and you have to understand the code your agent wrote six months ago to patch it.

What distinguishes a good architecture decision is not the speed of the first commit. It's the amortized cost over the following 24 months. And for layers that evolve under external pressure —provider deprecations, CVEs, regulation, user expectations— the amortized cost of maintaining them yourself is always higher than that of delegating them to someone whose job is precisely that.

DayWhat you seeWhat it costs
Day 1Login worksZero
Day 60You asked to add another providerUnexpected refactor of account linking
Day 180A provider deprecated a scopeInvestigation + patch + redeploy
Day 300Passkeys show up, users ask for themPartial rewrite of the module
Day 400Audit asks for access logsYou realize you didn't store them

Principle: The price of infrastructure isn't paid on day 1. It's paid over the next 400 days.

The second-provider test

There is a very specific moment when the symmetry breaks. The first social login is trivial: you paste credentials, the agent builds the callback, done. The second is where the real complexity appears.

The user who logged in yesterday with Google logs in today with GitHub. Is it the same person or a different user? If it's the same, how does your system know? If the two providers return different emails, which one do you store as "the" email? If one returns an unverified email and the other a verified one, what do you do with the recovery flow?

That decision —account linking— is not a feature. It's a policy. And a badly chosen policy opens doors: if an attacker can register an account with an email that your legitimate user hasn't verified yet, and then your user does OAuth with that same email, you've just lost them the account. It's a known pattern called account takeover via unverified email. You know it when you read it in someone else's postmortem.

When the agent configures your first provider, it doesn't make that decision. When you configure the second, someone has to make it. And if that person is you without context, you'll choose wrong.

Principle: The first provider is code. The second is policy. Policies are not delegated to someone who won't be there when they blow up.

The enterprise customer test

The other point where it breaks is the first client who pays seriously. That client —any bank, any fintech, any company with more than 200 people— will ask for three things your agent didn't build: SAML so their Active Directory authenticates their employees, SCIM to provision and deprovision users automatically, and real isolation between their data and that of your other clients.

Each of those three things, alone, is a project. SAML involves understanding XML signing, certificates, metadata exchange and a protocol with 20 years of accumulated complexity. SCIM involves a REST endpoint with a specific schema that has to survive updates. Physically isolated multi-tenancy —not just a tenant_id column— means rethinking how users are stored from day one.

If you've reached this point with code the agent wrote in an afternoon, you're not rewriting a module. You're rewriting the heart of your product, while you have to close the customer who is going to pay what keeps your runway alive.

Principle: If your product will ever touch enterprise, assume it will sooner than you think. Design for it from day one or never design for it.

When to ask your agent to build it, and when not to

This is not an absolute argument against letting an agent build. It's an argument against delegating layers the agent won't maintain. The difference is the heuristic:

  • DO ask the agent when: it's a side project, a proof of concept, an internal tool, an isolated feature whose rewrite cost is low. When the worst case is "we throw it away and start over".
  • DON'T ask the agent when: the layer will evolve whether you want it or not (new providers, new regulations, new protocols), when errors are costly (auth, billing, personal data), when you'll have clients asking you for things that today don't exist in your head.

A shorter way to say it: ask the agent when the code it will write might not be in your repo in six months. Don't ask when that code will be in production for years, because then you'll be the one maintaining it.

Principle: An agent is good at building what you can throw away. It's bad at building what you're going to inherit.

The pattern repeats beyond auth

Auth is the most visible example, but the rule applies to any layer that meets three conditions: it evolves under external pressure, errors are costly, and requirements grow with the customer. The same happens with:

  • Billing: your agent can integrate card payments in an afternoon. When the first customer arrives with taxes by jurisdiction, subscriptions with proration, automatic dunning, MRR/ARR metrics and a CFO asking for reporting, you'll understand why dedicated platforms exist.
  • Observability: flat-file logs work until you need to correlate traces across services, alert before something breaks, and keep 90 days without your disk exploding.
  • Transactional email: sendmail on your server works until the first customer reports that your emails land in spam, and you discover deliverability has 15 years of DNS, reputation, bounce handling and feedback-loop complexity.
  • Search: LIKE '%foo%' over your database works up to 100k records. Then you learn what BM25 is, synonyms, stemming, and when an external index makes sense.

In each case, the trap is the same: the agent solves the simple version in an afternoon and you assume —without meaning to— that the complex version will also be yours when it arrives.

Principle: Any layer that will have requirements you can't enumerate today should not live in your repo.

When the agent operates the service instead of rewriting it

If you've reached this point and your reaction is "this is too much, I want to focus on my product, not identity infrastructure", that reaction is completely valid. It's the right reaction for almost any founder building a B2B SaaS with a growth horizon.

There are platforms that abstract all this complexity as an external service, where your agent —the same one you were going to ask to write the OAuth callback— configures the service with an API call or via MCP in thirty seconds, without writing anything in your repo. One of those platforms, designed so an agent can operate it end to end and so that each of your customers lives in its own isolated instance, is Prysm:ID. The idea is not that it is the only option —there are Auth0, Clerk, WorkOS, Supabase Auth and several more, each with its trade-offs—. The idea is that any of them is preferable to having an emerging identity system inside your repo, written by an agent who won't be around when it breaks.

Checklist before next Friday

Before asking your agent to implement the next infrastructure layer, run the question through this filter:

  1. Will this layer evolve under external pressure that I don't control?
  2. Is an error here just annoying, or is it costly and visible?
  3. Will my customers ask me for requirements on this that I can't enumerate today?
  4. Will the code written today still be in production in 18 months?
  5. Do I have the context to maintain it, or will I inherit it?

If you answered yes to three or more, that layer shouldn't live in your repo. Ask the agent to integrate the external service, not to rewrite the service. It's the same agent, the same day-1 speed, and a day 400 that looks quite a lot like day 1.

The hard work of a technical founder is not writing code. It's deciding which code is worth writing.

Your agent can build you auth. And that's the problem.
Wilfredo Fernando Pastor Avila April 27, 2026
Share this post
Archive
Sign in to leave a comment
Azure from the inside: when errors aren't bugs, they're corporate culture
Five reproducible frictions in the Microsoft console, why they reflect a business model rather than a technical problem, and how to evaluate your next cloud provider.