Can I use AI on this code? How we taught our tools to answer that question.
In mid-2025, as AI coding assistants went from novelty to everyday tool, one question kept landing in our inbox from product teams across government: “Can I use this on my repo?”
It sounds like a yes-or-no question. It turned out to be anything but. Answering it properly meant building something governments don’t usually have: a way of classifying source code in its own right. This post explains why our team within GovTech did that, how it works, and how we’ve made the AI tools enforce the policy themselves, so that engineers rarely have to think about it.
The risk hiding in every prompt
To be useful, AI coding assistants need context. When an engineer asks an agent to fix a bug or write a test, the tool gathers relevant pieces of the code repository (source files, configuration, documentation) and sends them as part of a prompt to a model. More often than not, that model runs on infrastructure outside the organisation.
Every one of those prompts is, in effect, a small disclosure of code. Multiply that by thousands of engineers and millions of prompts, and you need to be confident about what you’re sharing.
For most government code, that’s not a problem. A lot of what we build is plumbing: web front ends, form handling, integrations, infrastructure as code. Leaking it would embarrass nobody and help nobody. But some code is different. Some code encodes how an agency makes decisions, and exposing it could cause real harm.
The trouble was that teams had no consistent way to tell those two kinds of code apart. Without one, people tended to go one of two ways. Some were cautious and avoided AI tools entirely, giving up the productivity gains. Others were optimistic and used them anyway, without really knowing what they might be exposing. Neither was a good outcome.
Code is an asset in its own right
Governments are good at classifying data. They’re also reasonably good at classifying systems. What we didn’t have was a classification for the code itself.
The natural instinct is to give code the classification of the system it belongs to. If the system handles sensitive information, the code must be sensitive too. But that conflates two very different questions:
- What would happen if someone got hold of the data this system processes?
- What would happen if someone got hold of the code that does the processing?
The answers are often very different. A system can process highly sensitive records while its code reveals nothing more interesting than how to read from a database and render a web page.
So we built a framework that treats code repositories as assets in their own right. To keep it familiar, we based the assessment criteria directly on the ones public officers already use for data and system classification, and then added guidance on how to interpret them for code. It applies to every code repository the government owns, regardless of who wrote it. That includes code built in-house, code built by a vendor and handed over to government, and open-source projects we’ve forked and maintain ourselves.
What makes code sensitive, and what doesn’t
The most useful part of the framework turned out to be the guidance on what should not affect a classification. Without it, people default to caution, and everything ends up classified more highly than it needs to be.
What a system does doesn’t count. Code that handles sensitive data isn’t automatically sensitive. The sensitivity of the data is dealt with by data and system classification. Code classification asks a narrower question: what would disclosing this code reveal?
Security by obscurity doesn’t count. Systems shouldn’t depend on attackers not knowing how they work. Revealing technical architecture in a repository generally shouldn’t be considered damaging, and secrets such as passwords and access tokens should never be in a repository in the first place.
“Just in case” doesn’t count. Precaution isn’t a valid justification. To classify a repository above the baseline, the assessor has to point to specific content in the repository that meets the criteria for that level.
So what does push code up the scale? Overwhelmingly, it’s business rules: logic that reveals an agency’s internal processes and how it makes decisions. Think of a grants system whose code contains the exact thresholds that trigger a fraud review, or an allocation system that encodes tie-break logic beyond what’s been published. If those rules became public, people could game them, sidestep them, or tie the agency up in disputes. Not every business rule is sensitive. The question is always how much damage disclosure would likely cause.
Alongside all of this sits one hard rule: personal data must never be committed to a code repository. Keeping it out of repositories entirely is much simpler, and much safer, than trying to classify it once it’s there.
The five levels
Every repository is assigned one of five security classification levels. Each is defined by the impact unauthorised disclosure would have:
| Level | Definition |
|---|---|
OFFICIAL_OPEN |
Unauthorised disclosure does not result in negative consequences to agency or national interests, and the code is deemed suitable and useful to be disclosed to the public. |
OFFICIAL_CLOSED |
Unauthorised disclosure does not result in negative consequences to agency or national interests, but the code is deemed unsuitable or not useful to be disclosed to the public. |
RESTRICTED |
Unauthorised disclosure causes no damage to national interests but some damage to agency interests, such as disrupting an agency’s processes and hindering it from carrying out its functions. |
CONFIDENTIAL_CLOUD_ELIGIBLE |
Unauthorised disclosure causes no damage to national interests but serious damage to agency interests, such as disrupting an agency’s critical processes so that it is unable to carry out its functions. |
CONFIDENTIAL |
Unauthorised disclosure causes some damage to national interests, such as disadvantage in national-level negotiations, disruption to foreign relations, or disruption to essential services for public safety, public order, public health, or the stability of the financial system. |
In practice, the assessor works down the levels from the top. Would disclosure damage national interests? If not, would it seriously damage agency interests? If not, would it cause some damage? The first “yes” gives the classification. If every answer is “no”, the only remaining question is whether the code is suitable for public release: if it is, it’s OFFICIAL_OPEN; if not, OFFICIAL_CLOSED.
If a repository mixes content at different levels, it’s classified at the highest level that applies. That’s often a hint to split the repository: moving the sensitive business rules into their own, smaller repository leaves the rest of the codebase at a lower level, where teams can use more tools.
Who decides
Classification is done by the people closest to the code. The assessor is a public officer on the product team, ideally the technical lead, because they have the context to judge what the repository actually contains. They can consult a specialist, such as a cybersecurity engineer, if they need a second opinion.
Accountability then sits with senior leadership. Depending on how the team is structured, that’s either a product director who approves each assessment, or an agency’s CIO, who is accountable for the classification of every repository in their agency. A central team runs periodic sampled reviews across government to check that the declared classifications match what’s actually in the repositories.
Classifications aren’t permanent. A repository is reassessed every year, or sooner if it changes significantly, for example when new business logic is added. Brand-new, empty repositories start at OFFICIAL_OPEN, so teams can use AI tools from their first commit and revisit the classification once there’s real code to assess.
Why a Markdown file in the repository
We had to decide where a classification should live. A central register was the obvious option. But registers drift out of date, they’re separate from the thing they describe, and nobody looks at them while they’re writing code.
Instead, every repository carries its own classification in a file called CLASSIFICATION.md at its root. Here’s an example:
---
version: https://go.gov.sg/code-classification-0-2-0
date: 2026-11-26
security: RESTRICTED
---
# Key determinants
The repository contains the eligibility scoring rules for the grants
application service, including the thresholds and weightings used to
flag applications for manual fraud review. Disclosure would let
applicants tailor submissions to avoid review, hindering the agency's
ability to assess applications. The rest of the codebase (front end,
API layer, infrastructure) would be OFFICIAL_CLOSED on its own.
# Assessors
Assessed by the product team's technical lead, with input from the
agency's cybersecurity engineer.
The format is deliberately simple: Markdown with YAML front matter. That choice serves two audiences at once.
Humans can read it. Product team members, new joiners, and auditors can open the file and see both what the classification is and why. The rationale sits right next to the code it describes, so it’s easy to check and to challenge when the code changes.
Machines can read it. The front matter is structured data that standard libraries in almost every language can parse. The version field identifies the schema the file follows, and it’s also a link to the documentation, so anyone who comes across the file can find out what it means.
Because the file lives in the repository, it travels with the code. It’s versioned and reviewed like everything else in the repository, and it’s always where you’d expect to find it.
The payoff: tools that enforce the policy themselves
Machine-readability is what makes the framework genuinely useful, rather than one more compliance exercise.
We approve each AI tool for specific classification levels. As a repository’s classification goes up, the set of approved tools narrows. At the lower levels, a full range of coding assistants, integrations, and AI-powered code review is available. At the higher levels, the options shrink to tools that run in tightly controlled environments.
The key point is that the tools check this themselves. Before running, an approved tool looks for the repository’s CLASSIFICATION.md, reads the classification, and confirms that the level is one it’s been approved for. If the file is missing, or the level is above what the tool is approved for, the tool refuses to run.
This matters more than it might seem. There are many AI tools, the market changes month by month, and each tool is approved for a different set of levels. Expecting every engineer in every product team to keep that matrix in their head would never work. With the tools enforcing it, they don’t have to. An engineer classifies their repository once, and from then on the tools take care of the rest. Policy is built into the tools rather than buried in a document nobody reads.
From pilot to standard
We launched the framework with a small group of teams in early 2026, refined it based on what we learned, and in the second half of the year extended the pilot to a wider set of agencies. In Nov 2026 it became an official government standard, integrated into the IM8 technology governance policy.
Over 3,000 code repositories across agencies have now been classified. One result stands out: over 80% of them are classified as either OFFICIAL_OPEN or OFFICIAL_CLOSED. In other words, the large majority of government code carries no risk of damage if disclosed. It’s the sensitive minority that needs careful handling.
That figure supports the reason we built the framework. Without it, the cautious default would have kept most of that code away from tools that could make our engineers significantly more productive. With it, teams can use AI with confidence where it’s safe, and the sensitive minority gets the protection it needs.
What’s next
More tools that recognise the classification. The more tools that read CLASSIFICATION.md and enforce policy themselves, the less engineers have to think about it. We want every AI tool across the development lifecycle, and eventually other parts of the toolchain too, to read the file and act on it.
AI-assisted classification. The rubric gives clear, specific criteria, which makes it a good fit for AI. We’re exploring tools that read a repository, identify content that’s likely to affect its classification, such as business rules, and propose a level with a draft rationale for the assessor to review. The decision will still be made by a person, who stays accountable for it, but they’ll start from a well-reasoned draft rather than a blank page.