Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

New features

While building a new feature, agentic AI can also save you time by generating the code you want to write. However, you should keep in mind that some of the time you save will be spent on carefully constructing your prompt, reviewing the work, and possibly iterating on it if you are not happy with the result. It is also the place where AI is most likely to go astray, since there are no tests to constrain the new code and the guidelines are only as good as your prompt. Still, there are some practices that can make the process more efficient and less error-prone. As in earlier chapters, the quoted prompts below are real, with links to the resulting PRs where public.

Plan first

It is a good habit to separate planning from implementation. Most harnesses have a plan mode, where the agent explores the codebase and proposes an approach without editing anything (editing and most other tools are disabled in this mode). A good agent will find weak or vague points in your idea, point out parts of the codebase that will require extra attention, and ask you questions that you might not have thought about yet. Answering those questions before any code exists is far better than discovering the same problems in review.

I’d like to support optional pre-compilation to speed up usage (header only libraries are slow). This is similar to how nanobind works (though I believe it’s not optional there), and there was an attempt here: pybind/pybind11#2445 tried to start this. It should be easy to use from cmake (maybe meson too, if possible), and have a pretty simple user-facing mechanism for users not using a supported build system.

Implementing from a specification

Agents are very good at working from a written specification. If the feature is already described somewhere (e.g. a PEP, an issue with a detailed proposal, an RFC, a design document), you can point the agent directly at it, add whatever extra details are specific to your codebase, and let it work. The specification does the same job that a test does in test-driven development (see Writing tests): it constrains the agent to a behavior you have already agreed on, rather than one it invented.

Now that we have a new Python discovery system, we should be able to support the requires-python option of PEP 723.

nox#1142 (the same PR later revived in Common tasks)

This works well in practice for things like implementing a new PEP in a library, or adding a feature to a build-backend plugin where the interface is already documented. The more precise the source material, the less supervision the implementation needs. A reference implementation works as a spec too:

Let’s add support for dynamic-metadata. It is described in ../../scikit-build/dynamic-metadata and it is implemented in ../../scikit-build/scikit-build-core.

Prototype to decide

Not every feature is worth building, and it is often hard to tell in advance. Agentic AI makes it cheap enough to build a rough version and find out. Does the approach actually work? Is it fast enough (see Profiling)? Once you can hold it, do you even like the design?

The important part is that the prototype has done its job regardless of what happens to the code. You might keep the AI version, polish it into something you are happy to maintain, or throw it away and write it yourself now that you know what you want. All three are good outcomes, and none of them require you to have committed to the feature before you had evidence. This scales to comparing whole alternatives:

Let’s evaluate mkdocs replacements. Launch opus agents in worktrees to try zensical, properdocs, and greatdocs as replacements.

— the winner became cibuildwheel#2946

Validate beyond your own repo

Your own test suite only tells you the feature runs. A few cheap ways to find out whether the feature is any good:

The real cost is after generation

It is tempting to measure the value of an agent by how quickly it produces a working feature, but the real time sink is working through the changes and genuinely understanding them, and an agent can produce far more code than you can carefully review in the same amount of time. A large, plausible-looking diff still has to be read carefully before it is worth anything.

The practical way to keep this under control is to iterate instead of trying to one-shot the feature. Talk to the agent while it works: redirect it when it heads somewhere you did not intend, ask it to explain a decision you do not follow, and have it fix the parts you are unhappy with. You do not need to hand-edit the code yourself, but you do need to keep iterating until it meets the standards you would apply to your own work. Reviewing in small pieces as they arrive is much easier than reviewing everything at the end (see Reviewing). If you would not merge it from a human contributor, do not merge it from the agent.

Exercise