Show HN: Plandex – an AI coding engine for complex tasks (github.com)
I built Plandex because I was tired of copying and pasting code back and forth between ChatGPT and my projects. It can complete tasks that span multiple files and require many steps. It uses the OpenAI API with your API key (support for other models, including Claude, Gemini, and open source models is on the roadmap). You can watch a 2 minute demo here: https://player.vimeo.com/video/926634577
Here's a prompt I used to build the AWS infrastructure for Plandex Cloud (Plandex can be self-hosted or cloud-hosted): https://github.com/plandex-ai/plandex/blob/main/test/test_pr...
Something I think sets Plandex apart is a focus on working around bad outputs and iterating on tasks systematically. It's relatively easy to make a great looking demo for any tool, but the day-to-day of working with it has a lot more to do with how it handles edge cases and failures. Plandex tries to tighten the feedback loop between developer and LLM:
- Every aspect of a Plandex plan is version-controlled, from the context to the conversation itself to model settings. As soon as things start to go off the rails, you can use the `plandex rewind` command to back up and add more context or iterate on the prompt. Git-style branches allow you to test and compare multiple approaches.
- As a plan proceeds, tentative updates are accumulated in a protected sandbox (also version-controlled), preventing any wayward edits to your project files.
- The `plandex changes` command opens a diff review TUI that lets you review pending changes side-by-side like the GitHub PR review UI. Just hit the 'r' key to reject any change that doesn’t look right. Once you’re satisfied, either press ctrl+a from the changes TUI or run `plandex apply` to apply the changes.
- If you work on files you’ve loaded into context outside of Plandex, your changes are pulled in automatically so that the model always uses the latest state of your project.
Plandex makes it easy to load files and directories in the terminal. You can load multiple paths:
plandex load components/some-component.ts lib/api.ts ../sibling-dir/another-file.ts
You can load entire directories recursively: plandex load src/lib -r
You can use glob patterns: plandex load src/**/*.{ts,tsx}
You can load directory layouts (file names only): plandex load src --tree
Text content of urls: plandex load https://react.dev/reference/react/hooks
Or pipe data in: cargo test | plandex load
For sending prompts, you can pass in a file: plandex tell -f "prompts/stripe/add-webhooks.txt"
Or you can pop up vim and write your prompt there: plandex tell
For shorter prompts you can pass them inline: plandex tell "set the header's background to #222 and text to white"
You can run tasks in the background: plandex tell "write tests for all functions in lib/math/math.go. put them in lib/math_tests." --bg
You can list all running or recently finished tasks: plandex ps
And connect to any running task to start streaming it: plandex connect
For more details, here’s a quick overview of commands and functionality: 111 comments
[ 2.8 ms ] story [ 201 ms ] threadAlso it doesn't work on a "small view of the world" like Copilot from when I was using it could only insert code around your cursor (I understand that copilot pulls in a lot of context from all the files you have open, but the area it can modify is really small). This can add/remove/update code in multiple files at once. But it'll also just show you a diff first before it applies and you can select some or all of the changes made.
I've also looked at Together (https://www.together.ai/) for this purpose. Can anyone speak to the differences between OpenRouter and Together?
OP has certainly built something interesting here and added significant value on top of the base utility of the OpenAI API.
That said, you can do quite a meaty task for well under $1. If you're using it heavily it can start to add up over time, so you'd just need to weigh that cost against how you value your time I suppose. In the future I do hope to incorporate fine tuned models that should bring the cost down, as well as other model options like I mentioned in the post.
You can try different models and model settings with `plandex set-model` and see how you go. But in my experience gpt-4 is really the minimum bar for getting usable results.
I tried to build the backend so that postgres, the file system, and git would combine to form effectively a single transactional database.
I personally wanted something with a tighter feedback loop that felt more akin to git. I also thought that simplifying the UI side would help me stay focused on getting the data structures and basic mechanics right in the initial version. But now that the core functionality is in place, I think it will work well as a base for additional frontends.
It seems like more examples demonstrating relatively complex tasks would be helpful, so I'll work on those.
I'm certainly not trying to claim that it can handle any task. The underlying model's intelligence and context size do place limits on what it can do. And it can definitely struggle with code that uses a lot of abstraction or indirection. But I've also been amazed by what it can accomplish on many occasions.
I still use ChatGPT for some coding tasks, e.g. I asked it to write C code to do some annoying fork/execve stuff (can't remember the details) and it did a decentish job, but it's like 90% right. Great for figuring out a rough shape and what functions to search for, but you definitely can't just take the code and expect it to work.
Same when I asked it to write a device driver for some simple peripheral. It had the shape of an answer but with random hallucinated numbers.
I've also noticed that because there is a ton of noob-level code on the internet it will tend to do noob-level things too, like for the device driver it inserted fixed delays to wait for the device to perform an operation rather than monitoring for when it had actually finished.
I wonder if coding AIs would benefit from fine tuning on programming best practices so they don't copy beginner mistakes.
That's not to say it's perfect or will never make "noob-level" mistakes. That can definitely happen and is ultimately a function of the underlying model's intelligence. But I can at least assure you that it's quite capable of going far beyond a trivial web project.
It's also on me to show more indepth examples, so thanks for calling it out. I'd love it if you would try some of the projects you mention and let me know how it goes.
I run about 10-15 rounds with it. At the beginning I was using GPT more heavily, but in the middle I found it easier to just fix the code myself. The context got as big as 10k tokens, but was not a problem. At some point I might need to filter the files more aggressively.
But surprisingly all that is needed for a bare-bone repo-level coding assistant is a script to list all the files so I could easily copy paste the whole thing into the chatGPT window.
We don't know what ChatGPT's summarization strategy is since it's closed source, but it does seem to be quite a bit more aggressive than Plandex's.
Just in case you are using a Mac, you can pipe the output of your script to pbcopy so that it goes directly into your clipboard
script.sh | pbcopy
I was able to improve reliability of line numbers by using a chain-of-thought approach where, for each change, the model first summarizes what's changing, then outputs code that starts and ends the section in the original file, and then finally identifies the line numbers from there.
The relevant prompts are here: https://github.com/plandex-ai/plandex/blob/main/app/server/m...
It seems it might be useful if it could actually try to execute the code, or somehow check for syntax errors/unimplemented functions before accepting the response from the LLM.
"It seems it might be useful if it could actually try to execute the code, or somehow check for syntax errors/unimplemented functions before accepting the response from the LLM."
Indeed, I do have some ideas on how to add this.
First I should say that it’s been a few months at least since I’ve used aider, so it’s possible my impression of it is a bit outdated. Also I’m a big fan of it and drew a lot of inspiration from it. That said:
Plandex is more focused on building larger and more complex functionality that involves multiple steps, whereas aider is more geared toward making a single change at a time.
Plandex has an isolated, version-controlled sandbox where tentative changes are accumulated. I believe with aider you have to apply or discard each change individually?
Plandex has diff review TUI where changes can be viewed side-by-side, and optionally rejected, a bit like GitHub’s PR review UI.
Plandex has branches that allow for exploring multiple approaches.
aider has cool voice input features that Plandex lacks.
aider’s maintainer Paul has done a lot of benchmarking of file update strategies. While I think Plandex’s approach is better suited to larger and more complex functionality, aider’s unified diff approach may have higher accuracy for a single change. I hope to do benchmarking work on this in the future.
aider requires Python and is installed via pip, while Plandex runs from a single binary with no dependencies, so Plandex installation is arguably easier overall, especially if you aren't a Python dev.
I’m sure I’m missing some other differences but those are the main ones that come to mind.
I think the plandex UX is novel and interesting. The idea of a git-like CLI with various stateful commands is a new one in this space of ai coding tools. In contrast, aider uses a chat based "pair programming" UX, where you collaborate with the AI and ask for a sequence of changes to your local git repo.
The plandex author highlights that it makes changes in a "version-controlled sandbox" and can "rewind" unwanted changes.
These capabilities are all available "for free" in aider, because it is tightly integrated with git. Each AI change is automatically git committed with a sensible commit message. You can type “/diff” to check the diff, or "/undo" to undo any AI commit that you don't like. Or you can use "/git checkout -b <branch-name>" to start working on a branch to explore a longer sequence of changes, etc.
All your favorite git workflows are supported by invoking familiar git commands with "/git ..." inside the aider chat, or using any external git tooling that you prefer. Aider notices any changes in the underlying repo, however they occur.
Sounds like the right approach to me. Some quick questions:
1. Is it easy to customize the system prompt with aider?
2. Does aider save a record of all OpenAI API calls? I’m thinking I may e.g. want to experiment with fine tuning an open source model using these one day.
3. What would you say are aider’s closest “competitors”?
One of the reasons I think it's good to have the plan version-controlled separately from the repo is it avoids intermingling your changes and the model's changes in a way that's difficult to disentangle. It's also resilient to a "dirty" git state where you have a mix of staged, unstaged, and untracked changes.
One more benefit is that Plandex can be used in directories that aren't git repos, while still retaining version control for the plan itself. This can be useful for more one-off tasks where you're not working in an established project.
Do you support AzureOpenAI with custom endpoints?
Are any special settings necessary to disable telemetry or non-core network requests?
If you self-host the server, there is no telemetry and no data is sent anywhere except to your self-hosted server and OpenAI.
I really dislike the hype marketing in some other solutions.
You can tell because there are papers from Microsoft on this but no product: https://www.microsoft.com/en-us/research/project/autogen/
I also wrote about the L1 to L5 of AI coding here: https://prompt.16x.engineer/blog/ai-coding-l1-l5