Estimate project
← All posts

How I Found My Way to Agentic Coding

The sheer volume of AI tools and news can be overwhelming. Still, if we want to stay ahead, each of us has to keep growing, test new tools, and experiment. People once laughed at those who used an IDE – a good, fast editor was all that counted – but the world has moved on, and an IDE is no longer a luxury.

10 min read
Machine LearningAIAgentic Coding

I got interested in AI quite early. I recall attending a conference in Belgrade in 2016, where chatbots and the way they were going to change the world were a hot topic.

It was also there that I first heard about IBM’s Watson – one of the earliest AI tools, even though nobody called them that at the time.

First steps

I recall my first tries at hooking Watson up to our company bot to make communication better. They were awkward attempts to bend AI to my goals, and since I’m not an ML engineer, many concepts were simply beyond me. It wasn’t a system for everybody – using it required a certain amount of ML know-how.

I recall how amazed I was by what AI could do when ChatGPT came out. I suspect I wasn’t alone in being fascinated by AI’s power. Going from Watson to ChatGPT felt like trading one old car for a slightly better old car.

ChatGPT simply worked – you asked something and received an answer, with no complex programming tricks needed – a tool for everyone!

Right away, I hooked it up to our company bot to make it “smarter”. The integration did a great job in casual conversations. You could ask questions straight from our Slack and talk with the bot in a thread, and people still do that today.

What I lacked, though, was contextual knowledge of what the bot itself was able to do – and it had quite a few functions that supported our company’s work. Trying to tailor ChatGPT so it would better understand how our company works was every bit as hard as it had been with Watson.

Still, I was amazed by ChatGPT’s ability to generate code (at that point still inside the chat window) and by how well it could explain the intricacies of code, particularly in a language I didn’t know (I was learning TypeScript back then).

Naturally, I soon noticed that AI gets things wrong or, as we say today, hallucinates. Once pasted into the IDE editor, the generated code often turned out to be buggy, failed to compile, and so on. So I’d return to the chat window and laboriously try to get a working result, copying one version of the code after another into the editor and checking whether it worked.

Finding out that ChatGPT could write Python code and execute it was a revelation to me. It let me work faster: I generated a solution in Python, tested it on ChatGPT’s side, and then had the AI translate it into TypeScript – which, as you might guess, didn’t work very well. But it did let me experiment more quickly with what worked and what didn’t, and if memory serves, this feature is still there.

AI-assisted coding

The biggest thrill probably came when Copilot launched a plugin for IntelliJ IDEA that brought AI directly into the IDE, both as a chat and as code completion. The jump in productivity was astonishing, like a fine wine.

A few keystrokes were enough to produce dozens of lines of code. Whole functions and classes popped up as if by magic – thousands of lines in a matter of minutes, along with generated unit tests that checked it all. The sense of being supercharged by AI kept growing – it felt like anything was possible.

Reality caught up with me fast, though, and left me with a nasty headache…

The generated code was of good quality, but its implementation was very naive whenever the problem got more complicated. The AI tended to get stuck in “repetition loops” of whatever already existed in the code, new functions were really copies of existing ones, and hitting “Tab” too eagerly meant spending long minutes tediously removing redundant or duplicated fragments. Productivity dropped quickly. In the end, I switched this feature off, as it distracted me more than it helped me write good code.

My next step in building AI skills was Claude Code. It marked another milestone in code generation. The AI no longer naively proposed code snippets or produced chunks of code from my prompt. You could describe the problem, give it context (such as a particular file containing a class), or point it to where it should take “inspiration” from.

Claude Code took time to prepare TODO lists – the well-known TODOs that other vendors copied later on. With a task list in hand, it would pause and ask whether this was what I wanted and whether the proposal met my requirements. That was amazing, because it gave me a feeling of control over what the AI produced. At last, it wasn’t random code sprinkled all over the place, but a genuine plan of action that looked very much like our everyday work – planning tasks in a sprint or a backlog.

Yet even here, I ran into a “wall” with prompting. Picking up earlier sessions to finish a bigger feature got less and less effective. All the information piling up in the context made the AI itself “wander off,” and it was also hard for me to tell what we were actually building at that point and how far along the plan we were – put plainly, we were “lost in the woods”, as the saying goes. Prompting just didn’t cut it for more complex problems.

Context is everything

Grasping how AI works – or more precisely, which prompts the agent generates before we even type ours – is essential to knowing how to steer the tool’s behavior. Our prompt is just one part of what the agent has already set up. You can see this clearly with the /context command in Claude Code:

I haven’t typed a single word, yet the context is already 40% full – I especially suggest looking at the System prompt and System tools, which are outside our control. MCP servers and subagents, on the other hand, we can define and control ourselves.

Likewise, what goes into the CLAUDE.md file is entirely up to us. System prompts of various agents can be found online, and I suggest getting to know them to see how our prompts can shape AI behavior. And keep in mind that AI isn’t deterministic – there’s always some randomness in how it operates.

