Practical Guide to LLM Coding Agents: Engineered Workflows and Document Preprocessing
How to use LLM coding agents for large-scale, multi-file engineering tasks. This article shares a real-world firmware porting experience and distills an effective workflow: a disciplined multi-stage process, TDD and verification-before-completion rules, sub-agent orchestration to keep context clean, and a PDF-to-Markdown preprocessing pipeline that dramatically improves retrieval accuracy.
Background: Why Large Coding Tasks Break LLM Agents
I recently completed a representative engineering project: porting a platform’s firmware-related modules (EDS, BIOS configuration, display configuration, and more) to another environment, touching dozens of files and over a hundred changes. This is one of the hardest scenarios for LLM coding agents — not an isolated “write a function” task, but a long-running engineering effort that requires continuously understanding requirements, maintaining context, and coordinating changes across many files.
Simply dumping the task on the model is usually disastrous: the agent dives into the files and starts modifying code “by feel,” loses track of the original requirements midway, and produces a pile of code that looks plausible but doesn’t compile. After multiple iterations, I settled on a fairly stable working method. The core idea can be summed up in one sentence: don’t let the model improvise — constrain it with an engineered process and tooling.
Environment and Overall Approach
My development environment was a CLI-based coding agent paired with a mainstream large-parameter code model. During testing, I also compared other models in the same class on the same task. The overall conclusion: model capability matters, but workflow design can matter even more to the final outcome. The same model, driven through free-form conversation versus a disciplined workflow, produces results that differ by orders of magnitude in quality.
I’ll break this down into four areas.
1. A Disciplined Multi-Stage Workflow
My setup follows a classic workflow decomposition: Brainstorming → Spec → Plan → Execute → Review.
The value of this flow is that it forces “align first, then act”:
- Brainstorming: Discuss requirement boundaries, technical choices, and known risks with the model. No code is written in this stage — only conclusions.
- Spec: Solidify the discussion into an explicit requirements specification document. This step is critical — verbal consensus erodes quickly over long conversations, but once written down, every later stage can refer back to it.
- Plan: Break the Spec into an executable task list, with each task annotated with the files involved, acceptance criteria, and dependencies.
- Execute: Carry out tasks one by one, with a small verification step after each.
- Review: A full walkthrough, checking against the Spec for gaps.
For a task like firmware porting, the quality of the Plan decomposition directly determines the success rate of the Execute stage. My rule of thumb: keep each task small enough to be verified in a single step. “Migrate a specific register definition header file and get it to compile” is the right granularity; “complete all driver-layer porting” is far too coarse.
2. Hard Rules: TDD, Systematic Debugging, and Verification Before Claiming Completion
Beyond the workflow, a few “hard skills” are essential for quality:
Test-Driven Development (TDD): Require the model to write tests before implementation. In firmware work, much of the logic can’t run directly on target hardware, but you can build host-side unit tests for the pure-logic parts — data transformations, protocol parsing, bitfield operations. With tests in place, every change the model makes has an objective regression baseline.
Systematic debugging: Forbid “guess-and-fix” behavior. When a compile error or test failure appears, the model must first reproduce it, then locate the root cause, propose a hypothesis, and verify the hypothesis before making any change. This dramatically reduces the cycle of “fixing one bug and introducing three more.”
Verification before claiming completion: This is the most valuable rule in my experience. LLMs have a notorious tendency — claiming a task is done without actually verifying it. For example, the agent might say “it compiles” when in fact it merely “believes” the code should compile. A hard rule requires it to actually run commands and show output before asserting any conclusion:
Example rules:- Before claiming "it compiles," actually run the build command and include the last few lines of output- Before claiming "tests pass," run the test suite and report pass/fail counts- If verification is not possible, explicitly state "not verified" — never assume success
This single rule cut my rework count by more than half.
3. Sub-Agent Orchestration: The Decisive Factor for Large-Scale Tasks
For projects spanning dozens of files and hundreds of changes, there’s another engineering problem: context pollution. If all implementation details unfold in the main conversation, its context quickly fills with code diffs, compile errors, and intermediate discussions. The model’s “memory” of the original requirements gets diluted, and quality visibly degrades in the later stages.
The solution is sub-agent orchestration: keep only Plan-level information in the main conversation, and dispatch the tasks decomposed from the Plan to sub-agents with independent contexts. Each sub-agent receives a self-contained task description (target files, acceptance criteria, relevant spec excerpts) and, when done, returns only a structured result summary to the main conversation (what was done, which files were changed, verification results).
This keeps the main conversation in a “commander’s view” with clean context, so quality doesn’t collapse in the second half of long tasks. For a large porting project, this mechanism is often the difference between success and failure.
4. Document Preprocessing: The Payoff of Converting PDFs to Markdown
Firmware development depends heavily on specification documents — EDS files, BIOS specs, and display configuration docs often run to hundreds of pages. In practice I found a seriously underrated problem: LLMs have very low retrieval accuracy on PDFs. Tables get shredded, register bitfield tables frequently shift rows or columns, and watermarks plus headers and footers add noise.
Converting the same content to Markdown improves retrieval accuracy by an order of magnitude. The reason is that Markdown preserves structural semantics: tables remain tables, heading levels are explicit, code blocks stand alone — the model can genuinely “read” the content instead of guessing from a fragmented text stream.
My approach was a three-step preprocessing pipeline:
- Layout parsing: Parse the PDF page by page into a structured intermediate representation, identifying text blocks, tables, and image regions;
- Targeted repair: Merge and realign broken tables, filter out watermarks, and extract key diagrams, embedding them as file references;
- Structured output: Reorganize content into Markdown by heading hierarchy, converting critical information such as register bitfields into standard table syntax.
The processed documents live in the project’s refer/docs directory, where retrieval tools let the model consult them on demand. The upfront investment took about half a day, but it bought reliable document access for the model throughout the entire porting cycle — an excellent return.
Key Takeaways
Abstracting from this experience, three general principles emerge:
- Process constraints beat capability expectations. Don’t expect the model to behave well on its own — frame it with explicit stage boundaries and hard rules.
- Every conclusion must be verifiable. Compiling, testing, running — always execute the commands you can run, and treat the verification result as part of the task’s closure.
- Context is a scarce resource. Keep decision-level information in the main conversation and delegate implementation details to sub-agents; preprocess input materials into structured form to reduce the model’s parsing burden.
LLM coding agents are evolving rapidly, but no matter how strong the models become, “how to organize tasks, how to constrain behavior, and how to verify results” remains the engineer’s responsibility. The essence of this methodology is migrating traditional software engineering quality practices into the new landscape of human-AI collaboration — tools will change, but engineering discipline never goes out of style.
