Joseph Leporati

How a CTO Should Set Guardrails for AI-Assisted Coding

Short answer

Treat the AI tool as an untrusted contributor. Automated tests and security scans must pass before anything merges. A named human reviewer signs off on every change, with stricter rules for auth, payments, infrastructure, migrations and PII. AI agents get scoped, short-lived credentials and can never push to protected branches. Every change is tagged as AI-assisted or not, so incident response can trace it. All of that fits on one page of written policy.

Abstract code pipeline flowing through a series of checkpoint gates before reaching a protected main branch

Your team is probably already using AI coding tools. So the real decision isn't whether to allow them. It's how much autonomy they get, on which parts of the codebase, and what evidence you need before their output reaches production. Without a written answer, every engineer sets their own rules, and you find out what they were during an incident.

I've spent 16 years building and running production software, most of it at Plondo Network, including commission payout systems held to 99.9% uptime. The controls below are the ones I'd put on any codebase that handles money, records or customer data. None of them needs an enterprise governance platform. A 5 to 20 person team can set them up with branch protection, CI and a policy document.

What does the data actually say about AI-generated code?

The risk is real, but it isn't spread evenly across the codebase, and that should shape your policy.

On quality, GitClear's 2025 analysis of 211 million lines of code found that AI assistants increase duplicated code and reduce refactoring. In that dataset, code churn rose from 4.5% in 2023 to 5.7% in 2024, refactoring dropped 39.9%, and copy-pasted code rose 17.1%. GitClear's 2026 follow-up reported within-commit copy/paste up 41%, code block duplication up 81%, error-masking constructs up 47%, and two-week churn up 15%.

The error-masking number deserves the most attention. A catch block that swallows an exception, or a fallback that quietly returns a default value, passes the tests and then hides the failure in production. It's the hardest kind of bug to find during an outage, because the logs say everything is fine.

On security, Augment Code's CTO playbook says AI-generated code fails security tests at roughly 45% regardless of model generation. It also flags "slopsquatting": the model invents a package name, someone registers that name with malicious code, and your build installs it.

Together these give three policy targets: duplication and maintainability (caught in review), silent error handling (caught by lint rules and review), and security and supply chain (caught by automated scanning and dependency controls).

How much autonomy should an AI tool get on a production repo?

Treat autonomy as a set of tiers, not a yes-or-no question. Here's how I'd lay them out:

TierWhat the AI can doCredentialsWhere it's acceptable
1. SuggestInline completions, chat answersNone beyond the editorEverywhere
2. Edit locallyMulti-file edits in a developer's working copyDeveloper's own, nothing extraEverywhere, with human commit
3. Agent in sandboxRuns commands and tests in a container, proposes a branchShort-lived, repo-scoped tokenNon-critical repos and paths
4. Opens PRsPushes to a feature branch, opens PRsScoped bot identity, no merge rightsNon-production repos, or restricted paths only
5. Merges or deploysMerges to main or touches productionNot grantedNowhere

The controls behind those tiers are well established. Knostic recommends scoping assistant access to the minimum repos and paths, using short-lived rotated tokens, and blocking pushes or PR creation from assistant identities in production repos. Six Feet Up recommends running agents in containers or sandboxes for auditability, access control and rollback, and requiring atomic commits with readable diffs.

If you need to explain this to an auditor or a public-sector customer, the NHI Mgmt Group maps it to familiar standards: NIST AI RMF's GOVERN function for ownership, NIST CSF 2.0 PR.AC-4 for permission boundaries, and NIST SP 800-53 Rev 5 AC-6 for least privilege.

In practice, the agent's bot account should never sit on the list of identities allowed to bypass branch protection. Check that list. Admin bypass rules are where these policies usually leak.

What tests and checks must pass before AI-generated code merges?

Whatever you require for AI-authored code, require it for all code. Developers can't reliably label which lines came from a model, and two standards invite people to game the label. What changes for AI-heavy work is how strictly you enforce the checks.

These are the required checks I'd put on the protected branch:

  • Tests on changed code. Measure coverage of the diff, not overall coverage. A repo at 70% overall can still accept a 300-line AI change with no tests at all. My own starting point is 80% line coverage on new and modified lines, adjusted per repo. That's a judgment call, not an industry standard, so tune it to how critical the code is.
  • Static analysis (SAST) that blocks on high-severity findings.
  • Lint rules against error masking. Ban empty catch blocks and bare except:, and flag broad catches that don't log or rethrow.
  • Duplication detection that warns above a threshold, so reviewers see copy-paste before it spreads.
  • Dependency gate. Any change to a manifest or lockfile needs explicit approval. This is your slopsquatting control.
  • Secret scanning, because models will cheerfully hardcode a sample key.

