Prompt Rules Are Not Enough: DevSecOps Enforcement Inside the AI Coding Agent

Purple Hooks cover: a steel crane hook pulls one red eval(expr) line out of a column of code written by an AI agent.

Executive summary

AI agents now write a large share of your code, so your DevSecOps checks have to run inside the agent’s own session, and Purple Hooks does exactly that in Claude Code, Cursor and Codex.

Key takeaways

  • Writing “don’t use eval” in a prompt is advice, and the agent can ignore it. A real control is a check that can stop the agent’s command.
  • Check the code at push and at pull request, and send the results straight back to the agent so it can fix the problem before a human sees it.
  • Block a pull request only for new problems the agent just introduced. Old problems that were already in the code are listed, but they do not stop anyone’s work.
  • Let the security team set one set of rules for the whole company. Each team can add stricter rules, but nobody can relax them on their own.
  • Make sure you can see which repositories have the check installed and running. If you cannot see it, you cannot count on it.

The problem: the agent writes the code, and your rules are only suggestions

In most engineering teams I talk to, developers no longer type most of the code. They ask an agent like Claude Code, Cursor or Codex to write it, then they review and merge. The agent works far faster than any review process was designed for.

Companies usually try to keep that code secure in two ways.

They give the agent better instructions. Teams write rule files and long prompts: “never use eval“, “always use parameterized queries”, “never put secrets in the code”. Good rules help, and Phoenix generates them from real findings. But a rule only nudges the agent. If the agent decides a shortcut is fine, it takes the shortcut.

They also rely on the CI pipeline, which checks the pull request later. By then the agent has moved on, and a person has to fix code they did not write, often days later.

Security teams have plenty of scan data. What they are missing is a check that runs at the moment the agent writes the code, following rules that the security team owns.

Why DevSecOps guidance alone fails when agents write the code

Four things go wrong in practice.

Instructions have no teeth. A rule file is just more text for the model to read. The agent decides whether to follow it, and you cannot prove afterwards that it did.

The agent’s own safety settings belong to the developer. In a live customer session in October, Claude Code’s built-in auto mode refused to commit an eval call before our check even ran. That was the right call, but it is a personal setting each developer can switch off, and a company policy cannot rely on it.

A report cannot stop anything. Our first version, in June 2026, ran an analysis when the agent’s session ended, but Claude Code does not let an end-of-session hook stop anything. So we moved the check to the moment the agent runs a command.

Too many alerts kill adoption. A check that blocks on every old problem in the repository blocks on day one, and developers remove it the same day.

The Phoenix approach: Purple Hooks

Purple Hooks puts a security check inside the AI coding agent itself. It is the center of three layers that work together, each one catching what the previous one missed:

  1. Guardrails guide what the agent writes, using rules built from your own findings.
  2. Purple Hooks stops the agent inside its session, while it can still fix the problem itself.
  3. The Phoenix check on every pull request confirms the result on our side, where nobody can switch it off.

Layer 1: Guardrails prevent the mistake before the agent writes it

Guardrails are security rules that Phoenix writes for your AI agents, based on the real vulnerabilities it has already found in your code. A cross-site scripting finding becomes a rule that tells the agent how to avoid that mistake in those files. If a repository has no serious findings yet, Phoenix runs a quick scan and creates best-practice rules for your stack instead.

You review the rules and download them in one click for Claude Code, Cursor, Gemini CLI or Codex CLI, and the agent reads them every time it writes code. Guardrails make the agent less likely to repeat a known mistake. The next layer catches anything that still gets through.

Layer 2: Purple Hooks stops the agent in its own session

Purple Hooks plugs into Claude Code, Cursor and Codex as a native “hook”, a small script the agent runs automatically before and after certain commands. It watches the three commands that move code toward production: git commit, git push and gh pr create. The decisions happen in Phoenix, using your security team’s rules, and neither the developer nor the agent can change them.

When the agent commits, nothing is scanned. Commits stay instant, and the agent sees a short note saying the check runs at push.

When the agent pushes, Purple scans the new code in the background. The agent does not wait. As soon as the results are ready, they appear in the agent’s own session, in two lists: Blocking (must fix) and Fix these too (worth fixing). A push is never blocked.

When the agent tries to open a pull request, Purple can stop it. If the change adds problems at the severity levels you chose, the pull request is not created. This is not a message the agent can talk its way around: the command simply does not run. The agent gets the full list of problems, with file and line, and one clear instruction: fix the Blocking list, then try again. And it does.

Built so developers keep it switched on

