Building a Solana project with an LLM

A colleague of mine tried an experiment: have an LLM agent write an entire Solana smart contract and barely look at the code along the way. Then I reviewed what came out. The code was good overall, at least compared to typical human-written code in this area, but the same kinds of mistakes kept recurring.

Below are the pitfalls you can run into when developing with LLMs.

This article is not a critique of LLMs. I believe all of the problems described here are manageable. The aim is to show, with a few real cases, where LLM-generated code still needs a developer’s attention.

The project

The project is medium-sized by the standards of smart contract projects.

All of it is LLM-generated, including the tests and the deployment scripts. My colleague described the features, accepted what the agent produced, and rarely opened the code. I never saw the prompts, so I could only judge by the code. A few context files remained: a project overview with a suggested breakdown into files, and some guidelines for the business logic.

Comments that refer to the previous code

a066a7b6555594e6279c9474acdd52e63.pi-fix.png

LLMs are known for verbose comments. A less obvious habit, which shows up as the project evolves, is how much they like to explain their fixes. Even when a change is trivial and the result is the only sensible option, you can find several lines of comment defending the new version, mentioning what the code used to be and why the fix matters so much.

This is largely a junior developer’s habit. It is tempting at first, but the code soon fills up with comments nobody needs, and for the sake of future maintenance you learn to delete them. A comment should explain why the code is the way it is, and only where the code would surprise a reader who expected the straightforward solution.

Left unattended, comments that justify past fixes grow into walls of text that hide the essential parts. As a reviewer, I also find that they make my job considerably harder.

Inconsistencies between parts of the code

Some parts of the code made wrong assumptions about other parts. Where a variable’s purpose wasn’t documented, code elsewhere sometimes used the wrong variable. A 100-line bash script promised an important check in its header comment and never performed it.

What surprised me most: CLAUDE.md forbade using a plain wallet key as the admin and suggested a program-derived address. Code written later ignored this completely.

a94897f3dfa4dd57f0903f3c5c88a7efb.dont-forget.png

LLMs are known to lose track of instructions as the context grows, and every lossy context compaction can drop a few more. That would explain these cases.

Ironically, attention to detail is where I like to have an LLM at my side, as a second pair of eyes, so that between the two of us nothing slips through. To actually get that today, I’d run separate sessions dedicated to consistency checks, rather than hope the agent writing the code catches everything along the way.

Dummy tests

How do you feel about tests that:

  • run against their own simplified copies of your functions;
  • end up testing only the standard library;
  • verify the input parameters rather than the behavior;
  • read the source code to make sure the required assertion is there (I wouldn’t have believed it if I hadn’t seen it myself);
  • have to be synced with the source code by hand to preserve coverage?

Skipping the review of generated tests is tempting, and from what I see, it’s a common habit in the industry, though hand-written tests got skipped too.

If you skip them and don’t use a dedicated test-generation skill, sorry for adding to your nightmares.

I wouldn’t call any of this dumb; these are beginner’s mistakes. Copying the source code and testing the copy, for instance, is tempting at a certain stage of a programmer’s growth. Later you close that chapter and try to forget it ever happened. Here, a little practical experience goes a long way, and an LLM still has to borrow it from someone.

A story from my own practice: I once explicitly asked Claude to prefer end-to-end tests, and it still wrote unit tests and called it a day. When I asked why, it answered that writing a test harness seemed like an overcomplication. So I wouldn’t let it write tests unsupervised.

Insufficient test coverage

Even if you ask an LLM to cover every new feature with tests, gaps can remain.

I can’t say for sure, but judging by this experiment project, even a dedicated test generation session may miss basic edge cases. What worked much better was asking the LLM for a test plan before any tests were written.

At Serokell, we treat testing as part of the developer’s responsibility, and that responsibility cannot be handed over to an LLM yet.

Uneven attention to detail

Every codebase has details that need deliberate care. The LLM handled most of them well and ignored a few.

In this project, the neglected one was error codes, which I always fuss over. Some error codes became catch-alls: InvalidArgument covered several unrelated problems. Worse, malformed input and a concurrent change of the contract state raised the same error.

As a result, the off-chain client can’t tell whether a transaction failed because of its own bug or because the state changed and a retry would do. While you’re focused on the contract itself, this is easy to overlook.

This is the kind of rule that belongs in a project’s coding guidelines, where developers and their agents will both see it.

Overcomplication

One feature took several rounds to implement: some designs ran into the platform’s memory limits on real data, others turned out to be partially incorrect. The agent found these flaws itself and proposed alternatives, and my colleague picked the direction. The result is more complex than a from-scratch design would be: new code sits on top of parts that had mostly become obsolete.

With no one reading the code between the rounds, no one asked for a refactoring, and the agent didn’t volunteer one.

This and some of the issues above suggest that the agent could keep only a few modules in focus at once. Beyond that, it lost the full picture: new code piled up on top of old, and parts of the project stopped agreeing with each other. A large feature can exceed that limit on its own.

I’d suggest at least asking for a refactoring after several rounds of changes to the same code, though architectural decisions like these are probably better left to a human.

Architectural concerns

Some functions were built around the wrong primitive.

One example is a user-facing endpoint that did too much off-chain: it computed the new contract state from a snapshot and wrote the result back on-chain, overwriting whatever another user had changed in the meantime.

Bugs like this tend to pass the tests and show up only after deployment, once real users hit the endpoint at the same time. It’s a class of issue that experienced reviewers learn to look for; an LLM needs it written down as a known pitfall and checked for.

Where it performed well

Some areas the LLM handled better than I expected:

  • Following the unwritten coding practices of the smart contract language and avoiding its common pitfalls.
  • Math utilities. What matters here is avoiding overflows and understanding the formulas in general. It almost got them right: the backbone was ported from a library in another language, and a few overflows slipped through in edge cases where the original’s numeric types had wider ranges.
  • Tests. Once you have a sound plan, handing the bulk of test writing over to someone (or “someit”) is a blessing. You only need an easy way to check that the plan is followed as expected.

Conclusion

An LLM is often compared to a gifted child: it knows a lot and can do a lot, but it needs guidance.

My colleague’s experiment showed what happens without that guidance: decent code overall, but with beginner’s mistakes repeating throughout and inconsistencies that caused real bugs.

A fresh agent assigned a single job, like a consistency check, would probably catch the inconsistencies. The rest took someone who had once made the same mistakes.

Left unchecked, such mistakes compound. Each new feature lands on top of the inconsistencies left by the previous ones, so the longer an LLM codes unsupervised, the faster the project slides toward being unmaintainable.

You still need to know what you are doing. LLMs don’t take that off your shoulders, at least not yet.

Building a Solana project with an LLM
Banner that links to Serokell Shop. You can buy hip FP T-shirts there!
More from Serokell
How to build a smart contract on Solana |SerokellHow to build a smart contract on Solana |Serokell
TON guideTON guide
Why Solana Chose Rust: Greg Fitzgerald on Haskell & Systems | SerokellWhy Solana Chose Rust: Greg Fitzgerald on Haskell & Systems | Serokell

Paris, France52 boulevard de Sébastopol, 75003

Tallinn, EstoniaPille tn 7/5-13, Kesklinna linnaosa,
Harju maakond, 10135

2015–2026 SerokellLegalPrivacy Policy