Large Language Model-Assisted Coding in Practice: From Prompting to Verification
Large language models (LLMs) can now take on part of the implementation work. Yet whether they deliver value depends less on clever prompts than on solid engineering: clear requirements and firm boundaries on the input side, and automated verification plus review on the output side. This article covers high-value use cases such as boilerplate code, legacy-code migration, and test generation. It also explains the model's key limitations, including hallucinated APIs, limited context, and weak support for non-functional goals. You'll also find a five-step workflow with reusable prompt and project-rule templates, four verification gates, practical ways to control and measure cost, and team-level practices for turning individual techniques into consistent results. It also looks at the most common pitfalls, especially shipping generated code straight to the main branch.
1. Capability Evolution: From Code Completion to Task-Level Delivery
In the early stages, a model’s main role in the editor was single-line or multi-line completion. Its value came mainly from reducing the repetitive typing of boilerplate code. As training data, instruction-following ability, and long-context handling have improved, models have gradually gained the ability to:
- understand repository structure;
- follow references across files;
- generate complete modules under explicit constraints.
The unit of work has expanded as well, from completing a single line to implementing an interface, locating and fixing a bug, or refactoring procedural code into a layered structure.
This shift changes how models fit into engineering practice. The model is no longer just a typing accelerator. It is a collaborator that can take on part of the implementation work.
The word “collaborator” itself implies three preconditions: clear input, clear acceptance criteria, and clear boundaries. These are also the long-standing fundamentals of software engineering. As a result, getting real value from LLMs depends less on “knowing how to prompt” than on whether the team can describe requirements clearly and verify results thoroughly. Skip that step and chase prompt tricks instead, and you will usually end up with code that looks plausible but can’t be merged.
2. High-Value Scenarios and Capability Boundaries
2.1 High-Value Scenarios
- Boilerplate and glue code: data model definitions, object conversion, CRUD interfaces, configuration wiring, and serialization logic. These patterns are well established and their semantics are unambiguous, so the generated code usually needs little or no modification.
- Code comprehension and migration: adding comments and documentation to legacy code, mapping out call chains, migrating old patterns to new conventions, and writing module responsibility descriptions. Where understanding the code is expensive, these tasks often deliver more value than generating new code.
- Test asset production: generating unit test skeletons from function signatures and implementations, covering boundary cases such as null values, extreme values, out-of-range inputs, and exception paths. Writing tests is tedious and easy to cut short under schedule pressure, which makes it a natural fit for offloading to a model.
- Frontend page scaffolding: generating layouts, styles, and interaction skeletons from a text description or a structural draft. Developers then refine the visuals and details by hand. This can significantly shorten the time from a blank page to a working preview.
- Scripting and workflow automation: log analysis scripts, batch data processing, snippets for build pipeline configuration, and one-off data repair tools.
2.2 Boundaries You Have to Accept
- Hallucinations and fabricated interfaces: models can generate APIs, parameters, or configuration options that look reasonable but don’t actually exist. These errors are invisible on reading, and only compilers, type checks, and running tests can catch them.
Limited context: an oversized repository can’t be fed to the model in full. Implicit cross-module dependencies are easy to miss, such as:
- initialization order;
- implicit global state;
- convention-over-configuration rules.
Changes may then “run fine locally but break in the integration environment.”
- No ownership of correctness: the model doesn’t know your business rules, compliance requirements, or the real state of production. The responsibility for accepting a change always stays with people.
- Weak support for non-functional goals: performance, concurrency safety, memory usage, and security boundaries need deliberate design and load testing. Don’t expect these to emerge as a by-product of generation.
3. A Reusable Workflow: A Five-Step Loop
- Structure the requirement. Break a vague request into inputs and outputs, constraints, the tech stack and its version, parts that must not change, and acceptance criteria. Explicit constraints matter more than descriptions. Writing down “must not introduce new third-party dependencies” works far better than repeatedly explaining “keep it lightweight.”
- Provide the context. Supply the relevant files, interface definitions, data structures, examples of the existing coding style, and directory conventions. This way the model works from the same facts instead of relying on its general assumptions about common frameworks.
- Iterate in small steps. Tackle one verifiable problem at a time. Compile and run tests as soon as code is generated, then feed the actual error messages back to the model unchanged. This creates a tight generate–verify–fix loop and keeps you from piling more changes onto a broken baseline.
- Automate verification. Put type checks, static analysis, unit tests, integration tests, and containerized builds into the pipeline. They are the only accepted measure of correctness.
- Review and consolidate. Record effective prompts, recurring error patterns, and team conventions in project rule files. This turns individual experience into a shared team asset.
Example Prompt Template
[Task] Complete the implementation of the function below, keeping it consistent with the existing code style in the repository.[Context]- Interface definition: <paste the signature and type definitions>- Related files: <list file paths and key snippets>- Technical constraints: language/framework version <...>; must not introduce new third-party dependencies[Requirements]1. Modify only the specified function; do not change the public signature;2. Handle null values and invalid inputs; use the project's error type <...> for all exceptions;3. Before returning the code, self-check: list the boundary cases you need to consider;4. Point out the three implementation choices you consider risky and explain why.[Acceptance] Passes <test command> in the repository, with no new warnings from static checks.
The template matters for three reasons: it states constraints explicitly (no new dependencies, no signature changes), it requires a self-check, and it asks the model to surface where it is uncertain. Having the model say “I’m not sure about this” gives you far more control than letting it finish with confidence.
Example Project Rules File (Illustrative)
# Engineering conventions- Directories: src/<domain>/{api,service,repo,model}- Error handling: always return Result<T, Error>; do not throw raw exceptions- Logging: use the shared logging facade; no debug-style prints- Tests: every service method must cover the normal path, empty inputs, and dependency failures- Before committing, these must pass: formatting -> type checks -> unit tests
4. Engineering Safeguards for Model Output
Treat model output as a high-risk contribution from a junior engineer. That is the simplest and most reliable mindset. None of the four gates below can be skipped:
- Syntax and type gate: compilers and type systems catch interface mismatches, misspelled fields, and missing optional values. These problems account for a large share of real-world rework, yet catching them costs almost nothing.
- Behavior gate: unit tests lock down intended behavior, and integration tests confirm that the code meets its contracts with upstream and downstream components.
- Static and dependency gate: static analysis flags excessive complexity, duplicated implementations, and potential null references. Dependency scanning and license checks keep out non-compliant components.
- Human review gate: reviewers focus on design and business correctness, not formatting, because tools already guarantee formatting.
Security calls for extra care:
- Don’t paste secrets, production data, or customer information into a chat context.
- Run commands and scripts generated by the model in a sandbox or a temporary container first.
- Insist on a second human confirmation for any operation that involves deletion, bulk changes, or permission adjustments.
5. Cost and Efficiency: Making the Investment Measurable
Cost usually comes from three sources: context length, the number of calls, and rounds of rework. Practical optimizations include:
- Sending only the necessary files, rather than the whole repository, to shorten the context.
- Caching results for explanation-oriented requests.
- Routing by task difficulty: simple completions go to lightweight models, while architecture design and tricky debugging go to more capable ones.
- Splitting batch work into independent subtasks that can run in parallel**, such as generating tests in bulk or migrating many call sites to a new pattern.
When you orchestrate this kind of batch work in the cloud, general-purpose cloud product categories are enough to support the job. They cover task scheduling, storage of intermediate artifacts, and failure triage. Examples include elastic compute, container platforms, object storage, logging, and monitoring with alerting (such as the corresponding product categories offered by Baidu AI Cloud). You don’t need to build the entire infrastructure stack yourself.
For efficiency measurement, track the following:
- Adoption rate: the share of generated code that is kept.
- First-pass rate: the share of changes that pass tests without modification.
- Rework rounds.
- Defect density.
- Requirement lead time.
Counting how many lines were generated tells you nothing. Lines of code and actual value are often inversely related.
6. Team Practices and Knowledge Consolidation
Individual techniques don’t scale; conventions do. Three practices work well:
- A shared rules file: put language style, directory conventions, and prohibited practices under version control. Every team member’s tool output then starts from the same baseline.
- A shared verification entry point: everyone runs the same pipeline command before committing. This eliminates excuses like “it works on my machine.”
- A shared review standard: the review checklist should explicitly list the high-risk areas in model-generated code:
- new dependencies;
- authentication and authorization logic;
- shared mutable state across concurrent execution paths;
- swallowed exceptions;
- sensitive information in logs.
7. Common Pitfalls
- Merging generated results straight into the main branch without tests or review.
- Asking for too much in a single request, which overruns the context budget and makes the scope of the changes hard to pinpoint.
- Relying on natural language in place of types and contracts, then repeatedly reworking the code at compile time.
- Overlooking license and data provenance compliance, and bringing in code snippets of unknown origin.
- Generating code without verifying it, which shifts risk from development to production.
Conclusion
Model capabilities will keep raising the ceiling on what can be completed automatically. They won’t change the engineering fundamentals, though: requirements must be clear, boundaries must be explicit, and correctness must be verifiable. Integrate LLMs into your existing systems for testing, type checking, review, and compliance, rather than letting them bypass those systems. That is the reliable way to turn efficiency gains into lasting value.
