Everything, but not at once: the art of focused decomposition

If you find yourself not getting useful results when interacting with AI tools and wasting time in cycles with the agent, don't rush to become a skeptic. Try applying the tips from this article. In addition to the main topic, we will touch on techniques that will help improve your experience when interacting with agents.

Hello, I am Peter – a developer of the "Sovcombank Investments" application for Android.

In our team, we actively adapt approaches to the use of various AI assistants for the Android development of our applications and beyond. Mostly, we use language models deployed within the bank's environment, which imposes certain limitations, but at the same time provides opportunities for practical experimentation.

In this article, I will share an idea that I came up with during my search process. I hope it will help you avoid the mistakes my team faced. If, during your interaction with AI tools, you find yourself not getting useful results for a long time and wasting time in cycles of interaction with the agent, don’t rush to become a skeptic. Try applying the tips from this article. In addition to the main topic, we will touch on techniques that work well with the described approach and can enhance your experience when interacting with agents.

Expectations from Agents

You have probably heard stories about "vibe coding," about entire applications that seemingly emerged by themselves thanks to AI, or about the mythical "agent that accelerates development by X times." But the reality looks different.

To practically achieve that very "AI efficiency," it is essential to clearly understand what work or part of it can be delegated to the AI agent.

If you give artificial intelligence a vague request like "implement a feature for displaying stock market charts," it will generate hundreds of lines of code. Then you will spend an hour or two debugging, trying to understand why nothing works. The essence of the problem lies not in the AI itself, but in how we use it.

In what cases can working with AI not yield the desired result?

  • If you expect the agent to provide a holistic architectural solution, while it works better with clear, localized tasks – ideally with steps.

  • You do not provide enough context: you do not specify existing patterns, you do not explain the system's limitations.

  • You overload the context: too much introductory information is not always good. Due to the overload, the agent starts to "hallucinate" and gets lost in its actions.

  • You skip verification stages, hoping for a "magical" result from the first request.

If you are engaging in any of the above actions, try to proceed as follows:

  1. Break down the large task into subtasks, ideally steps. Each prompt should be perceived as a specific, measurable subtask.

  2. Check the result of each step before moving on to the next.

  3. Give the AI context: code examples, errors, requirements.

  4. Iteratively refine and correct, rather than generate everything from scratch.

Today, some agents, such as Kilo Code, are already capable of independently building a plan to implement a large task. You can follow it by selecting the context deemed appropriate by the agent from those available in the project. While this improves the result, it does not eliminate the need to manage the agent in a way that brings you the desired outcome, solving the task.

Over time, we will see more advanced and autonomous agents. However, until that future arrives, it is necessary to pay attention to the analysis and decomposition of large tasks so that agents assist rather than become a cause of wasting such valuable time and your tokens in vain.

The Problem of Large Tasks

When assigning a large task to AI, many expect it to act as an experienced developer who, from the very first request:

  • Completely understands their codebase

  • Knows all the agreements accepted by the team

  • Is familiar with the subject area of the project

  • Takes into account the architectural decisions made

This is unrealistic. Modern research shows: when AI tools attempt to work with complex multi-step tasks, their effectiveness noticeably decreases.

Typical problems:

  • The model begins to make unfounded assumptions

  • The context of previous steps is lost

  • The generated code appears correct but does not meet actual requirements

Make an analogy: You are unlikely to ask a new team member on their first day to completely redo the deep linking system in your application. So why expect this from imperfect agents who are still newcomers in our ranks?

Conclusion: Instead of monolithic requests, it is better to break tasks down into understandable, manageable steps. This will reduce the load on the model, errors will be identified earlier, process control will be clearer, and the feedback loop with the agent will accelerate. As a result, the quality of the outcome will improve.

Solution: decomposed prompting

Decomposed prompting or DecomP for short is an approach in the field of prompt development, where a complex task or problem is broken down into smaller, clearly focused subtasks. Instead of giving one large monolithic instruction, you create a sequence or tree structure of prompts, each responsible for solving a specific subtask. Each of these can be processed with a separate prompt.

This solution helps the model to better focus on the current step, reason more consistently and reliably, and avoid information overload.

For different types of subtasks, it is permissible to employ specialized agents – separate AI models or modules optimized for specific types of tasks.

The key principle of the approach lies in representing the task not as a "black box," but as a sequence of transparent and controllable steps that solve specific problems.

Example of focused decomposition

Instead of asking the agent to solve large-scale tasks, try asking it to help with specific, narrowly focused subtasks. Here’s how this looks in practice:

Unsuccessful approach:

— Fix the input error of the short code during client registration

More successful approach:

— Look at this error message. What is its cause?
— Here is the code for MyGlitchyRegistrationApp.kt. What needs to be changed?
— Write a test that confirms the fix works.
— Make a commit with a description of the changes, specifying what the problem was and how it was fixed.

Each step is small, has a clear goal, and leads to the desired outcome.

Why does this work better?

By using DecomP, we:

  • Reducing cognitive load. The agent does not try to handle multiple tasks at once, but focuses on what is truly important right now.

  • Maintaining control. Instead of checking hundreds of lines of generated code, we analyze small, targeted changes.

  • Ensuring error localization. If something goes wrong, it happens in a small isolated fragment that is easy to fix or regenerate.

  • Learning faster. Each interaction shows what tasks the agent is really good at and where it needs help from us.

Key aspects

Not all programming tasks are equally well-suited for working with AI. I suggest dividing them into three types:

Type 1: Narrow, straightforward tasks

For example, removing feature flags, writing unit tests for specific functions, or generating boilerplate code. The agent handles these very well, as there is usually one correct answer and minimal context is required.

Type 2: Specific tasks requiring context

For example, debugging a specific bug, refactoring a function according to your templates, or optimizing a specific query. The agent can perform such tasks, but it needs to be provided with the necessary context: show the error, templates, and relevant examples.

Type 3: Large, open-ended tasks

For example, implementing the ability to view a news feed or adding photo uploads. Such tasks often turn out to be complex even for an experienced person. Do not assign such tasks to the agent directly; instead, break them down into smaller tasks of the first or second type.

Four-step process

Let's consider a step-by-step approach using the example of bug fixing. Upon discovering a bug in the code, do not immediately ask the agent to "fix the bug." Use the following algorithm:

  1. Identifying the error and creating context

    We use the agent to document the issue: we work in dialogue or planning mode if tools are needed.

  2. Cause analysis

    We ask the agent to get to the heart of the problem: “Here is the error: [insert error text or debug log]. What is the cause of the error?”.

  3. Making code corrections

    We show the agent a specific fragment and request a solution: “The function where the error occurs is whereIsMyMoney in Salary.kt. Based on the error, what needs to be changed?”.

  4. Verification and testing

    After the correction, we ask to create a test: “Write a test that identifies this specific bug.” Why do we ask to write a test? Correct: because any bug is a test that no one has written.

Four focused interactions yield four small victories:

  • The error is fixed

  • The problem is documented

  • Testing has been added

  • Execution is faster compared to solving the problem in its entirety

The code gets better because each step is checked as it is carried out. At each of the steps in the example, a specific set of prepared prompts and rules may be needed. To address this issue, agents have many excellent tools that we will explore soon.

Why small steps are more effective

Research shows: developers using AI tools often spend more time checking code than they save writing it. This is true when the agent generates large blocks of code that require careful analysis.

By working in small steps, you gain:

  • Quick verification – each revision takes seconds, not minutes.

  • Easy debugging – each fragment is isolated, making it easier to find issues.

  • Clear code – you are not overwhelmed by large blocks of code from the agent that are hard to comprehend.

  • Continuous progress – you move forward without getting stuck on analyzing the output generated by the agent.

The right mode

Most agents support several modes of operation. Thus, agents adhere to the decomposition approach described in the first part of the article. Generally, these are: Chat, Plan, and Agent. Each mode will be useful at its stage of solving a large task.

Important: try not to jump straight into agent mode. If the agent mode does not yield results in a reasonable time, try switching to other modes, or better yet, start working in them right away.

Advanced agents can independently determine that the user-selected mode is not optimal for the assigned task and switch to the necessary one, continuing work in it. By agreeing to this, we give the agent more freedom but deprive ourselves of some control over its actions. Ultimately, this has a significant impact on the result, and not for the better.

Chat Mode

If you don't know where to start, it's worth gaining knowledge about the problem. For this, you can use the Chat mode. In this mode, the agent cannot use tools that modify files or execute commands in the terminal.

The specific features of this mode depend on the chosen agent; however, its tasks remain unchanged: prepare for the solution, learn about the essence of the problem, analyze errors from debug logs, find the best algorithm. Once you have answers to the questions of interest and an understanding of the next steps, you can switch to planning mode - Plan.

Plan Mode

In this mode, the main goal will be to obtain a clear action plan from the agent, understandable primarily to you. It is in this mode that attention should be focused on decomposition. Here, the agent assists the user in planning. The agent is limited only to reading tools and does not perform unnecessary or dangerous actions that waste time and do not lead to success.