With this knowledge, I began investing more time in crafting the right prompt, particularly when a task called for more than a few functions and unit tests. More and more often, my prompts began by asking for a plan and refining it before letting the Agent write code. I spelled out the requirements – what I needed and what could be left out.

Telling the AI what you don’t need matters just as much – AI is extremely good at “drifting” away from the requirements. An implementation plan, a migration plan, time estimates for a team that doesn’t exist – the AI will produce all of these unless you forbid it. You don’t even need to request them – they’ll just show up in your otherwise perfect plan and spoil it – because they’re “garbage” that pointlessly “distracts” the AI from what matters most.

Plans are important, but following the plan is more important

The heading above pretty much says it all. Once I had a plan ready, I’d hand it to the AI to implement – with a plan, surely it would stick to it and not “get lost”. I was sure that at this point the machine would carry out its work according to the program it was given, since that’s how I saw the plan.

Have I mentioned that AI isn’t deterministic? I’ll say it once more – it isn’t, and even the best plan can get distorted, with important parts skipped. Why? Because of context – our plan lands in the context and adds to what’s already there, like the System prompt and the rest.

As time goes on, the AI’s own responses also pile up in the context – code snippets, web searches, replies containing documentation. Thousands of lines of text with little connection to our plan. The plan gets watered down by the “noise” the agent produces. All this noise makes the AI stop “understanding” what matters. Stopping and clearing the context doesn’t help either, because when we start over with the plan, new “noise” gets generated, and since it differs from the previous noise, the results differ as well – pure “chaos”.

What worked was splitting the implementation into phases. For that, however, the plan itself needed steps describing what to implement and in which order. To prepare a plan split into phases, I had to narrow the scope properly and cut out everything unnecessary. Restricting what goes into the plan and what the AI should concentrate on matters as much as describing the requirements precisely.

Saying explicitly that I didn’t need time estimates for my team, AWS infrastructure costs, or deployment and migration plans let me trim the plan down so it focused only on coding.

These days, Spec-Driven Development is being discussed and written about more and more. It’s not a new idea, of course, but when working with AI, it matters enormously. Writing a concise PRD document and then deriving a technical specification from it gives far better results than simply writing a good prompt.

Tool vendors have picked up on this too, promoting this approach or offering tools such as Spec Kit or OpenSpec. We write clear instructions for the AI and document our project at the same time. It won’t be long before ADR gets created this way too, so that AI can easily “digest” it.

Naturally, this approach works best for greenfield projects, but Spec-Driven Development can be applied in brownfield projects as well, with real benefits – it beats endlessly polishing our prompts.

Continuous development

I arrived at most of these conclusions largely by trial and error, trying out various techniques in projects and testing my ideas against those of others at the company.

It would have been far better to be able to learn right away from people who had already run into these problems and had answers ready. Training courses are the obvious solution, but there are thousands of AI-related courses on the market right now, and picking one that fits our needs is hard.

I’m fortunate to work at a company that puts a strong emphasis on growth and encourages people to take part in training. On top of that, two Scala experts ran the Efficient Programming in Scala with Friendly Agents workshop at this year’s Scala Days.

Later, they ran the same workshop internally for people from our parent company and our company. If I had to sum up what I learned there in a single sentence: it was everything I had worked out on my own over the past 6 months and described in the paragraphs above.

The workshop focused on using AI tools in practice in a Scala programmer’s everyday work. We went over automation, scripts, writing prompts, and how to make sensible use of agents and the various tools that support writing and refactoring code.

We also talked about what large language models can really do and how they affect a programmer’s work, showing how to avoid buying into common AI myths. Together, we tried out AI workflows, integrated tools, and even attempted to automate migrations of bigger Scala projects – all in a spirit of experimentation and knowledge sharing. The 2x 8 hours I spent there were very well invested. If you get the chance to take part in this workshop, I recommend it.

Another kind of training is an online course on AI-assisted development – this is its second edition, and the first one got very good reviews. I’m halfway through the course right now, and it’s already hard to say how much I’ve learned.

Still, the range of material we’re going through and the introductions to each new part line up closely with my own experience and very often deepen my knowledge in areas I believed I already knew well. There’s a strong focus on writing good prompts (prompt engineering) and on preparing plans for AI.

Summary

AI is evolving more rapidly today than the JavaScript ecosystem did back when a new framework or library showed up every week. Right now, keeping track of all the tools hitting the market is tough. And because the LLM models offered by the big players are available to everyone, anybody can build all sorts of tools.

New ideas and approaches to using AI in a programmer’s work keep popping up all the time. And that’s just my own “bubble,” shaped by fellow programmers – the same progress is happening in every field, from generating text and images to producing full-length films.

The sheer volume of AI tools and news can be overwhelming. Still, if we want to stay ahead, each of us has to keep growing, test new tools, and experiment. People once laughed at those who used an IDE – a good, fast editor was all that counted – but the world has moved on, and an IDE is no longer a luxury.

AI in our work as programmers will go the same way – it’s not just “bells and whistles” (even if some of it looks that way), but a tool that keeps evolving.