A security check only works if people leave it on. These are the choices that make Purple Hooks easy to live with:

  • It only blocks on new problems in the lines the agent changed. Older issues still appear in the Fix these too list, so nothing is hidden, but they never stop the pull request.
  • Vulnerable open source libraries are reported but never block a pull request.
  • It never fakes a pass. If part of the scan could not run, Purple says so, and in block mode the pull request stays closed until it can check properly.
  • Your security team decides how long a pull request waits: up to 300 seconds (5 minutes) by default, after which it opens and the agent posts the result as a comment, or until the result is ready.
  • Fixes are suggested, never forced. For each problem, Purple can add guidance or up to 10 AI-generated fixes, clearly labeled as suggestions to review. They never change the verdict.
  • False positives have a clean way out. When the check blocks something that is actually safe, the message includes a ready-made command to request a waiver for that finding. A different person approves it, and it expires after a time limit you set, up to 365 days.

Layer 3: the pull request check nobody can remove

The hook runs on the developer’s computer, so a developer could remove it. We say so openly, and it is why the third layer exists. Every pull request is also checked by Phoenix on our side, where nobody can switch it off. The hook gets problems fixed early, so this check passes first time far more often and remains your official record.

Configure it: one set of rules for the whole company

The security team sets the company-wide minimum under Policies > Scanning > Hook policy, such as “block pull requests with critical or high issues”. Each team can make its own rules stricter, but never weaker. If someone tries to save a weaker setting, Purple refuses it and explains which setting is the problem. If a team really needs to go below the minimum, an admin can grant a policy exception for a limited time, and the check announces it every time it applies. Every change is recorded.

Roll it out: set up in one command

A developer downloads the setup pack from Phoenix and runs a single command. The pack contains a one-time code that expires after 15 minutes, which the installer swaps for a personal login stored safely on the developer’s machine. Nobody has to copy or paste API keys. For larger teams, Phoenix opens a draft setup pull request per repository on GitHub, GitLab or Azure DevOps, and your team merges it when ready.

See where it is running

A check that looks installed but does nothing is worse than no check. Purple records every time a scan is skipped. The Enforcement page shows, for each repository, whether the hook is installed and up to date, which repositories have gone quiet, and, on GitHub, how many pull requests were merged even though the Phoenix check was red in the last 90 days.

The PR scans page lists every pull request Phoenix scanned, with what started the scan and the newest result: Pass, Block, Running or Recheck required. Its Waivers tab shows every approved waiver next to the pull requests it affected.

The Policy heartbeat shows, for each workspace, whether the gate is still talking to Phoenix. A workspace is Healthy only when its hook fetched the policy in the last 48 hours and reported no violations. After 48 hours of silence it is flagged as Silent, a warning rather than a pass, because silence can mean the hook was removed. Workspaces with blocks or skipped scans show Has reported violations, so you know where to look first.

Real-world example: the agent fixes its own code

We ran the whole flow in our test environment with Claude Code and a demo app.

The agent added a calculator endpoint that used eval, a classic code-injection risk. The agent committed and pushed with no friction. When it tried to open the pull request, Purple stopped it after 94 seconds and showed one blocking problem, with the exact file and line.

The agent’s reply was clear: it would not bypass the security check. It offered two options: fix the code itself, or ask Purple for a suggested fix first with /purple-scan remediate.

We typed “fix it”. The agent removed eval, wrote a safe replacement and tried again. This time the pull request passed, in 91 seconds. No person touched the code.

Then the third layer, the Phoenix check on GitHub, confirmed the result.

That is the whole idea in one loop. The vulnerable line never reached a human reviewer. The agent that wrote it also fixed it, while it still had all the context.

Protect yourself with Phoenix Purple – find TRUE critical chainable vulnerabilities with exploits

Practical guidance: how to start on Monday

Start by watching, not blocking. Install Purple Hooks on 3 to 5 active repositories and set pull requests to warn only. After a week, the Enforcement page shows which teams use agents, how often new problems appear and which repositories are not covered.

Then switch on blocking. A good starting point is: block critical and high problems on pull requests, warn on pushes, and leave commits alone.

Turn on waivers before you start blocking. Developers need a fair way to handle false positives, or they will look for ways around the check.

Watch the “merged past a red check” number. If it is above zero, your branch protection rules need tightening.

Next steps

  1. Look at the rule files you already give your agents. Every rule you would like to enforce, not just suggest, is a candidate for Purple Hooks.
  2. Set your company-wide policy under Policies > Scanning > Hook policy, then roll it out to one team with the setup pull request.
  3. See it working on your own code. Book a demo at securityphoenix.io/demo and we will show you an agent being stopped, and fixing its own mistake, live.

