Code like a pirate with AI — Bitfield Consulting
Blog RSS
Aug 4
Aug 4 Code like a pirate with AI
John Arundel
Source image by Reiterlied, licensed under Creative Commons
Ahoy, maties! Cap’n Long John Arundel here with more tips on sailing<br>the good ship Go. This time, we’ll lay aloft to the crow’s nest and turn<br>our spyglass on AI tools. Arrr ye ready to vibe-code like a pirate?<br>Let’s weigh anchor and see what booty we can find on the AI seas.
For this tutorial, I be using Junie, the JetBrains AI coding agent,<br>but the same workflows and prompts apply to Claude Code, ChatGPT, Codex,<br>or any other scurvy tool ye fancy. Technically, it’s not necessary to<br>prompt them using pirate speak (but it’s a lot more fun, and works just<br>fine).
Flying the black flag
Your first voyage with AI development tools can be a perilous one,<br>veering from calm seas of code to storms of syntax errors and test<br>failures. So, will your AI agent be a trusty first mate, or just an<br>unpredictable stochastic<br>parrot squawking nonsense from your shoulder?
Junie is pretty smart, and she can tackle any task you choose, but<br>she needs the guidance of a good cap’n. To help you stay on course, I’ve<br>put together a handy six-step workflow I like to call “Code like a<br>PIRATE”. Aye, ‘tis another o’ my made-up<br>acronyms—but ye’ll find it easy to remember, me hearties [Are we<br>doing the pirate thing for the whole article?—Ed.]
“P” is for Plan
Every good voyage begins with a map. When you set Junie a task, tell<br>her where the ship’s headed, so she’ll know which direction to steer.<br>(I’m sure Junie won’t mind me calling her “she”; fun fact, lots of<br>pirates were women—including quite a few of the<br>men).
Ask Junie to draw up a quick chart for the voyage, but not to set<br>sail until you’ve approved it:
It’s important to get this stuff right before you even leave the<br>dock, so don’t be afeared to spend a bit of time refining the plan.<br>[I’m “afeared” we might be wearing out the salty sea-dog bit<br>already—Ed.]
“I” is for Iterate
Even the boldest captains don’t try to cross an ocean in a single<br>leap. It’s more effective to island-hop, sailing a short distance at a<br>time and checking you’re still on course. Give Junie one small task at a<br>time, starting with the simplest possible program that could be<br>useful:
With too vague a heading, Junie can end up going a bit adrift, like<br>any of us: don’t hesitate to cry “Avast heaving there!” and interrupt<br>her if that happens. Rowing back when the project has gone too far in<br>the wrong direction will cost you a lot of time and doubloons<br>[Seriously, clap a stopper on the pirate speak for now—Ed.].<br>Sorry, I meant to say “tokens”.
“R” is for Review
Once Junie has completed each iteration, go through the code line by<br>line to check and review her work. She’s pretty good at delivering<br>what you asked for, but she doesn’t necessarily know<br>how you want it. For example:
When giving feedback, bundle all your comments together in one<br>message. This lets Junie generate the new version of the program in a<br>single step, saving tokens. If you keep making small comments and asking<br>her to rebuild the whole program each time, you’ll find your pieces of<br>eight—I mean, credits—dwindling rapidly.
Good programs have a harmonious architecture that makes overall<br>sense: everything works the same way everywhere and it all seems to fit<br>together neatly. Junie can’t achieve this without your guidance, so keep<br>a hand on the tiller and help her ensure things slot neatly into a<br>unified structure.
“A” is for Assess
Once Junie has finished the step you asked for, don’t just glance at<br>the code and move on—take a moment to assess whether it actually does<br>what it should. Does the program run cleanly? Do the functions behave as<br>expected? Are there strange side effects lurking in the bilges, waiting<br>to sink your ship later? [What did I just<br>say?—Ed.]
Now that you can see the program in action, you might realise it’s<br>not quite what you want. If so, now’s the time to adjust course, either<br>with Junie’s help or by making little steering inputs yourself.
If you’re happy with the assessment, though, you can move on to the<br>next iterative step towards the final program:
“T” is for Test
No old salt trusts a ship that hasn’t been through its sea-trials,<br>and nor should you. As you and Junie build the program, check each new<br>plank is watertight by adding tests to accompany each function. That<br>way, you’ll know as soon as something springs a leak.
Junie can be a helpful shipmate when it comes to drafting tests, but<br>don’t just accept her handiwork blindly. Ask yourself: What is this<br>really testing? Are there hidden reefs—edge cases—that we’re missing?<br>And, when the tests fail (they’re no use otherwise) do they print<br>something helpful?
“E” is for Evaluate
Machine learning is fine, but human learning is even better.<br>After each task, take a little time to analyse what worked, and what<br>could have gone better.
Were your prompts detailed enough? Did Junie sail safely...