AI Agents

My AI Coding Agent Asked to Query a Bank's Core Database Directly. The Architecture Said No.

AI coding agents do not know your architecture rules, so they break them. I designed a bank around Apache Fineract in Cortex Architect, turned its rules into guardrails, and watched Claude Code get refused over MCP, with the reason.

Here is the question I had Claude Code ask before it wrote any code: may the customer-facing API connect straight to the bank's core database?

And here is the answer it got back:

The AI Augmented Engineer: Software Development 2026-2030: A Practical Guide to Thriving in the Age of AI-Native Development

The AI Augmented Engineer: Software Development 2026-2030: A Practical Guide to Thriving in the Age of AI-Native Development

By 2030, 0% of IT work will be done without AI. Data-backed career roadmap for software engineers. No hype, no doom. Practical strategies that work.

Learn More
{
  "allowed": false,
  "alreadyExists": false,
  "violates": [
    {
      "rule": "Nothing except the Fineract runtime roles may depend on the Fineract production database.",
      "decision": "ADR-0002"
    }
  ]
}

No, the rule it would break, and the decision that rule comes from.

An hour earlier the same question got "allowed": true. Nothing about the agent changed in between. What changed is that the rule stopped being a sentence and became something that is checked. This article is about that hour, because I think it is the missing piece in how most teams use coding agents.

I should say up front that I build the tool this was done in, Cortex Architect. You can click through it without an account on the live demo.

The problem: your agent has never been to an architecture review

https://grizzlypeaksoftware.com/articles/api/image/509

Every system has rules that are not in the code. Only the orders service writes to the orders table. Nothing calls the payment provider except the payments service. Reporting reads from the replica, never from production.

People learn these rules slowly, from reviews and from being told off. A coding agent learns none of them. It sees a database it can reach and a ticket that says "make the balance screen faster", and it writes the query that works. The code is fine. The tests pass. The architecture is a little more broken than it was yesterday, and nobody finds out until something that was supposed to be isolated turns out not to be.

You can put the rules in a prompt file. I have. It helps until the file is long, or stale, or the agent decides this case is different.

So I tried it the other way round, on the kind of system where these rules matter most.

The test: a bank

I connected Apache Fineract, the open source core banking platform, to Cortex Architect. It read the repository and drew what is there: the Fineract services, the database, the Kafka topics, fifty code modules.

Then I asked the architect in the side panel to design a whole bank around it. It proposed digital channels, an integration layer, payments and reconciliation, onboarding and lending, financial crime and fraud, data and reporting, operations and security, and disaster recovery. The model came to 158 parts and 151 connections. Everything read from code is solid. Everything that is only a design is dashed and marked "Proposed".

The bank in Cortex Architect: nine applications on the left, and the architect listing the fifteen decisions it recorded on the right.

This is a reference design, not a real bank, and I have no connection to the Apache Fineract project. The architect left the country, the payment schemes and every outside provider unselected, which is right. I had not told it, so it did not guess.

Round one: the rule is only words

The first design already had rules. They were in the descriptions. The channels application said plainly that channels never access core banking or payment databases directly.

Cortex Architect is also an MCP server, so a coding agent can ask it things. One of the things it can ask is whether a dependency is allowed before it adds one. I had Claude Code ask about the customer API and the core database.

{ "allowed": true, "alreadyExists": false }

That is the honest state of most architecture. The rule was written down, a person would have found it, and the machine doing the work was told to go ahead.

Round two: the rule is a guardrail

I asked the architect to record the rules the design already stated as decisions, and to make each one a guardrail. It took a few minutes and produced fifteen. A few of them:

  • Only the Core banking adapter may call Fineract.
  • Only Fineract's own runtime may access the Fineract production database.
  • Digital channels never access core banking or payment databases directly.
  • Only the Payment hub may call the Payment scheme connector.
  • The data pipeline never reads the Fineract production database directly.

The decision trail in Cortex Architect, with the payments application beside it.

Then the same question again, and the answer at the top of this article. I tried a second shortcut, the Payment hub calling Fineract and skipping the adapter:

{
  "allowed": false,
  "alreadyExists": false,
  "violates": [
    {
      "rule": "No component may call Fineract except the Core banking adapter; the mock OAuth server is a test-only exception.",
      "decision": "ADR-0001"
    }
  ]
}

And the route the design intends, the Payment hub calling the adapter, came back allowed.

Three things about this matter to me.

The agent gets the reason, not only the refusal. It can open ADR-0001 and read why. That record says letting every service call Fineract makes the core's API "an internal free-for-all", and that a generic proxy controls routing but not which banking operations are allowed. An agent that knows why takes the intended route. An agent that is only blocked looks for another way around.

The decision is made on the server. The rule is not in a prompt the agent may or may not weigh. It asks, and the model answers.

It still works when the agent does not ask. Guardrails are checked against the code every time the repository is read. A shortcut somebody adds anyway shows up as drift.

The bonus finding: a case-notes database in the payment path

Since the model was there, I ran the stress test on it. I took down the financial crime case store, which is where investigators keep alerts and case notes.

The stress test with the financial crime case store down: screening, fraud decisions and everything waiting on them in red.

Twenty-three other parts stopped. Sanctions screening and fraud decisions both write their evidence to that store, and the Payment hub waits on both before releasing money. A database that sounds like back-office record keeping sits in the path of every payment.

I do not think that is wrong. A bank should not release a payment it cannot record a screening decision for. But it is the kind of dependency nobody decides on purpose. It just accumulates, and the first time anyone learns about it is during an outage. I learned about it by clicking.

What it will not do

  • It does not block a packet. A guardrail in a model is not a firewall. The decision record itself says network policy and code-level tests must enforce the same rule in production. What the guardrail does is tell every person and agent the rule, and catch the breach.
  • The agent has to be connected and has to ask. If it does not, you find out at the next read of the code, not before the change.
  • The bank is a design. Only the Fineract parts came from real code.
  • The stress test is pessimistic. It treats every dependency as fatal and knows nothing about fallbacks. It also ranks the local logging stack from Fineract's repository as one of the worst things to lose, because it reads development tooling as it finds it. On a real project I would mark that as development-only.

Do it to your own codebase

You already have the rules. They are in a wiki and in three people's heads. This is how to put them where your agent can read them:

  1. Connect a repository. Cortex Architect reads it and draws the system that is really there.
  2. Tell the architect one rule you care about. It records the decision and the guardrail.
  3. Connect Claude Code, Cursor or another MCP client with one command.
  4. Ask your agent to break the rule, and see what it is told.

One project is free for one person, with no card. The Team plan is $199 a month for the whole team, not per seat, with a 14-day trial.

If your agent gets told no, I would like to hear which rule it was.

Found this article helpful?

Explore more tutorials and guides on API development, AI, and software architecture.

Browse All ArticlesGet Expert Help