Your Previous Agency Shipped Bad Code: Now What

Veld Systems||6 min read

You paid an agency $50K, $100K, maybe $200K to build your software product. They delivered something that technically works, but your new developer took one look at the code and said something along the lines of "this needs to be rewritten." Or maybe the product has been live for a while and it is slow, buggy, and expensive to maintain. Either way, you paid for professional work and got something that does not feel professional.

This is one of the most common situations we encounter. Not because agencies are inherently bad, but because the incentives in agency work often prioritize speed over quality. Ship it, bill it, move on. The technical debt becomes your problem, not theirs.

Here is how to deal with it.

Understand What "Bad Code" Actually Means

Not all bad code is equally bad. Before you commit to a rewrite, understand what kind of bad you are dealing with.

Bad but functional. The code works, users can use the product, but the codebase is messy. Inconsistent naming, no tests, duplicated logic, poor file organization. This is the most common type. It is annoying and it slows down development, but it is fixable incrementally. You do not need a rewrite. You need a disciplined refactoring plan and a team that cares about code quality.

Architecturally flawed. The code works today but cannot support what you need tomorrow. The database schema does not support the queries your product needs. The API was designed for 100 users and you have 10,000. Authentication is hand rolled and has security holes. This is more serious. Some architectural problems can be fixed in place. Others require rebuilding significant portions of the system.

Security liability. SQL injection vulnerabilities, unencrypted passwords, exposed API keys, no input validation. If your agency shipped code with these problems, your first priority is fixing them, not discussing long term strategy. Check our web app security checklist for the critical items. Every day these vulnerabilities exist in production is a day you are exposed.

Built on dead technology. The agency used a framework that is no longer maintained, or a language version that is end of life. This is not the agency's fault if the tech was current when they built it. But if they chose an obscure or dying stack in 2024, that is a competence issue.

The Audit: What to Look For

Before deciding what to do, run a proper audit. This should take 1 to 2 weeks and cover:

Performance. How fast do pages load? What do the database queries look like? Are there N+1 queries, missing indexes, or unoptimized assets? Performance problems are often the most visible symptom of underlying code quality issues. Our performance optimization guide covers the key metrics.

Security. Run automated scans (OWASP ZAP, npm audit, Snyk). Check authentication flows manually. Look for hardcoded credentials. Verify that user input is sanitized everywhere.

Maintainability. How long does it take a new developer to understand the codebase? Is there documentation? Are there tests? Is the code organized logically? Can you set up a local development environment in under an hour?

Scalability. What happens when traffic doubles? Are there bottlenecks in the database, the API, or the frontend? Is the infrastructure configured to auto scale, or will it fall over under load?

Dependency health. Are packages up to date? Are there known vulnerabilities in dependencies? Are there abandoned packages that need to be replaced?

Deciding What to Save

Here is the honest truth: rewriting everything from scratch is almost never the right answer. Even bad code has value. The business logic encoded in that codebase represents real decisions about how your product works. Throwing it all away means re making every decision, and you will make some of them wrong the second time too.

Always save: The database and its data. Your users, transactions, and content are valuable regardless of code quality. Even if the schema needs work, migrating data is almost always better than starting over.

Usually save: The business logic. Even if it is poorly implemented, the rules for how your product works (pricing calculations, workflow state machines, permission models) represent hard won knowledge. Extract and reimplement rather than reinvent.

Sometimes save: The frontend. If the UI works and users like it, keep it. Refactor the component structure and add type safety, but do not rebuild screens that are already working well.

Rarely save: Hand rolled infrastructure, custom authentication systems, and bespoke ORMs. These are almost always better replaced with established tools. Supabase vs. Firebase, managed auth vs. custom auth, established ORM vs. raw queries, use the tools that thousands of developers have already debugged.

How to Avoid This Next Time

The mistakes that led to bad agency output are predictable and preventable.

Require access to the codebase from day one. If an agency will not give you access to the Git repository during development, walk away. You should be able to see every commit, every pull request, and every code review. This single requirement eliminates most of the worst outcomes.

Insist on automated tests. Write it into the contract. Minimum test coverage percentage, required for every feature. An agency that pushes back on testing requirements is telling you exactly how they plan to cut corners.

Demand weekly demos of working software. Not mockups, not slide decks. Running code in a staging environment. If the agency goes more than two weeks without a demo, the project is off track, regardless of what their status report says.

Check references by talking to the engineering team at past clients, not just the CEO. The CEO will tell you the project launched on time. The engineering team will tell you they spent six months cleaning up the code afterward.

Choose a partner, not a vendor. The agency model where you throw a spec over the wall and get code back three months later does not work. You need a team that asks hard questions about your requirements, pushes back when something does not make sense, and treats your product like their reputation depends on it, because it does.

The difference between a vendor and a partner is what happens after launch. A vendor disappears. A partner provides ongoing management and continues to maintain and improve the product. This is the difference between "we built your software" and "we are responsible for your software."

The Path Forward

If you are sitting on a codebase you do not trust, here is the practical sequence:

1. Get an independent audit (not from the team that built it or the team that wants to rebuild it)

2. Fix security issues immediately, everything else can wait

3. Set up monitoring and alerting so you know when things break, observability is non negotiable for production systems

4. Create a prioritized refactoring roadmap based on the audit findings

5. Execute incrementally while continuing to ship features, do not stop all product work for a months long rewrite

The biggest mistake we see is companies swinging from one extreme to the other. They had a bad experience with one agency, so they try to build an in house team. In house teams are great, but building one takes 3 to 6 months and costs significantly more, as our in house vs. agency comparison details. The better approach is to partner with a team that can stabilize the codebase now while you build internal capabilities over time.

If your previous agency left you with a mess and you want an honest assessment of the damage, talk to us. We will audit what you have and tell you exactly what it will take to get it where it needs to be.

Ready to Build?

Let us talk about your project

We take on 3-4 projects at a time. Get an honest assessment within 24 hours.