Introduction
This material is meant to give an overview of best practices in software development. It’s kept on a general level to be relevant for people writing code in various different contexts. Hopefully you find it useful no matter if you are writing a little script to transform a set of data or a big web application for thousands of users. As this is written in late 2026 when already a lot of code is produced by AI agents rather than humans, we will look at the different practices from that perspective as well.
Structure
The field of software best practices is broad and this overview is meant to give a bit of everything. It starts with advice on details that is valid for basically every line of code and then goes into a bigger and bigger perspective. In the end, we will look at practices to follow on a project level and the whole process of software development.
The line level
There are three things to think about in every line of code. The purpose of all of them is to make your code as readable and easy to understand as possible.
Naming conventions
If there are conventions for naming things in the programming language you are using - follow those. This can be about the use of camelCase versus snake_case versus kebab-case, the use of capital letters or the naming structure. Try to make names as explanatory as possible. Preferably, a name can already tell the reader what to expect. For example:
- a function called “isLeapYear” will give you a boolean
- a variable called “yearsWithData” will probably be an array
Code style
Depending on your programming language there can be more or less freedom on how to deal with indentation, line breaks etc. The more freedom, the more important to limit yourself to a set of rules. Be consistent in how you format your code and preferably follow the conventions for your language. To make your life easier, use a linter for this: It’s a little program that you can provide with a set of formatting rules and that you run over your code and that will warn you if you don’t follow them. A formatter can even rewrite the code for you to match the rules.
The block level
These three concepts are good to have in mind when writing bigger chunks of code:
DRY - Don’t repeat yourself
When you find yourself writing the same logic that you already have written in another part of your code - try to make it reusable. Move the shared logic to a function, component, module or whatever would be the suitable alternative in your context and programming language. It will hopefully reduce the amount of code that you need to write, read and maintain and it will hopefully make your code more robust: If you later find that there was an error in your logic you have to fix it only in one place instead of remembering all the copies of it in the code. However, as with most of these rather general ways of thinking, you shouldn’t focus on it too strictly. Sometimes, moving parts of the code into reusable snippets can make the code overly complicated and harder to follow. That’s of course not the goal either. A good rule of thumb can be: It’s okay to repeat something once. When you are about to repeat it again it’s time to make it reusable.
KISS - Keep it simple, stupid
Try to make your code as easy to follow as possible. This will help future you and anyone else who wants to read and understand your code. Sometimes, it can be appealing to solve things in a particularly clever or abstract way but that isn’t necessarily the best way of solving things. Don’t aim for clever, aim for clear. Keep your solution as simple as possible, you’re not writing code to show off but to solve a problem.
YAGNI - You ain’t gonna need it
Only write the code that you need right now. Focus on the cases and problems you want to solve now, don’t try to imagine all kinds of other possible future use cases. If you don’t know for sure that you will need a certain piece of code, don’t write it. Again, this rule shouldn’t be taken too seriously: Of course it can be good to anticipate the future and try to prepare your code for use cases that you assume will arise in the future. But do this within limits.
Yes, it is. As long as you assume that you will read and maintain your code manually to some degree, it’s worth trying to keep the code easy to understand. The three principles mentioned all serve that purpose. Also, AI agents tend to break all of these rules when producing code: They repeat themselves, overcomplicate things and happily invent use cases that you didn’t ask for. So having these principles in mind is certainly important when dealing with code produced by AI.
The file level
When your code starts stretching over several files and becomes a project rather than just a script complexity rises. That makes it important to keep these two things in mind:
Write tests
When it comes to writing tests, there is a wide range of how people deal with it in practice. Some projects survive entirely without tests, others aim for a test coverage of 100% and want to have tests for every single piece of logic in the code. There is even the concept of test-driven development (TDD) where you start off with defining your test cases and writing tests and then write the code that will make the tests pass. You should try to find a middle ground here. In general, tests are helpful because they make your code more robust. For example, they will prevent cases where the code silently produces wrong results because you had an error in your logic. They can also ensure that new parts of your software work correctly together with already existing parts. Thinking about test cases can make you think about the edge cases that you might have missed when writing the actual code.
How do I know which parts of my code need a test?
If you find yourself testing a certain part of the functionality manually over and over again, that’s a good indicator that a test can save you time here. Also, if you once saw a part of your code break when you implemented another part, that’s a good point to add a test - even though of course you would rather have caught that before the error occurred. In general, more or less every test is better than no test. If the threshold of starting to write tests seems too high because there would be so much to test, just start with one test somewhere. After a while you will develop a feeling for what kinds of logic should have tests and which can go without.
Use lockfiles
The bigger your code project gets the higher the chance that you rely on some other libraries or packages. If you want others to be able to seamlessly run your code you should pin down the versions of these dependencies, preferably in a lockfile. The ecosystem for this looks different in different languages. In Python, you can create pyproject.toml to specify versions of dependencies. Package managers like “uv” and “pixi” read this and create a lockfile that contains the specific version of every dependency and sub-dependency used in your project. The most basic way to pin dependencies in Python is a requirements.txt file even though that’s not a real lockfile. Still it will inform anyone looking at the code which versions of dependencies should be used.
Software versions are typically specified using “semantic versioning” following the pattern major.minor.patch that results in e.g. v1.2.3. It can be common practice to not pin down the exact version down to the patch level but rather to specify “this or any higher available patch version”, or using a range, i.e. “higher than this but lower than that version”. You should find out what is reasonable and necessary in your context to make it possible for others to run your code.
Yes, maybe even more than before. If you let AI write your code, tests become part of your specification. AI can also write the tests for you (which actually might lower the threshold for you to start using tests). But it’s still you who needs to define the test cases, specify what’s needed and how the code should behave in certain edge cases. A test takes a limited input and compares the output to what would be the expected output. But only you can know for sure what that expected output would look like. Even lockfiles are still a good idea to use despite AI producing the code. Agents have a tendency to add dependencies to a project that might not be needed, or to use older versions of certain libraries than there are available. If nothing else, a lockfile will make this transparent so that you can catch it if it doesn’t follow your intention.
The project level
When your code becomes a bigger project best practices dealing with the process of software development become relevant. I’ll focus on five of them.
Containers
Lockfiles that pin down your dependencies improve the reproducibility of your code but they can still lead to different results for people running the code in different environments, e.g. a Linux computer versus a Mac. Containers solve this problem because they give you a whole “environment in a box”, including operating system libraries, tools and dependencies. Using containers thus makes it easier to collaborate with others on a code project and for others to run your code in their own environment.
Version control / Git
Version control makes it possible for you to track your changes and thus works like a safety net. If you break something there is an earlier, working version of the code that you can easily go back to. This safety net becomes extra strong if you not only use version control locally on your machine but also sync your repository to a remote place like GitHub. Version control lets you keep a working version of the code on a main branch while you are experimenting on new features on a separate branch. That also makes collaboration with others easier as you can work in parallel on different branches. If you work on a project that is already released and used by others version control will make it easy for you to track the changes that you have made to the software prior to every new release.
Pull requests and code reviews
If you use version control you can develop the habit of creating a pull request for every piece of new code that you want to add to your working version of the project. Before the pull request gets merged to the main branch you ask someone for review. Feedback from others will improve your code and give you the opportunity to learn which makes it extremely valuable for your personal development. Creating pull requests also helps you structure your work because it forces you to reflect on what pieces of code together become a reasonable chunk that you would want feedback for.
Automating checks
Many of the things that you do regularly during software development can be automated to free some of your personal brain memory: you don’t need to remember them because they happen automatically. Good examples for this are linting and formatting, building your code (in both development mode and production mode if they exist in your project) and running tests that you have written. Running all these checks regularly makes your code more robust because they will warn you as soon as anything breaks. Automating these checks is a core part of what is called “Continuous Integration / Continuous Delivery” (“CI/CD”) that has the aim to merge changes into the main branch and release them continuously instead of every now and then in big chunks. That only becomes possible because all checks are running automatically. GitHub makes it very easy to automate these by using GitHub Actions. They enable you to trigger checks by various events, for example with every commit, every pull request etc. You decide when to trigger what depending on your needs in every project.
Agile thinking
The core of agile thinking is to divide your work into smaller (and even smaller) tasks. Every task, when fulfilled, should add some value to the project. This way of thinking helps you structure your work and can make it easier to get going when what you want to build seems like a huge mountain of work just right in front of you. It also helps to identify what is the most essential part of what you are building, the simplest possible solution that still serves your biggest needs. Aiming for this “minimum viable product” will make it easier to achieve progress when working on a bigger software project.
- Containers - yes. No matter who writes the code, you still want it to be reusable for others.
- Version control - yes, even more. When agents produce your code the option to go back to a previous, working version becomes even more important. It also makes it transparent what the agent has changed when they do so.
- Pull requests and code reviews - yes, even more. If it’s not you who writes the code but an agent, the habit of letting others check it becomes even more important. Of course in that case you should always be the first person to review the agent’s code before you bother anyone else with it. Also, you can take advantage of agents doing a code review for you for those cases where you can’t identify anyone else who would be available for a code review.
- Automating checks - yes, even more important. When changes to the codebase happen quicker because the code is generated by agents the automated checks are a way of constantly checking your code’s quality.
- Agile thinking - yes, even more important. If you prompt an agent with a small and well-scoped task the result will most likely be more correct and useful than if you prompt it with a broad description of a whole project.
Comments
In general it’s good practice to add comments to parts of your code that can be hard to understand for others or future you. In those cases focus on the WHY. Explain why you are covering (or ignoring) a certain edge case or if there is any background knowledge necessary to understand why the code is written in a certain way. You can also add comments explaining WHAT will happen in the next lines of code. It’s a question of taste how much to use these. I recommend adding them when they function like subheadings would in a text. They should improve the readability of your code file and give orientation rather than producing noise.
Yes, it is. All of this advice has the goal to make your code more readable and easier to understand, no matter if you have written the code manually or let an AI produce it. As long as you assume that you will still read the code that an AI might produce for you it is worth following these best practices. Even AI agents reading your code will have an easier time understanding it correctly when the code follows these best practices.