Agent Mode

Once you understand that the agent has the necessary context and action plan, you can confidently switch to agent mode and start making changes. In this mode, the agent has all available tools and can make changes to project files, execute commands.

The effectiveness of the agent in this mode largely depends on how well the work was done in the previous two modes. It remains to iteratively bring the result to an acceptable level by correcting possible errors and shortcomings.

If something doesn't work out, I recommend not forgetting about the possibility of returning to the previous modes. Summarize the context if needed, as most agents have this capability. Now a few words about the models used by agents in different modes, and then we will move on to the second part with useful techniques for improving interaction efficiency with the agent.

Different agents – different modes – different models

Choose models based on the task. Reasoning models are more effective in planning and problem-solving, while instruct models are better in agent mode when editing code. For tasks where speed and cost are important, deploy small local models, for example, for code autocompletion mode in the chosen IDE.

Cutting corners

The techniques that I will describe next will help speed up work and elevate the skill of using the agent to a new level. In fact, there are more such techniques and tricks, but I will only provide a few examples that I find relevant in the context of the main topic of the article. I would be very interested to learn in the comments about what techniques and which agents you use.

Workflows

These are customizable AI workflows that combine prompts, rules, and tools. Their purpose is to perform specific, often repetitive, template tasks. Prepare several workflows and place them along with the project code, after which they will be available to the entire team. Most agents support this capability, for example, Kilo Code. Each workflow can be configured to address one or more similar tasks.

Distribute responsibilities among them: one workflow is tailored for generating a module template with a feature, another specializes in Gradle configuration or knows typical errors and accepted methods for their resolution, the third will help prepare messages for commits and send merge requests in GitLab.

Hotkeys

To switch between different modes, most agents provide keyboard shortcuts. Use them, and you will enter the desired mode or launch the agent to plan the first steps. Hotkeys speed up work in any program, and agents are no exception. In Intellij IDEA, there is an option to reassign hotkeys. Do not ignore this possibility: it will make your work easier.

Slash commands

For quick access to prepared prompts and workflows, use slash commands: in the input field, insert the character "/", select the desired prompt, add context, and press the enter key. Identify template tasks and save successful prompts for solving them. Share them with your team and even beyond. Other participants will be able to use the prompts through slash commands, and together you can improve them based on experience and feedback.

In summary

Preliminary decomposition and best practices of "cutting corners" allow you to maintain workflow rhythm, avoid dead ends, keep control over the process, and achieve results at each step. This way, you will gradually improve code quality. All of this is a path to effective development with AI, not "magic," but systematic work.

Advanced, practically honed decomposition skills increase effectiveness when solving any complex task. By applying decomposition wisely, you ensure smooth and progressive work movement. Each subtask is completed with high quality. Every interaction with AI provides benefits instead of creating additional work to fix mistakes.

Just as tides lift all boats, decomposition inevitably brings to the surface everything that is repeated, all patterns in solving tasks. Once you uncover the patterns, you can automate them using AI. By applying this approach regularly, you will start to notice regularities and templates.

Recurring tasks will become apparent: generating models for domain entities, creating stubs for unit tests, checking changes for compliance with accepted standards, documenting changes, preparing commit messages, creating templates for new modules. Everything that is repeated time and again. Regardless of the context, as soon as you can clearly name and structure these steps, they can be automated.

Experienced engineers know how to break down complex problems into manageable parts and solve them one by one. It is now important to identify which of these parts can be successfully delegated to an agent. It is precisely decomposition that is intended to uncover patterns and repetitive steps that get lost in the context of solving a larger task.

This will help to assess the task more accurately and anticipate possible issues and solutions in advance. If necessary, there is the opportunity to distribute it among other project participants, including your agents. This is exactly what we want to achieve: to do more in the same amount of time by offloading part of the work to agents.

Practice the skills of focused decomposition; without them, it's much harder to tackle large-scale tasks using agents. This is how development speed is achieved in practice – not through "magical" solutions, but through systematic decomposition, sensible automation, and cutting corners.

At the very end, I would like to know your opinion in the comments: should attention be paid to detailed decomposition or is it wiser to wait for more advanced agents for coding?

Thank you for your attention to my article; I hope you found it interesting.

Links to Materials

  1. LLMs Get Lost In Multi-Turn Conversation

  2. Break Down Your Prompts for Better AI Results

  3. Decomposed Prompting: A Modular Approach for Solving Complex

  4. Decomposed Prompting: GitHub-repository

  5. Crafting Effective Prompts for Agentic AI Systems: Patterns and Practices

Comments