CodeBot for Delphi: A Deep Dive into the New AI Assistant
What Actually Runs Under the Hood
CodeBot is a local/cloud hybrid agent. The IDE extension handles context extraction — open units, cursor position, compile errors, and the current project's unit dependency graph. That context gets compressed into a prompt and sent to a fine-tuned model that has seen a large chunk of Delphi open-source code and Stack Overflow answers. The result comes back as either inline completions or full refactor proposals, not just "explain this code" chat.
First Run, Step-by-Step
1. Install the IDE plugin from the RAD Studio repository manager.
2. Get an API key from the CodeBot dashboard (there's a free tier with 500 requests/day).
3. Open the CodeBot panel, point it at your .dproj file, and let it index for a minute or two.
4. Hit Alt+C to generate at cursor, or Alt+R for refactor suggestions on a selection.
The indexing stage is the important part. CodeBot builds a local semantic map of your units, so when you ask it to "add error handling to this data module," it already knows which exception classes your project standardizes on.
A Real-World Prompt Workflow
I spent an afternoon migrating a legacy forms app to a cleaner MVVM structure. The practical tutorial that worked best was giving CodeBot a single unit at a time and asking for concrete change sets, like this:
Refactor TCustomerForm in CustomerForm.pas to separate the business logic into a TCustomerViewModel class. Keep the VCL form as a thin view, preserve all existing event handlers' behavior, and use the currently injected TCustomerService from unit CustomerService.pas. Respond with the full new unit code plus a diff outline.The output wasn't perfect — the generated view-model had a duplicate property definition and one over-eager Try block. But the diff outline made it easy to spot the mistakes. CodeBot also generated the unit tests in two seconds flat, something I usually skip because it takes too long by hand.
Honest Impressions After Real Use
- Completion quality: noticeably better than generic copilots on VCL and FMX code. It knows
TStringListownership semantics and won't suggest leaks. - Refactoring: the strongest feature. It respects the existing code style and unit boundaries.
- Test generation: baseline DUnitX tests are solid; edge-case coverage is still on you.
- Slowpoints: large multi-unit refactors can take up to a minute, and it occasionally pulls the wrong unit context if a project has duplicate filenames.
- Deployment: if you're behind a corporate firewall, you'll need the on-prem option — setup is straightforward but requires a separate server.
The real value isn't autocomplete. It's the ability to say "turn this 400-line unit into a maintainable pattern" and get a starting point that's 80% right. For a niche ecosystem like Delphi, that's a rare and welcome thing.
If you've been wondering whether AI can handle Object Pascal at all, CodeBot is the first answer that feels like it actually respects the language's constraints.