creating code, you usually want to check it earlier than pushing to the event or manufacturing surroundings. Nevertheless, ready for a deploy with GitHub actions, or CDK stack deploys with CDK, is time-consuming.
Such time-consuming duties kill iteration pace, which is a crucial issue if you wish to develop code successfully. It’s because you have to take a look at your implementations correctly to make sure they work. Then, after every change, you have to take a look at it once more.
With the most recent coding brokers, creating full native testing scripts is tremendous quick, and one thing I do day-after-day as I write code as an information scientist.
On this article, I’ll take you thru why you have to create an environment friendly native testing setup by operating a Docker picture and sending take a look at occasions. I’ll additionally present how I do it myself, and the way it helps me grow to be a extra environment friendly engineer.
I’ll largely be speaking about the way to work with Infrastructure as Code (IaC), as a result of that’s largely what I’m working with on a day-to-day foundation. Nevertheless, the idea of effectively operating your code domestically applies to all programming.

Why you have to run code domestically
Firstly, I wish to cowl why we have to run code domestically. The straightforward reply is that:
Iteration pace is among the most vital points for effectively getting working code to manufacturing
The quicker you may iterate in your code, the higher. Once you develop new performance (or repair previous performance), you wish to shortly take a look at if it really works, after which iteratively repair the code till it really works as supposed.
If you must wait 5-Quarter-hour on your code to deploy earlier than testing it, you might have a significant issue. Each time you’re not capable of one-shot an issue, you waste 5-Quarter-hour merely ready for the deploy.
As a substitute, it’s best to run your code domestically. For instance, for those who’re working with IaC, resembling AWS CDK, you may construct and run Docker photographs domestically, basically replicating the manufacturing surroundings, however by yourself pc. This fashion, the iteration loop is easy, and the time it takes to construct the Docker picture and run the code.
Constructing the Docker picture is often very quick, contemplating Docker caches earlier builds. Thus, most of your time might be spent operating the code with take a look at enter and verifying the output is as anticipated.
Should you’re engaged on an online utility, it’s best to (and doubtless are already), operating the appliance domestically, earlier than deploying your code. There must be no distinction when working with IaC.
Tips on how to develop domestically as if it have been a manufacturing surroundings
An vital facet when creating domestically is that you simply’re capable of intently replicate the manufacturing surroundings. Should you’re writing IaC, constructing Docker photographs, and operating the Docker picture domestically:
You might be testing with the very same code, with the identical enter paths, and for those who mirror your .env file to the manufacturing .env file, you additionally mirror the entire variables. Thus, operating Docker photographs domestically is the best way to go if you are able to do that.
Create native scripts with coding brokers
Earlier than the discharge of coding brokers like Cursor and Claude Code, it was often a tedious activity to arrange code to run all the things domestically. You wanted to construct the Docker picture accurately, set it to run together with your .env file, and so forth. Otherwise you would possibly wish to run your code domestically as a FastAPI server as a substitute, wherein case you confronted comparable challenges.
This isn’t a problem anymore, nonetheless. To begin operating domestically, I often present Cursor the next instruction:
Create a shell script for me to run this code domestically. The shell script
ought to run the docker picture, and have an optionally available --build flag, which builds
the docker picture earlier than operating it. The docker picture ought to load surroundings
variables from the .env file.
This creates an environment friendly shell script you should use. I just like the optionally available –— construct tag, as a result of it’s generally time-consuming to construct the Docker picture, and I don’t all the time must construct it earlier than operating.
Additionally, the next elements permit me to run the script simply:
- I by no means retailer precise secrets and techniques in .env. I solely retailer secret references, which my code then picks up from AWS Secrets and techniques Supervisor. Thus, I can push my env file with none fear of leaking secrets and techniques. Moreover, this makes it simpler for others to run the scripts as nicely when pulling the code from GitHub
- I create one other file with take a look at occasions, the place I can simply ship occasions to the operating Docker picture. This fashion, I can simply test the enter and output
- I deploy the testing scripts to Git, so everybody else additionally has entry to them. This contains the env file as talked about, because it doesn’t comprise any secrets and techniques
Now you might have the precise setup you have to run and take a look at your code domestically. Each time you make modifications, you rebuild the Docker picture and ship the take a look at occasions, guaranteeing that all the things is working as supposed.
I like to recommend establishing these native testing scripts for all of your repos and pushing them to Git for sharing. Getting access to these scripts will make your whole staff extra environment friendly as programmers.
Additional tricks to run domestically
I additionally wish to share two extra tricks to be much more environment friendly, given these native testing information:
- Run and take a look at Docker picture with pre-commit hooks
- Give your coding agent entry to those scripts
Pre-commit hooks
Pre-commit hooks are code that runs earlier than each decide to git. Typical pre-commit hooks embrace:
- Run black . for formatting
- Run mypy for kind security
- Run pytest exams to ensure all exams go
Having a pre-commit hook ensures you always remember to run any such instructions earlier than pushing your code. That is extremely helpful and an important timesaver. It’s arduous for me to rely the variety of occasions I forgot to run black formatting earlier than committing, and the deploy exams find yourself failing 5 minutes later, costing me a variety of time.
If constructing, operating, and testing on the Docker picture shouldn’t be tremendous time-consuming, I like to recommend additionally including this to the pre-commit hooks. This fashion, you assure that earlier than you push any code, you’ve examined that the code runs in a manufacturing surroundings, and that you simply get the anticipated output for a given enter. Implementing this as a pre-commit hook will seemingly prevent a variety of time sooner or later.
Give Cursor entry to testing scripts
The second tip is that I all the time present Cursor and Claude Code entry to run my testing scripts. I then inform Cursor to run the testing scripts after making modifications, and earlier than ending its present implementation.
Having your coding agent run and take a look at Docker photographs will vastly enhance the quantity of occasions it’s capable of one-shot an implementation
This can prevent a variety of time when your coding agent implements a characteristic, after which you must manually run and take a look at the Docker picture. Should you now encounter an error, you must paste that into your coding agent, and the cycle repeats till the code is working.
It is a waste of time, and one thing it’s best to work arduous to keep away from. Giving your coding agent entry to the testing scripts is basically like handing your coding agent a instrument, which strongly improves efficiency in software program engineering duties. I can’t stress sufficient how a lot time this protects me.
Conclusion
On this article, I’ve mentioned how one can create life like manufacturing environments domestically by creating scripts to construct, run, and take a look at Docker photographs domestically. Doing this lowers iteration pace, which is a crucial part of being an environment friendly programmer. Moreover, I lined how I do that in observe: by prompting Cursor to create the testing scripts, and a few instance occasions I can run on the Docker picture. I then give Cursor and Claude Code entry to run these scripts, making my programming vastly extra environment friendly.
I consider that having a fast iteration pace is crucial for nearly all software program engineering duties, and it’s one thing it’s best to try for. Creating native take a look at information and giving your coding agent entry to them will increase iteration pace loads, which is why I consider that doing so myself has vastly elevated my productiveness as a programmer.
👉 My Free Assets
🚀 10x Your Engineering with LLMs (Free 3-Day E-mail Course)
📚 Get my free Imaginative and prescient Language Fashions e-book
💻 My webinar on Imaginative and prescient Language Fashions
👉 Discover me on socials:
🧑💻 Get in contact
✍️ Medium
