The dependency gate can be a few lines of CI:

# Fail if dependency manifests changed without explicit approval
CHANGED=$(git diff --name-only origin/main...HEAD | grep -E '(package\.json|package-lock\.json|requirements\.txt|poetry\.lock|go\.mod|Gemfile\.lock)$')
if [ -n "$CHANGED" ] && [ "$DEPS_APPROVED" != "true" ]; then
  echo "Dependency change needs approval from a code owner:"
  echo "$CHANGED"
  exit 1
fi

Set DEPS_APPROVED from a PR label that only code owners can apply. The reviewer then checks that each new package exists, is maintained, and is actually the package the code meant to import.

Who has to review AI-written code, and what do they sign off on?

Every change gets a human reviewer. Some paths get a specific human. Checkmarx recommends formal thresholds for when human security review is required, such as any AI-generated code touching sensitive systems or business logic, built into the PR and CI/CD workflow. Augment Code names the trigger areas as auth, payments, infrastructure, data migrations, public APIs and PII, and says to size review capacity to the volume.

Enforce the triggers with a CODEOWNERS file plus "require review from code owners" on the protected branch:

# CODEOWNERS
/src/auth/           @org/security-reviewers
/src/billing/        @org/payments-owners
/src/payouts/        @org/payments-owners
/db/migrations/      @org/data-owners
/infra/              @org/platform-owners
/api/public/         @org/api-owners

With that in place, a junior engineer who accepts an AI suggestion in billing code can't merge it without a payments owner approving. Juniors can still use the tools freely. The repo just decides who signs off, so it doesn't depend on anyone's judgment in the moment.

Review criteria should be written down, not left to habit. Six Feet Up lists logic errors, security implications, style and conventions. I add three questions specific to AI output:

  1. Does this duplicate logic that already exists elsewhere in the codebase?
  2. Does any error path fail silently?
  3. Can the author explain every line without re-prompting the model?

The third question carries the most weight. If the author can't explain the change, it isn't ready, however clean it looks.

For payment code in particular, the subtle failures are retries and partial writes. My posts on idempotency for payments and commission ledgers cover what a reviewer should look for there.

Review capacity is the real bottleneck

AI tools increase the volume of code. Review capacity doesn't grow with it. Experienced reviewers have long been hard to hire in this part of the state. In an undated article, the Cyber Innovation Center quotes its director as saying there were 3,000 unfilled tech jobs in the Monroe and Shreveport-Bossier region. Since the article carries no date, read that number as background on a long-running shortage, not a current count. Your own hiring pipeline is the better measure.

The local pipeline is improving. ULM's Computer Science program received $129,532 from the Board of Regents for AI-powered cybersecurity education, with stipends for 150 students. In Ruston, Louisiana Tech received $612,000 in federal funding for Cyber Service Academy scholarships and hands-on AI and security-operations training, and its Cybersecurity Applied Innovation Laboratory works with industry partners on AI and malware research. ULM's CIS faculty also stay in touch with NELASec/Tek and the Northeast Louisiana PMI chapter, which are good places to find people who already think about these problems.

Until you have that capacity, limit agent autonomy to what your senior reviewers can actually read. If a 2,000-line agent PR gets rubber-stamped, you have no control, only paperwork.

Why does the audit trail matter more in Louisiana?

When an AI-introduced bug exposes customer data, the legal clock doesn't care who wrote the code. Under Louisiana's Database Security Breach Notification Law (La. R.S. 51:3071), a business must notify affected residents without unreasonable delay and no later than 60 days after discovering the breach, and notify the Attorney General within 10 days of notifying residents. A Monroe or Ruston business facing that deadline needs to answer three questions quickly: which change caused it, when it shipped, and what else the same author or tool touched.

You can answer those from git if you set it up now. Require commit trailers through a PR template and a commit-msg hook:

Fix rounding in payout batch totals

AI-Assisted: yes
AI-Tool: <tool and version>
Reviewed-By: <name>

Then scoping an incident becomes a query instead of an archaeology project:

# Replace the window with the period your incident covers
git log --since="90 days ago" \
  --format='%h %ad %an %(trailers:key=AI-Assisted,valueonly)' \
  -- src/billing/ src/auth/

Keep the agent's own logs (prompts, commands run, files touched) alongside CI logs, and retain them at least as long as your incident investigation window. Self-reported trailers aren't perfect, but a partial attribution record is far more useful than none. For deciding where customer data should live in the first place, see on-device vs cloud AI.

