TECH

Designing Agentic Workflow

Designing Agentic Workflow

AI is an amazing tool, especially when it comes to writing code. But it is also fundamentally different from what we, as programmers, are used to. This becomes even more visible when we use AI in the form of autonomous agents that generate application code based on our instructions and requirements.

After the initial excitement around vibe coding, the first structured approach to solving the problems we quickly began to encounter emerged: Context Engineering.

Fighting Entropy

LLMs, much like people, perform poorly when they have too little information, but also when they have too much. There is a sweet spot between insufficient and overloaded context where AI works best.

This applies both to the temporary context that agents build up while working and to the more "permanent" context made up of application code, documentation, and saved prompts, skills, or instructions.

If left unchecked, the quality of this data degrades over time. Just as an apartment becomes messy all by itself! Entropy in an isolated system tends to increase.

A Probabilistic World

Agentic coding tools are intentionally non-deterministic. The same task, run twice on the same codebase, can produce very different results.

Those differences become larger when the instructions are less precise, there is more room for "interpretation". This can lead not only to inconsistency in code style, but also to unpredictable efficiency: first time AI completes a task in a few minutes, while next it may "grind" on it infinitely.

Designing a Workflow

As AI assisted development has matured, many frameworks have appeared to spread good practices and improve efficiency. Some of these techniques in the end have been built directly into coding tools themselves, such as Claude Code.

Let's look at the most common phases of working with AI agents. Understanding them will give you a solid foundation for designing your own workflow.

1. Exploration

This is the first step in building context: gathering requirements, reviewing designs, searching knowledge bases, and collecting information about the codebase. In short, checking everything that may be useful for implementation.

Every AI coding tool was built with automating this process in mind, but we can still help by manually pointing to related parts of the code, providing detailed descriptions, connecting ticketing or project systems that AI can pull information from, and preparing documentation or project instructions.

Just as we would try to make onboarding easier for a new programmer, we can do the same for AI.

2. Brainstorming

In other words, use AI to explore alternative approaches before moving into implementation. Ask it to suggest different ways of solving the task, and then identify the potential risks, trade-offs, or weaknesses of each one.

This can expose weak points we may have missed, but it can also improve the quality of AI's output itself. After all, that information becomes part of the context and guides further work.

This step is not always mandatory, but it is definitely worth keeping in mind.

3. Planning

Having AI prepare an implementation plan is one of the most important parts of the workflow, because it serves two purposes:

  • It allows the user to review the work while it is still in progress - a true human-in-the-loop checkpoint. This gives us a chance to verify that AI is heading in the right direction before it spends more time and tokens on implementation.
  • It narrows the context. During exploration, the agent reads files without knowing whether they contain relevant information. The planning step then distills what was found and moves forward only with the parts that matter.

4. TDD (Test-Driven Development)

Once we get to the implementation phase, the most important part is the feedback loop. Test driven development works especially well here, as long as the tests are written first. Otherwise, AI tends to write tests that fit the implementation, which significantly reduces their value.

TDD can be delegated to AI with confidence because the same principle applies here as with humans: we implement simple code to verify the more complex one.

And automated tests are not the whole story. Linters, code quality analysis tools, and tools that let AI inspect the results of its own work - such as Playwright MCP or the Chrome integration in Claude Code - all provide the essential feedback that makes TDD truly effective.

5. Retrospection

You can do this part yourself, or let the AI do it. If the AI had trouble, if you had to stop and correct it, or if it got stuck in a loop, ask it to summarize what happened.

That summary becomes a simple guide for next time. It shows how to solve similar problems and what to avoid doing again.

6. Self-Validation

This is another stage that should happen with a cleaned-up context. Let AI evaluate its own work with fresh eyes. It can check coverage against requirements, assess code quality, verify consistency with code style, and review documentation.

AI can absolutely perform a code review of its own work, as long as it is not operating in the exact same context that produced it.

7. Refinement

This is the most important step in the entire workflow.

At the beginning, we mentioned the gradual degradation of data and the growth of entropy. Refinement is one of the main ways to counteract that. You need to regularly review the relevance of project documentation, saved prompts, instructions, and skills. Whatever is considered your knowledge base.

This is also a good time to merge notes from retrospection back into the workflow.

The moment inconsistencies appear in the documentation is the moment errors begin to multiply.

How to use it?

However you like, really.

A good starting point is to write a few commands or Claude Code skills that handle the individual steps. You can also place these instructions in AGENTS.md if you want them to be part of the process by default, although personally I prefer having control over what gets triggered and when.

You can also apply these principles directly in conversations with your agents by focusing on phrasing the right prompts yourself.

So now you have the conceptual blueprint. It's time to mold it into a workflow that fits you (or your team) perfectly!

Przeczytaj więcej na naszym blogu

Sprawdź bazę wiedzy zebraną i opracowaną przez doświadczonych
profesjonalistów.
bloglist_item
Tech

Parę słów na temat użycia AI podczas pracy (gdzie jako pracę rozumiemy nie tylko kodowanie), aczkolwiek od kodowania zaczniemy, a konkretnie od często ostatniego jego etapu - code review oraz...

bloglist_item
Tech

##Jak wniosłem wkład do projektu open source, nie znając frameworka Jestem deweloperem Ruby on Rails z kilkuletnim doświadczeniem w różnych projektach i technologiach. Dwa tygodnie temu, po...

bloglist_item
Tech

You finally click Deploy. The terminal scrolls, CI is all green, and for a few seconds, you feel unstoppable. You open the app in production, click around, and everything seems fine. Then an...

ul. Powstańców Warszawy 5
15-129 Białystok
+48 668 842 999
SKONTAKTUJ SIĘ Z NAMI