Purple Hooks is available now on the Phoenix Enterprise plan, for Claude Code, Cursor and Codex.

International Sales Engineer — founding SE globally at Phoenix Security.

Discuss this blog with our community on Slack

Join our AppSec Phoenix community on Slack to discuss this blog and other news with our professional security team

From our Blog

AI coding agents read your security rules, then decide whether to follow them. Purple Hooks moves DevSecOps enforcement inside Claude Code, Cursor and Codex. In our test, the agent added eval, was blocked at pull request after 94 seconds, fixed its own code and passed in 91. No human touched it.
Jorge Vico Castillo
NGINX2Root (CVE-2026-123007) lets an unauthenticated attacker run code on NGINX through a crafted HTTP/2 session. Every release from 1.9.5 to 1.31.8 is affected, and about 8.8 million internet services still negotiate HTTP/2. Patching isn’t enough on its own: a config reload leaves the vulnerable binary running.
Marcus Webb
Derek

Derek Fisher

Head of product security at a global fintech

Derek Fisher – Head of product security at a global fintech. Speaker, instructor, and author in application security.

Derek is an award winning author of a children’s book series in cybersecurity as well as the author of “The Application Security Handbook.” He is a university instructor at Temple University where he teaches software development security to undergraduate and graduate students. He is a speaker on topics in the cybersecurity space and has led teams, large and small, at organizations in the healthcare and financial industries. He has built and matured information security teams as well as implemented organizational information security strategies to reduce the organizations risk.

Derek got his start in the hardware engineering space where he learned about designing circuits and building assemblies for commercial and military applications. He later pursued a computer science degree in order to advance a career in software development. This is where Derek was introduced to cybersecurity and soon caught the bug. He found a mentor to help him grow in cybersecurity and then pursued a graduate degree in the subject.

Since then Derek has worked in the product security space as an architect and leader. He has led teams to deliver more secure software in organizations from multiple industries. His focus has been to raise the security awareness of the engineering organization while maintaining a practice of secure code development, delivery, and operations.

In his role, Jeevan handles a range of tasks, from architecting security solutions to collaborating with Engineering Leadership to address security vulnerabilities at scale and embed security into the fabric of the organization.

Jeevan Singh

Jeevan Singh

Founder of Manicode Security

Jeevan Singh is the Director of Security Engineering at Rippling, with a background spanning various Engineering and Security leadership roles over the course of his career. He’s dedicated to the integration of security practices into software development, working to create a security-aware culture within organizations and imparting security best practices to the team.
In his role, Jeevan handles a range of tasks, from architecting security solutions to collaborating with Engineering Leadership to address security vulnerabilities at scale and embed security into the fabric of the organization.

James

James Berthoty

Founder of Latio Tech

James Berthoty has over ten years of experience across product and security domains. He founded Latio Tech to help companies find the right security tools for their needs without vendor bias.

christophe

Christophe Parisel

Senior Cloud Security Architect

Senior Cloud Security Architect

Chris

Chris Romeo

Co-Founder
Security Journey

Chris Romeo is a leading voice and thinker in application security, threat modeling, and security champions and the CEO of Devici and General Partner at Kerr Ventures. Chris hosts the award-winning “Application Security Podcast,” “The Security Table,” and “The Threat Modeling Podcast” and is a highly rated industry speaker and trainer, featured at the RSA Conference, the AppSec Village @ DefCon, OWASP Global AppSec, ISC2 Security Congress, InfoSec World and All Day DevOps. Chris founded Security Journey, a security education company, leading to an exit in 2022. Chris was the Chief Security Advocate at Cisco, spreading security knowledge through education and champion programs. Chris has twenty-six years of security experience, holding positions across the gamut, including application security, security engineering, incident response, and various Executive roles. Chris holds the CISSP and CSSLP certifications.

jim

Jim Manico

Founder of Manicode Security

Jim Manico is the founder of Manicode Security, where he trains software developers on secure coding and security engineering. Jim is also the founder of Brakeman Security, Inc. and an investor/advisor for Signal Sciences. He is the author of Iron-Clad Java: Building Secure Web Applications (McGraw-Hill), a frequent speaker on secure software practices, and a member of the JavaOne Rockstar speaker community. Jim is also a volunteer for and former board member of the OWASP foundation.

Join our Mailing list!

Get all the latest news, exclusive deals, and feature updates.

The IKIGAI concept
Protected By
Shield Security PRO