AI for programming: understand code, test it, adopt it safely
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.

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
| Task | What the AI does | What you do afterwards |
|---|---|---|
| Understanding someone else’s code | Explains functions, flows, dependencies | Check at the spot in the code |
| Writing tests | Suggests cases and test code | Run them, break the code on purpose |
| Preparing a review | Flags suspicious spots | Do the actual review yourself |
| Refactoring code | Suggests a change | Read the diff, run the tests |
| Interpreting an error message | Names possible causes | Confirm 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.
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.
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.
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.
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.
- Check that the package exists in the official registry, and compare the name exactly.
- Look at who maintains it, when it was last updated and how many projects use it.
- Read the license and compare it with your company’s rules.
- 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
- Read and understood the code, not just tried it out.
- Ran the tests and broke the code once on purpose.
- Checked every new package for existence, maintenance and license.
- No credentials and no real customer data in the prompt or the code.
- 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
- Regulation (EU) 2024/2847 on cybersecurity requirements (Cyber Resilience Act), EUR-Lex (opens in a new tab)
- ANSSI and BSI, AI Coding Assistants (October 4, 2024) (opens in a new tab)
- OWASP Gen AI Security Project, LLM01:2025 Prompt Injection (opens in a new tab)
- OWASP Gen AI Security Project, LLM09:2025 Misinformation (made-up libraries) (opens in a new tab)
- German Trade Secrets Act (Gesetz zum Schutz von Geschäftsgeheimnissen) (in German) (opens in a new tab)
Information as of November 17, 2026. Laws and offers can change; this article is not legal advice.
Read more
Try it now
The trial lesson with examples for Software developer. No account, a few minutes.
Start the trial lesson