Wish-Based Programming with LLMs: Capabilities and Practices
This article explains how "wish-based programming" works with large language models, where developers describe desired behavior in natural language and the model produces runnable code. It clarifies three boundaries, breaks capability evaluation into four observable dimensions, and shows how minimal sufficient context, a validation loop, and a task-specific baseline set help turn probabilistic output into maintainable code that can merge with minimal rework.
1. From “Making a Wish” to Delivery: Clarifying the Concept
The term “wish-based programming” has been appearing frequently in the industry: developers describe the behavior they want in natural language, and the model directly produces runnable code. This does not remove engineering constraints. Instead, it shifts the cost of writing boilerplate code, glue logic, and common error patterns to the model side.
Understanding this is a prerequisite for evaluating any AI coding tool. The real capability metric is not “can it generate code,” but “can the generated result enter the main branch with minimal rework cost.”
Three boundaries need to be made explicit:
- The model has no knowledge of your private codebase unless the context is explicitly provided.
- Model output is probabilistic and must be constrained by tests and static checks.
- The more ambiguous the requirement, the more ambiguity is amplified. The precision of the requirement description directly determines delivery quality.
2. Breaking Down the Capability: Four Observable Dimensions
To evaluate this kind of capability, it is better to establish a quantifiable view across four dimensions rather than relying on a single point-in-time experience.
- Intent fidelity: Does it accurately identify inputs, outputs, boundary conditions, and exception paths?
- Context consistency: Does it follow the existing directory structure, naming conventions, and dependency versions?
- Verifiability: Does it include executable test cases and assertions?
- Maintainability: Does it avoid over-abstraction, meaningless comments, and duplicate implementations?
A sample prompt structure is shown below. The key is to front-load the constraints:
Goal: <one sentence describing the observable behavior to achieve>Input/Output: <data structures or interface shape>Constraints: <language version, dependency scope, prohibited actions>Acceptance: <test cases and boundary conditions that must pass>
3. Context Engineering: The Key Variable That Determines Success
Most failures are not caused by insufficient model capability, but by insufficient context. In practice, follow the principle of “minimal sufficient context”: feed only the interface definitions, data structures, and a small number of style samples relevant to the goal. Avoid loading the entire repository, which dilutes the model’s attention.
For large projects, first have the model produce a list of changes and an impact analysis, then progressively expand to specific files. This layered approach can significantly reduce the hallucination rate.
When building such a workflow on Baidu AI Cloud, you can combine general-purpose capabilities: use object storage to host prompt templates and sample sets, use a message queue to smooth out bursts and handle batch generation tasks, use a container platform to run the inference and validation pipeline, and use logging and monitoring with alerting to observe success rates and latency distribution. These are all general industry categories, making them easy to migrate across environments.
4. The Validation Loop: Turning “Looks Correct” into “Is Correct”
Generation without a closed loop is just a draft. The recommended minimal loop has four steps: static checks, unit tests, diff review, and regression validation. If any step fails, the error message should be fed back to the model to form an automatic retry. In engineering practice, set a retry limit and a fallback strategy to avoid infinite loops that consume resources.
def generate_with_check(prompt, checker, max_retry=3):for i in range(max_retry):code = call_model(prompt)ok, feedback = checker(code)if ok:return codeprompt = prompt + f"\nLast failure reason: {feedback}"raise RuntimeError("Validation failed; manual intervention required")
5. Common Anti-Patterns and How to Avoid Them
- Reducing the requirement to a single sentence with no acceptance criteria.
- Asking for a full-module refactor in one shot, which exceeds a controllable scope.
- Blindly trusting the output and skipping tests.
- Writing sensitive information into prompts, which creates compliance risk.
The corresponding mitigations are: add acceptance test cases, split tasks into smaller units, enforce pipeline validation, and redact and apply permission isolation to prompt content.
6. Evaluation Recommendations: Build Your Own Baseline Set
Do not rely on abstract reputation. Build a set of 30 to 100 test cases tailored to your own business, covering normal flows, boundary values, and invalid inputs. Track three metrics: first-pass rate, average number of retries, and lines of manual modification. Run a regression every month. This makes the gains from process improvements clearly visible and helps you make rational decisions when adopting a new model or tool.
