harper-blog-l8lxlh.txt (20037B)
1 [1]Skip to main content [2]Avatar 2 3 Harper Reed's Blog 4 5 [3]Home [4]Posts [5]Notes [6]Now [7]Media [8]About [9][email protected] [10]RSS 6 7 My LLM codegen workflow atm 8 9 2025-02-16 · 3062 words · 15 minutes · 10 11 tl:dr; Brainstorm spec, then plan a plan, then execute using LLM codegen. 12 Discrete loops. Then magic. ✩₊˚.⋆☾⋆⁺₊✧ 13 14 I have been building so many small products using LLMs. It has been fun, and 15 useful. However, there are pitfalls that can waste so much time. A while back a 16 friend asked me how I was using LLMs to write software. I thought “oh boy. how 17 much time do you have!” and thus this post. 18 19 (p.s. if you are an AI hater - scroll to the end) 20 21 I talk to many dev friends about this, and we all have a similar approach with 22 various tweaks in either direction. 23 24 Here is my workflow. It is built upon my own work, conversations with friends 25 (thx [12]Nikete, [13]Kanno, [14]Obra, [15]Kris, and [16]Erik), and following 26 many best practices shared on the various terrible internet [17]bad [18]places. 27 28 This is working well NOW, it will probably not work in 2 weeks, or it will work 29 twice as well. ¯\_(ツ)_/¯ 30 31 Let’s go 32 33 Juggalo RobotI always find these AI-generated images to be suspect. Say hi to 34 my juggalo coding robot angel! 35 36 There are many paths for doing dev, but my case is typically one of two: 37 38 • Greenfield code 39 • Legacy modern code 40 41 I will show you my process for both paths 42 43 Greenfield 44 45 I find the following process works well for greenfield development. It provides 46 a robust planning and documentation approach, and allows you to execute easily 47 in small steps. 48 49 Green fieldTechnically, there is a green field on the right. Leica Q, 5/14/2016 50 51 Step 1: Idea honing 52 53 Use a conversational LLM to hone in on an idea (I use ChatGPT 4o / o3 for 54 this): 55 56 Ask me one question at a time so we can develop a thorough, step-by-step spec for this idea. Each question should build on my previous answers, and our end goal is to have a detailed specification I can hand off to a developer. Let’s do this iteratively and dig into every relevant detail. Remember, only one question at a time. 57 58 Here’s the idea: 59 60 <IDEA> 61 62 At the end of the brainstorm (it will come to a natural conclusion): 63 64 Now that we’ve wrapped up the brainstorming process, can you compile our findings into a comprehensive, developer-ready specification? Include all relevant requirements, architecture choices, data handling details, error handling strategies, and a testing plan so a developer can immediately begin implementation. 65 66 This will output a pretty solid and straightforward spec that can be handed off 67 to the planning step. I like to save it as spec.md in the repo. 68 69 You can use this spec for a number of things. We are doing codegen here, 70 but I have used it to bolster ideas by asking a reasoning model to poke 71 holes in the idea (must go deeper!), to generate a white paper, or to 72 generate a business model. You can pop it into deep research and get a 10k 73 word supporting document in return. 74 75 Step 2: Planning 76 77 Take the spec and pass it to a proper reasoning model (o1*, o3*, r1): 78 79 (This is the TDD prompt) 80 81 Draft a detailed, step-by-step blueprint for building this project. Then, once you have a solid plan, break it down into small, iterative chunks that build on each other. Look at these chunks and then go another round to break it into small steps. Review the results and make sure that the steps are small enough to be implemented safely with strong testing, but big enough to move the project forward. Iterate until you feel that the steps are right sized for this project. 82 83 From here you should have the foundation to provide a series of prompts for a code-generation LLM that will implement each step in a test-driven manner. Prioritize best practices, incremental progress, and early testing, ensuring no big jumps in complexity at any stage. Make sure that each prompt builds on the previous prompts, and ends with wiring things together. There should be no hanging or orphaned code that isn't integrated into a previous step. 84 85 Make sure and separate each prompt section. Use markdown. Each prompt should be tagged as text using code tags. The goal is to output prompts, but context, etc is important as well. 86 87 <SPEC> 88 89 (This is the non-tdd prompt) 90 91 Draft a detailed, step-by-step blueprint for building this project. Then, once you have a solid plan, break it down into small, iterative chunks that build on each other. Look at these chunks and then go another round to break it into small steps. review the results and make sure that the steps are small enough to be implemented safely, but big enough to move the project forward. Iterate until you feel that the steps are right sized for this project. 92 93 From here you should have the foundation to provide a series of prompts for a code-generation LLM that will implement each step. Prioritize best practices, and incremental progress, ensuring no big jumps in complexity at any stage. Make sure that each prompt builds on the previous prompts, and ends with wiring things together. There should be no hanging or orphaned code that isn't integrated into a previous step. 94 95 Make sure and separate each prompt section. Use markdown. Each prompt should be tagged as text using code tags. The goal is to output prompts, but context, etc is important as well. 96 97 <SPEC> 98 99 It should output a prompt plan that you can execute with aider, cursor, etc. I 100 like to save this as prompt_plan.md in the repo. 101 102 I then have it output a todo.md that can be checked off. 103 104 Can you make a `todo.md` that I can use as a checklist? Be thorough. 105 106 You can save it as todo.md in the repo. 107 108 Your codegen tool should be able to check off the todo.md while processing. 109 This is good for keeping state across sessions. 110 111 Yay. Plan! 112 113 Now you have a robust plan and documentation that will help you execute and 114 build your project. 115 116 This entire process will take maybe 15 minutes. It is pretty quick. Wild tbh. 117 118 Step 3: Execution 119 120 There are so many options available for execution. The success really depends 121 on how well step 2 went. 122 123 I have used this workflow with [19]github workspace, [20]aider, [21]cursor, 124 [22]claude engineer, [23]sweep.dev, [24]chatgpt, [25]claude.ai, etc. It works 125 pretty well with all the tools I have tried, and I imagine it will work well 126 with any codegen tool. 127 128 I, however, prefer raw claude and aider: 129 130 Claude 131 132 I essentially pair program with [26]claude.ai and just drop each prompt in 133 iteratively. I find that works pretty well. The back and forth can be annoying, 134 but it largely works. 135 136 I am in charge of the initial boilerplate code, and making sure tooling is set 137 up correctly. This allows for some freedom, choice, and guidance in the 138 beginning. Claude has a tendency to just output react code - and having a solid 139 foundation with the language, style, and tooling of your choice will help quite 140 a bit. 141 142 I will then use a tool like [27]repomix to iterate when things get stuck (more 143 about that later). 144 145 The workflow is like this: 146 147 • set up the repo (boilerplate, uv init, cargo init, etc) 148 • paste in prompt into claude 149 • copy and paste code from claude.ai into IDE 150 • run code, run tests, etc 151 • … 152 • if it works, move on to next prompt 153 • if it doesn’t work, use repomix to pass the codebase to claude to debug 154 • rinse repeat ✩₊˚.⋆☾⋆⁺₊✧ 155 156 Aider 157 158 [28]Aider is fun and weird to use. I find that it slots in well to the output 159 of step 2. I can get really far with very little work. 160 161 The workflow is essentially the same as above but instead of pasting into 162 claude, I am pasting the prompts into aider. 163 164 Aider will then “just do it” and I get to play [29]cookie clicker. 165 166 An aside: Aider does really great benchmarking of new models for codegen in 167 their [30]LLM leaderboards. I find it to be a really great resource for 168 seeing how effective new models are. 169 170 Testing is nice with aider, because it can be even more hands off as aider will 171 run the test suite and debug things for you. 172 173 The workflow is like this: 174 175 • set up the repo (boilerplate, uv init, cargo init, etc) 176 • start aider 177 • paste prompt into aider 178 • watch aider dance ♪┏(・o・)┛♪ 179 • aider will run tests, or you can run app to verify 180 • if it works, move on to next prompt 181 • if it doesn’t work, Q&A with aider to fix 182 • rinse repeat ✩₊˚.⋆☾⋆⁺₊✧ 183 184 Results 185 186 I have built so so many things using this workflow: scripts, expo apps, rust 187 cli tools, etc. It has worked across programming languages, and contexts. I do 188 like it. 189 190 If you have a small or large project that you are procrastinating on, I would 191 recommend giving it a shot. You will be surprised how far you can get in a 192 short amount of time. 193 194 My hack to-do list is empty because I built everything. I keep thinking of new 195 things and knocking them out while watching a movie or something. For the first 196 time in years, I am spending time with new programming languages and tools. 197 This is pushing me to expand my programming perspective. 198 199 Non-greenfield: Iteration, incrementally 200 201 Sometimes you don’t have greenfield, and instead need to iterate or do 202 increment work on an established code base. 203 204 a brown fieldThis is not a green field. A random photo from my grandfather’s 205 camera - somewhere in Uganda in the 60s 206 207 For this I have a slightly different method. It is similar to above, but a bit 208 less “planning based.” The planning is done per task, not for the entire 209 project. 210 211 Get context 212 213 I think everyone who is knee-deep in AI dev has a different tool for this, but 214 you need something to grab your source code and efficiently jam it into the 215 LLM. 216 217 I currently use a tool called [31]repomix. I have a task collection defined in 218 my global ~/.config/mise/config.toml that allows me to do various things with 219 my code base ([32]mise rules). 220 221 Here is the LLM task list: 222 223 LLM:clean_bundles Generate LLM bundle output file using repomix 224 LLM:copy_buffer_bundle Copy generated LLM bundle from output.txt to system clipboard for external use 225 LLM:generate_code_review Generate code review output from repository content stored in output.txt using LLM generation 226 LLM:generate_github_issues Generate GitHub issues from repository content stored in output.txt using LLM generation 227 LLM:generate_issue_prompts Generate issue prompts from repository content stored in output.txt using LLM generation 228 LLM:generate_missing_tests Generate missing tests for code in repository content stored in output.txt using LLM generation 229 LLM:generate_readme Generate README.md from repository content stored in output.txt using LLM generation 230 231 I generate an output.txt that has the context from my code base. If I am 232 blowing through tokens, and it is too big - I will edit the generate command to 233 ignore parts of the code base that are not germane to this task. 234 235 One thing really nice about mise is that the tasks can be redefined and 236 overloaded in the working directory’s .mise.toml. I can use a different 237 tool to dump/pack the code, and as long as it generates an output.txt I can 238 use my LLM tasks. This is helpful when various codebases differ so much. I 239 regularly override the repomix step to include broader ignore patterns, or 240 just use a more effective tool to do the packing. 241 242 Once the output.txt is generated, I pass it to the [33]LLM command to do 243 various transformations and then save those as a markdown file. 244 245 Ultimately, the mise task is running this: cat output.txt | LLM -t readme-gen > 246 README.md or cat output.txt | LLM -m claude-3.5-sonnet -t code-review-gen > 247 code-review.md. This isn’t super complicated. the LLM command is doing the 248 heavy lifting (supporting different models, saving keys, and using prompt 249 templates). 250 251 For example, if I need a quick review and fix of test coverage I would do the 252 following: 253 254 Claude 255 256 • go to the directory where the code lives 257 • run mise run LLM:generate_missing_tests 258 • look at the generated markdown file (missing-tests.md) 259 • grab the full context for the code: mise run LLM:copy_buffer_bundle 260 • paste that into claude along with the first missing test “issue” 261 • copy the generated code from claude into my ide. 262 • … 263 • run tests 264 • rinse repeat ✩₊˚.⋆☾⋆⁺₊✧ 265 266 Aider 267 268 • go to the directory where the code lives 269 • run aider (always make sure you are on a new branch for aider work) 270 • run mise run LLM:generate_missing_tests 271 • look at the generated markdown file (missing-tests.md) 272 • paste the first missing test “issue” into aider 273 • watch aider dance ♪┏(・o・)┛♪ 274 • … 275 • run tests 276 • rinse repeat ✩₊˚.⋆☾⋆⁺₊✧ 277 278 This is a pretty good way to incrementally improve a code base. It has been 279 super helpful to do small amounts of work in a big code base. I have found that 280 I can do any sized tasks with this method. 281 282 Prompt magic 283 284 These quick hacks work super well to dig into places where we can make a 285 project more robust. It is super quick, and effective. 286 287 Here are some of my prompts that I use to dig into established code bases: 288 289 Code review 290 291 You are a senior developer. Your job is to do a thorough code review of this code. You should write it up and output markdown. Include line numbers, and contextual info. Your code review will be passed to another teammate, so be thorough. Think deeply before writing the code review. Review every part, and don't hallucinate. 292 293 GitHub Issue generation 294 295 (I need to automate the actual issue posting!) 296 297 You are a senior developer. Your job is to review this code, and write out the top issues that you see with the code. It could be bugs, design choices, or code cleanliness issues. You should be specific, and be very good. Do Not Hallucinate. Think quietly to yourself, then act - write the issues. The issues will be given to a developer to executed on, so they should be in a format that is compatible with github issues 298 299 Missing tests 300 301 You are a senior developer. Your job is to review this code, and write out a list of missing test cases, and code tests that should exist. You should be specific, and be very good. Do Not Hallucinate. Think quietly to yourself, then act - write the issues. The issues will be given to a developer to executed on, so they should be in a format that is compatible with github issues 302 303 These prompts are pretty old and busted (“boomer prompts” if I may). They need 304 some refactoring. If you have ideas to make them better lmk. 305 306 Skiing ᨒ↟ 𖠰ᨒ↟ 𖠰 307 308 When I describe this process to people I say “you have to aggressively keep 309 track of what’s going on because you can easily get ahead of yourself.” 310 311 For some reason I say “over my skis” a lot when talking about LLMs. I don’t 312 know why. It resonates with me. Maybe it’s because it is beautiful smooth 313 powder skiing, and then all of a sudden you are like “WHAT THE FUCK IS GOING 314 ON!,” and are completely lost and suddenly fall off a cliff. 315 316 I find that using a planning step (ala the Greenfield process above) can help 317 keep things under control. At least you will have a doc you can double-check 318 against. I also do believe that testing is helpful - especially if you are 319 doing wild style aider coding. Helps keep things good, and tight. 320 321 Regardless, I still do find myself over my skis quite a bit. Sometimes a quick 322 break or short walk will help. In this regard it is a normal problem-solving 323 process, but accelerated to a breakneck speed. 324 325 We will often ask the LLM to include ridiculous things in our not very 326 ridiculous code. For instance, we asked it to create a lore file and then 327 reference the lore in the user interface. This is for python cli tools. 328 Suddenly there is lore, glitchy interfaces, etc. All to manage your cloud 329 functions, your todo list or whatever. The sky is the limit. 330 331 I am so lonely (。•́︿•̀。) 332 333 My main complaint about these workflows is that it is largely a solo endeavor - 334 i.e. the interfaces are all single player mode. 335 336 I have spent years coding by myself, years coding as a pair, and years coding 337 in a team. It is always better with people. These workflows are not easy to use 338 as a team. The bots collide, the merges are horrific, the context complicated. 339 340 I really want someone to solve this problem in a way that makes coding with an 341 LLM a multiplayer game. Not a solo hacker experience. There is so much 342 opportunity to fix this and make it amazing. 343 344 GET TO WORK! 345 346 ⴵ Time ⴵ 347 348 All this codegen has accelerated the amount of code that I as a single person 349 am able to generate. However, there is a weird side effect. I find myself 350 having a huge amount of “downtime” while waiting for the LLM to finish burning 351 its tokens. 352 353 PrintingI remember this like it was yesterday 354 355 I have changed how I work enough to start incorporating some practice that will 356 try and eat the waiting time: 357 358 • I start the “brainstorming” process for another project 359 • I listen to records 360 • I play [34]cookie clicker 361 • I talk with friends and robots 362 363 It is awesome to be able to hack like this. Hack Hack Hack. I can’t think of 364 another time I have been this productive in code. 365 366 Haterade ╭∩╮( •̀_•́ )╭∩╮ 367 368 A lot of my friends are like “fuck LLMs. They are terrible at everything.” I 369 don’t mind this POV. I don’t share it, but I think it is important to be 370 skeptical. There are an awful lot of reasons to hate AI. My main fear is about 371 power consumption and the environmental impact. But… the code must flow. 372 Right… sigh. 373 374 If you are open to learning more, but don’t want to dig in and become a cyborg 375 programmer - my recommendation is not to change your opinion, but to read Ethan 376 Mollick’s book about LLMs and how they can be used: [35]Co-Intelligence: Living 377 and Working with AI. 378 379 It does a good job of explaining the benefits without being a tech 380 anarcho-capitalist bro type tome. I found it very helpful, and have had so many 381 good and nuanced conversations with friends who have read it. Highly 382 recommended. 383 384 If you are skeptical, but a bit curious - feel free to hit me up and let’s talk 385 through all this madness. I can show you how we use LLMs, and maybe we could 386 build something together. 387 388 thanks to [36]Derek, [37]Kanno, [38]Obra, and [39]Erik for taking a look at 389 this post and suggesting edits. I appreciate it. 390 391 [40]About · [41]Posts · [42]Colophon · [43]Harper.lol 392 Copyright © Harper Reed 393 Generated on Mar 2, 2025 394 Send me an [44]email 395 396 397 References: 398 399 [1] https://harper.blog/2025/02/16/my-llm-codegen-workflow-atm/#main-content 400 [2] https://harper.blog/ 401 [3] https://harper.blog/ 402 [4] https://harper.blog/posts/ 403 [5] https://harper.blog/notes/ 404 [6] https://harper.blog/now/ 405 [7] https://harper.blog/media/ 406 [8] https://harper.blog/about/ 407 [9] mailto:[email protected] 408 [10] https://harper.blog/index.xml 409 [12] https://www.nikete.com/ 410 [13] https://nocruft.com/ 411 [14] https://fsck.com/ 412 [15] https://github.com/KristopherKubicki 413 [16] https://thinks.lol/ 414 [17] https://news.ycombinator.com/ 415 [18] https://twitter.com/ 416 [19] https://githubnext.com/projects/copilot-workspace 417 [20] https://aider.chat/ 418 [21] https://www.cursor.com/ 419 [22] https://github.com/Doriandarko/claude-engineer 420 [23] https://sweep.dev/ 421 [24] https://chatgpt.com/ 422 [25] https://claude.ai/ 423 [26] https://claude.ai/ 424 [27] https://github.com/yamadashy/repomix 425 [28] https://aider.chat/ 426 [29] https://orteil.dashnet.org/cookieclicker/ 427 [30] https://aider.chat/docs/leaderboards/ 428 [31] https://github.com/yamadashy/repomix 429 [32] https://mise.jdx.dev/ 430 [33] https://github.com/simonw/LLM 431 [34] https://orteil.dashnet.org/cookieclicker/ 432 [35] https://www.penguinrandomhouse.com/books/741805/co-intelligence-by-ethan-mollick/ 433 [36] https://derek.broox.com/ 434 [37] https://nocruft.com/ 435 [38] https://fsck.com/ 436 [39] https://thinks.lol/ 437 [40] https://harper.blog/about/ 438 [41] https://harper.blog/posts/ 439 [42] https://harper.blog/colophon/ 440 [43] https://harper.lol/ 441 [44] mailto:[email protected]