iTranslated by AI
Split Instruction MCP Server: Saving Routine Tasks Where Vibe Coding Fails
Are you all starting to get used to vibe coding or waiting for AI tasks to complete after providing careful prompts? I am not getting used to it at all. In fact, I feel despair every day, wondering what I even dreamed of achieving with AI.
This is because:
- I can't leave things to it as loosely as "vibe coding" implies.
- Even when I provide careful prompts, I end up writing similar ones almost every time.
- Yet, because the tasks are so diverse, I can't write long instructions in
.clinerulesor.cursor/rules/.
As a result, there is an imbalance in parts of my coding work. While there are developments where I can use AI effectively, it completely fails in cases where it's not suited (and it makes me want to cry when those tasks are the core of my business).
Specifically, I'm talking about the commoditized parts of client-side web production, such as:
- Periodic page additions for site operations
- Template creation for new site builds
In these cases, a unified design system cannot be used, so I end up creating similar (yet different) UI and content from scratch every time.
However, since many parts are routinized, I want to delegate these to the AI effectively.
Conclusion: Solve by Dividing Instructions
I tried writing various prompts, but my current solution is to divide the instructions to solve the problem. Let me list the failures that led to this conclusion.
Failure 1: Instructions are too long
When an AI agent receives a large volume of instructions at once, it might handle them fine at first, but it gradually starts ignoring instructions or performing actions outside of what was requested.
Failure 2: Mixing instructions and rules
For example, .clinerules or .cursor/rules/ are where you define rules, but because I want to omit prompts, I end up writing instructions in these files. This causes the rule content to become massive. Similar to when instructions are too long, this results in the AI ignoring rules or behaving unexpectedly.
Failure 3: Instructions contain multiple tasks
Failure 2 actually doesn't cause much of a problem if the instructions are sparse. (That's why it took me a while to realize it was a failure.) But as I wanted to add more types of tasks and kept writing more instructions into .clinerules, the instructions and rules eventually became bloated, causing the AI agent's behavior to become unstable and its accuracy to drop.
Failure 4: Multiple rules are mixed
Furthermore, for example, the target directories and related files differ slightly between creating a page and creating a component, and each might have its own independent rules. However, when these exist in the same context window, the AI may mix the rules together during interpretation, resulting in an inability to complete the task.
Hints for the Solution
Based on these points, I thought I could improve the accuracy of the AI agent by doing the following:
- Give instructions in small, divided chunks as much as possible
- Ensure rules are independent or included within the instructions
In fact, I felt that accuracy wouldn't stabilize otherwise.
Why not just write divided instructions in the prompt each time?
That is a perfectly valid point. However, I can't stay glued to VS Code or Cursor all the time. It makes me wonder, "What is the point of using an AI agent?" Like vibe coding, I want to be able to say "Do this," and then leave it alone until it's finished.
So I Built an MCP Server to Issue Divided Instructions
The mechanism is simple.
- Write "If there is an instruction for XX, use the MCP server to read the XX instruction manual and execute the instructions returned by the server" in
.clinerulesor.cursor/rules/. - The AI agent requests the "instruction file path" from the MCP server.
- The MCP server reads the instruction file, divides it, and returns the first instruction to the AI agent.
- The AI agent receives the instruction and executes it.
- ☝️ This is the key point: The first instruction includes an instruction to "Proceed to step 2."
- When the AI agent finishes the first instruction, it requests the "instruction file path" and "next step number" from the MCP server.
- The MCP server reads the instruction file, divides it, and returns the second instruction to the AI agent.
- Repeat this process.
With this, once you provide the initial "Do XX" instruction, the AI agent and the MCP server will handle the rest according to the procedure automatically.
- Rules refers to
.clinerulesor.cursor/rules/.
MCP Server Tool Implementation
-
cwd: Current working directory -
filePath: Path to the instruction file -
step: Step number
Implementation of Instruction Splitting: getTaskStep()
A function that simply divides the file and returns only the part for the given step number.
Configuration Examples in Cline
.clinerules
Try to avoid including specific instructions here as much as possible. Keep it strictly to rules (well, they are instructions, but you get the point).
Since it acts like conditional branching, it's better to write them explicitly.
.clineignore
Exclude the instruction files so they are not read directly by the AI.
./ai-tasks/{task-name}.md
Instruction files.
You can also give conditional instructions by explicitly specifying a step number to skip to from each step.
Note that use_mcp_tool is the identifier Cline uses when calling a tool[1], so specifying it explicitly seems to improve accuracy compared to just using natural language (in my opinion).
By managing instruction manuals within the repository like this, you can handle multiple different instructions for each project. Alternatively, you could modify the MCP server to fetch instructions from a URL, which would allow for centralized management of common instructions.
Summary
As you can see, I've (so far) succeeded in improving task accuracy with a fairly simple mechanism. Best of all, by just giving an initial simple instruction, the task can proceed almost entirely to completion. The hybrid of vibe coding and meticulously detailed instructions is working well.
This approach might be useful not only for commoditized routine tasks but also for instructions with many steps or repetitive processes. I feel quite a bit of potential in this approach.
I hope you find this helpful.
-
Cline's system prompt ↩︎
Discussion
私も結局、AIが出力したコードをレビューしないと精神的な安定が得られないですし、その労力を減らすためにタスクを細かく分割して出力し、一度にレビューする量を減らしてます。そうしないと私がパンクするというか…笑 不具合が出た時に、お客様や同僚に、実装はどうなってるの?と聞かれて説明できないのも変な話ですしね。コーディングスタイルが微妙に気に入らないと頭にも入ってこないので、その辺も指示し出すと、AIといえど、まあまあの作業量になりますね笑