A one-page policy skeleton you can adapt

AI-ASSISTED DEVELOPMENT POLICY  (owner: CTO / eng lead, review quarterly)

1. Scope
   Applies to all code, config and infrastructure changes, regardless of author.

2. Approved tools
   List of approved tools and versions. Data-handling terms reviewed.
   No customer data, secrets or production credentials in prompts.

3. Autonomy tiers
   Tiers 1 and 2 allowed everywhere. Tier 3 (sandboxed agent) allowed in: <repos>.
   Tier 4 (bot opens PRs) allowed in: <repos/paths>. Merge/deploy: never.

4. Credentials
   Agents use dedicated bot identities, repo- and path-scoped,
   tokens expire within <N> hours. Bots never on branch-protection bypass lists.

5. Required checks before merge
   Tests pass; new/changed-line coverage >= <your threshold>; SAST no high
   findings; secret scan clean; error-masking lint clean; dependency
   changes approved.

6. Human review
   1 approval on every PR. Code-owner approval required for auth, payments,
   infrastructure, migrations, public APIs and PII paths.
   Author must be able to explain every line.

7. Attribution and audit
   AI-Assisted trailer on every commit. Agent logs retained <N> months.

8. Incidents
   Incident runbook includes the attribution query. Breach clock: residents
   within 60 days of discovery, AG within 10 days of resident notice.

9. Exceptions
   Written, time-boxed, approved by <role>.

Where to start

  1. Audit branch protection on every production repo this week, especially the bypass lists.
  2. Add CODEOWNERS for auth, payments, migrations, infrastructure and PII paths.
  3. Add diff coverage, SAST, secret scanning and the dependency gate as required checks.
  4. Adopt the commit trailer and test the attribution query before you actually need it.
  5. Fill in the policy skeleton and set a date to revisit it in 90 days.

If you'd rather have someone run this as an engagement, it's typical fractional CTO work.

If you want help putting these guardrails in place on your codebase, email hello@josephleporati.com.

Common questions

Is AI-generated code actually buggier than human-written code?

The research shows measurable quality erosion, not a single clean defect rate. GitClear found more duplication, less refactoring and higher churn in AI-era code, and its 2026 report found error-masking constructs up 47%. Augment Code says AI-generated code fails security tests at roughly 45%. The practical response is to apply automated security scanning and human review to every change, whoever or whatever wrote it.

Should we use an AI tool to review AI-generated code?

An AI reviewer is useful as an extra check that catches obvious issues before a human looks. It shouldn't count as the required approval. The value of review comes from a person who owns the outcome and understands the system, which is what the NIST AI RMF GOVERN function addresses. Let AI pre-screen, and keep a named human as the approver of record, especially on code-owned paths.

Can a small team do this without buying an AI governance platform?

Yes. Branch protection rules, CODEOWNERS, required CI status checks, a free SAST scanner, secret scanning, a PR template and a commit-msg hook cover most of the controls in this article. The real cost is reviewer time, not tooling. For a 5 to 20 person team, start by limiting agent autonomy to what your senior reviewers can read carefully.

Do we have to tell customers we use AI coding tools?

The research behind this article doesn't identify a Louisiana law that requires disclosing AI coding tool use to customers. Your contracts may still require it, especially with healthcare, financial or public-sector customers, and Louisiana's breach notification deadlines apply no matter how the code was written. Check customer agreements and ask counsel before you assume no disclosure is needed.

Sources

  1. AI is eroding code quality states new in-depth report devclass.com
  2. Self-Admitted GenAI Usage in Open-Source Software (arXiv) arxiv.org
  3. The Maintainability Gap: 2026 AI Code Quality Research - GitClear gitclear.com
  4. Managing the Risk of AI-Generated Code: A CTO Playbook augmentcode.com
  5. How to Secure AI Coding Assistants and Protect Your Codebase knostic.ai
  6. A CTO's Guide to AI Coding Assistants sixfeetup.com
  7. Autonomous code review needs guardrails, not just faster AI coding nhimg.org
  8. CISO Guide to AI Code Security: Risks & How to Fix checkmarx.com
  9. Far From Silicon Valley, Emerging Tech Hub Pulls Workers To Northern Louisiana cyberinnovationcenter.org
  10. ULM Computer Science program receives grant for AI-powered cybersecurity education project ulm.edu
  11. Louisiana Tech receives $612K federal grant to expand cybersecurity education knoe.com
  12. ULM Computer Information Systems program page ulm.edu
  13. Louisiana data breach notification law and cyber insurance coveredbycornerstone.com

ai coding engineering policy code review security cto