Tell it to use red/green TDD and start things off with an already configured test suite, maybe with a single test that asserts 1+1==2.

Make sure it know how to run the tests before it starts writing any additional code.

Then set it a clear goal.

Basically all the examples of LLM's building impressive things have been because they have human written tests to base the implementation on. If you have an LLM write the tests the results are far less impressive or valuable.

Yes and LLMs are known to cheat on tests written by them.

Last year when they added computer use to Claude web I was excited to try it out.

I just asked it for a code snippet and it ended up setting up a whole repo in a docker container or something.

Even volunteered a test suite. This genuinely amazed me.

...until I checked the tests.

It was just console.log("Tests passed!")

AGI 2027

It's not always cheating either. They aren't intelligent, so they don't actually understand the purpose of the tests or can build them to define the actual semantics of the problem space. It's literally just next-token prediction based on the codebase and prompt. Cheating implies that they have agency, and ironically agents don't.