Skip to content

AI for programming: understand code, test it, adopt it safely

By the KI können editorial team7 min read

Written with AI and checked against the sources by a second AI. As of November 17, 2026. More in the notes on AI.

Coding assistants write functions, tests and whole changes in seconds. The code usually looks tidy, and that is exactly what makes it tricky: it can have gaps, use packages that don’t exist, or use permissions it shouldn’t have. Where AI helps in development is quickly said. What matters more is how you treat its output: like code from a stranger.

Two developers sit side by side at a desk in front of a laptop, one points at the screen, a board with notes behind them, a notebook and mugs on the desk.

Key points

  • AI code is someone else’s code: read it, test it, review it before it goes into the main branch.
  • Credentials don’t go into any prompt. Customer data and company source code only go into an approved service.
  • Check every suggested package: Does it exist, who maintains it, what license does it have?
  • Agents that run commands get as few permissions as possible, and you read every change.
  • Anyone offering products with digital elements in the EU has had to report actively exploited vulnerabilities since September 11, 2026, no matter who wrote the code.

Where AI helps in development

Development tasks and what you do afterwards
TaskWhat the AI doesWhat you do afterwards
Understanding someone else’s codeExplains functions, flows, dependenciesCheck at the spot in the code
Writing testsSuggests cases and test codeRun them, break the code on purpose
Preparing a reviewFlags suspicious spotsDo the actual review yourself
Refactoring codeSuggests a changeRead the diff, run the tests
Interpreting an error messageNames possible causesConfirm the cause yourself

In the trial lesson you put your first instruction together and get feedback. No account, in a few minutes. Start the trial lesson

Rules first: account, code, credentials

Source code is usually a trade secret. Copying it into a private AI chat hands it to a third party and weakens its protection. That’s why many companies approve one specific assistant with a company account and rule out others. The BSI, Germany’s Federal Office for Information Security, and ANSSI, the French cybersecurity agency, published joint recommendations on AI coding assistants in 2024. Among other things, they advise checking generated code carefully and not giving confidential data to publicly accessible services.

  • Only use the assistant your company has approved, with the company account.
  • No credentials, keys or tokens in prompts, files or examples. If they are in the code, they don’t belong there anyway.
  • No real customer data as test data. Made-up data in the same format is enough.
  • For files like .env or configurations with passwords: take away the assistant’s access.

Understanding someone else’s code

Tyler is a web developer at an agency and is taking over a client project that has grown over five years. There is hardly any documentation. He has individual modules explained, not the whole project at once.

Sample instruction
Explain this file to me. I’m a developer and know the language, but not the project.
1. What does the file do, in three sentences?
2. Which functions are there, one sentence each?
3. Which other files or services does it call?
4. What is unclear to you or looks like a bug? Give the line.
If you are only guessing, write “guess”.

The explanation is a starting point, not proof. Tyler jumps to every line mentioned and checks whether it really says that. Under point 4 he finds two real bugs and one hint that is wrong because the AI didn’t know about a configuration.

Tests that actually test something

Erin is a software tester at a provider of point-of-sale systems. She uses AI to derive test cases from a requirement, especially the edge cases people think of late.

Sample instruction
Here is a requirement: [requirement, e.g. a discount for quantities of 10 or more, at most 15 percent, can’t be combined with vouchers].
List test cases as a table: case | input | expected result | why this case.
Think of boundary values (exactly 10, 9, 11), empty and invalid inputs, and combinations.
Don’t write any test code until I’ve confirmed the list.

Only once the list is right does Erin have the test code written. Then she breaks the function on purpose, for example by moving the threshold from 10 to 11. If no test fails, the test checks nothing. That happens with AI tests when they are derived from the existing code: then they test what the code does, not what it should do.

Interpreting error messages

With a cryptic error message, an AI can help narrow down possible causes. Give it the message, the environment and what you’ve already tried. A full log often contains paths, server names or credentials; cut it down to the lines you need and replace such details with placeholders.

Sample instruction
I’m getting this error message: [message, shortened, without credentials or server names].
Environment: [language, version, framework, operating system].
Already tried: [steps].
Name the three most likely causes, each with a test that confirms or rules it out. Don’t suggest a fix yet.

Confirm the cause first, then fix it: that way an AI fix doesn’t just cover up the symptom while the actual bug stays.

Reviewing with AI, not by AI

An AI can go through a merge request beforehand and flag spots: missing error handling, unvalidated input, queries that could be manipulated. It doesn’t replace the actual review. It only knows the intent of the change from what you tell it, and it misses what is missing from the context.

Sample instruction
Look at this change. Goal of the change: [goal].
Only flag spots with possible bugs or security problems, each with the line and a one-sentence reason.
Order them by severity. Leave out praise and style questions.

Packages and licenses: does it even exist?

AI assistants sometimes suggest libraries that don’t exist, with plausible names. Attackers can register such names and put malicious code in them. Real packages can also be outdated or have a license that doesn’t fit your project.

  1. Check that the package exists in the official registry, and compare the name exactly.
  2. Look at who maintains it, when it was last updated and how many projects use it.
  3. Read the license and compare it with your company’s rules.
  4. Have the package approved like any new dependency, if that’s how your company does it.

The same goes for longer pieces of code that might come verbatim from a well-known project. If you notice that, check origin and license before you adopt them.

Agents that run commands

Some assistants work as an agent: they read files, run commands and change several files on their own. That saves time and brings a new danger. If a file, a ticket or a website contains a hidden instruction, the agent may follow it. This is called prompt injection.

  • Run the agent in an isolated environment, not with your full permissions.
  • Allow commands that delete, publish or send something over the network only after confirmation.
  • No credentials for production or customer data within its reach.
  • Read every change as a diff before it is accepted.

Cyber Resilience Act: responsibility stays with the manufacturer

Logan heads software development at a manufacturer of machine controls. For him, the EU’s Cyber Resilience Act matters, a regulation on the security of products with digital elements. Since September 11, 2026, manufacturers must report actively exploited vulnerabilities in their products: an early warning within 24 hours, a notification within 72 hours. Most of the other obligations apply from December 11, 2027. Pure web services without a product of their own are usually not covered.

Whether code was written by a person or an AI makes no difference here. Logan has therefore decided that AI code goes through the same reviews, tests and security checks as any other code, and that nobody approves a change they don’t understand.

Before you adopt it

  1. Read and understood the code, not just tried it out.
  2. Ran the tests and broke the code once on purpose.
  3. Checked every new package for existence, maintenance and license.
  4. No credentials and no real customer data in the prompt or the code.
  5. Reviewed by a person, like any other change.

Clear instructions are half the work here too

If you describe exactly what a function should and shouldn’t do, you get better code and can check it more easily. That holds for programming as much as anywhere. The learning app “KI können” practices writing and checking instructions with your own AI, including for tasks beyond code. The trial lesson shows you how it works; you don’t need an account for it.

Sources

Information as of November 17, 2026. Laws and offers can change; this article is not legal advice.