Lurker News
I've been working on a personal project recently, rewriting an old jQuery + Django project into SvelteKit. The main work is translating the UI templates into idiomatic SvelteKit while maintaining the original styling. This includes things like using semantic HTML instead of div-spamming, not wrapping divs in divs in divs, and replacing bootstrap with minimal tailwind. It also includes some logic refactors, to maintain the original functionality but rewritten to avoid years of code debt. Things like replacing templates using boolean flags for multiple views with composable Svelte components.

I've had a fairly steady process for doing this: look at each route defined in Django, build out my `+page.server.ts`, and then split each major section of the page into a Svelte component with a matching Storybook story. It takes a lot of time to do this, since I have to ensure I'm not just copying the template but rather recreating it in a more idiomatic style.
This kind of work seems like a great use case for AI assisted programming, but I've failed to use it effectively. At most, I can only get Claude Code to recreate some slightly less spaghetti code in Svelte. Simple prompting just isn't able to get AI's code quality within 90% of what I'd write by hand. Ideally, AI could get it's code to something I could review manually in 15-20 minutes, which would massively speed up the time spent on this project (right now it takes me 1-2 hours to properly translate a route).
Do you guys have tips or suggestions on how to improve my efficiency and code quality with AI?

Comments (469) 111 threads

Earlier comments
yashwantphogat#
I’ve run into the same wall. The issue is not that AI “can’t code well”, it’s that it’s bad at large, aesthetic refactors unless you constrain the problem very tightly.

A few things that have helped me get closer to that 15–20 minute review window:
1. Stop asking it to translate a whole route AI struggles when it has to infer intent, architecture, and taste at once. Instead, I break things down explicitly:
one prompt for semantic HTML structure only
one prompt for component boundaries
one prompt for state and data flow I often tell it “do not worry about styling or completeness, just structure”.
2. Give it examples of what “idiomatic” means to you Before asking it to generate anything, I paste a small, finished Svelte component from my codebase and say “match this level of abstraction and composition”. Without this, it will default to generic Svelte patterns.
3. Ask for constraints, not solutions Prompts like:
“Do not use boolean flags for view switching. Use composable components.”
work better than:
“Refactor this to be idiomatic Svelte.”
The more you forbid, the better the output.
4. Use AI as a first-pass reviewer, not an author I’ve had more success writing the initial version myself, then asking AI to:
point out anti-patterns
suggest component splits
identify places where logic can move to the server This tends to align better with how humans actually refactor.
5. Accept that taste is still human Things like semantic HTML, component boundaries, and long-term maintainability are closer to “design” than “coding”. Current models can assist, but they won’t replace your judgment yet.
One small thing that’s helped me personally is using quieter, review-focused AI tools instead of chat-style copilots. I’ve been building and using a GitHub app called MergeMonkey that gives short, structured PR feedback and only goes deeper when you ask. It’s been useful as a second set of eyes once the code exists, rather than trying to generate everything from scratch.

sdn90#
Go into planning mode and plan the overall refactor. Try to break the tasks down into things that you think will fit into a single context window.

For mid sized tasks and up, architecture absolutely has to be done up front in planning mode. You can ask it questions like "what are some alternatives?", "which approach is better?".
If it's producing spaghetti code, can you explain exactly what it's doing wrong? If you have an idea of what ideal solution should look like, it's not too difficult to guide the LLM to it.
In your prompt files, include bad and good examples. I have prompt files for API/interface design, comment writing, testing, etc. Some topics I split into multiple files like criteria for testing, testing conventions.
I've found the prompts where they go "you are a X engineer specializing in Y" don't really do much. You have to break things down into concrete instructions.

daxfohl1 reply#
Go slowly. Shoot for a 10% efficiency improvement, not 10x. Go through things as thoroughly as if writing by hand, and don't sacrifice quality for speed. Be aware of when it's confidently taking you down a convoluted path and confidently making up reasons to do so. Always have your skeptic hat on. If something seems off, it probably is. When in doubt, exit the session and start over.

I still find chat interface generally more useful than coding assistant. It allows you to think and discuss higher level about architecture and ideas before jumping into implementation. The feedback loop is way faster because it is higher level and it doesn't have to run through your source tree to answer a question. You can have a high ROI discussion of ideas, architecture,algorithms, and code, before committing to anything. I still do most of my work copying and pasting from the chat interface.
Agents are nice when you have a very specific idea in mind, but I'm not yet hugely fond of them otherwise. IME the feedback loop is too long, they often do things badly, and they are overly confident in their oytput, encouraging cursory reviews and commits of hacked-together work. Sometimes I'll give it an ambitious task just in the off chance that it'll succeed, but with the understanding that if it doesn't get it right the first time, I'll either throw it away completely, or just keep whatever pieces it got right and pitch the rest; it almost never gets it right the second time if it's already started on an ugly approach.
But the main thing is to start small. Beyond one-shotting prototypes, don't expect it to change everything overnight. Focus on the little improvements, don't skip design, and don't sacrifice quality! Over time, these things will add up, and the tools will get better too. A 10% improvement every month gets to be a 10x improvement in (math...). And you'll be a lot better positioned than those who tried to jump onto the 10x train too fast because you'll not have skipped any steps.

ebcode1 reply#
> A 10% improvement every month gets to be a 10x improvement in (math...)

1.1^24=9.85, so yeah, if you could reliably get a 10% speed-up each month, you’d get to 10x in roughly 2 years. (But I’d expect the speed-up per month to be non-linear.)

verdverm#
it would be hard to account for model / agentic capability increases in the next 2 years, b/c which side of multiple Nx on its own is hard to predict
zmmmmm#
I'm a day late and I see so much advice here, but I see little mention of what made the most difference to me: lean into TDD.

Building tests first has always been a strong methodology, but with AI support its both far less work AND you get double dividends, because your test becomes the spec the AI needs to follow but it's an executable, verifiable one. So as you give it more requirements, it's automatically finding and fixing its mistakes along the way.
In terms of having it code how you like: nothing beats putting examples into AGENTS.md / CLAUDE.md etc. Give it some examples of how you like it, and say this is how the code is written. Make remarks about why as well, put the design philosophy in too.

Load more comments