12 ms·
Claude Code: Best practices for agentic coding
- andrewstuart 1y agoI’m too scared of the cost to use this.
- xpe 1y agoYou can set spend limits https://docs.anthropic.com/en/api/rate-limits https://docs.anthropic.com/en/api/rate-limits
- LADev 1y agoThis is so helpful!
- fallinditch 1y agoI'm wondering how much of the techniques described in this blog post can be used in an IDE like Windsurf or Cursor with Claude Sonnet? My 2 cents on value for money and effectiveness of Claude vs Gemini for coding: I've been using Windsurf, VS Code and the new Firebase Studio. The Windsurf subscription allowance for $15 per month seems adequate for reasonable every day use. I find Claude Sonnet 3.7 performs better for me than Gemini 2.5 pro experimental. I still like VS Code and its way of doing things, you can do a lot with the standard free plan. With Firebase Studio, my take is that it should good for building and deploying simple things that don't require much developer handholding.
- flashgordon 1y agoSo I feel like a grandpa reading this. I gave Claude code a solid shot. Had some wins but costs started blowing up. I switched to Gemini AI where I only upload files I want it to work on and make sure to refactor often so modularity remains fairly high. It's an amazing experience. If this is any measure - I've been averaging about 5-6 "small features" per 10k tokens. And I totally suck at fe coding!! The other interesting aspect of doing it this way is being able to break up problems and concerns. For example in this case I only worked on fe without any backend and flushed it out before starting on an backend.
- xpe 1y agoby fe the poster means FE (front-end)
- flashgordon 1y agoSorry yes. I should have clarified that.
- xpe 1y agoOr uppercase would have cleared it up.
- neodypsis 1y agoA combination that works nicely to solve bugs is: 1) have Gemini analyze the code and the problem, 2) ask it to create a prompt for Claude to fix the problem, 3) give Claude the markdown prompt and the code, 4) give Gemini the output from Claude to review, 5) repeat if necessary
- vessenes 1y agoIf you like this plan, you can do this from the command line: `aider --model gemini --architect --editor-model claude-3.7` and aider will take care of all the fiddly bits including git commits for you. right now `aider --model o3 --architect` has the highest rating on the Aider leaderboards, but it costs wayyy more than just --model gemini.
- neodypsis 1y agoI like Gemini for "architect" roles, it has very good code recall (almost no hallucinations, or none lately), so it can successfully review code edits by Claude. I also find it useful to ground it with Google Search.
- flashgordon 1y agoDamn that's interesting. How much of the code do you provide? I'm guessing when modularity is high you can give specific files.
- simonw 1y agoThe "ultrathink" thing is pretty funny: > We recommend using the word "think" to trigger extended thinking mode, which gives Claude additional computation time to evaluate alternatives more thoroughly. These specific phrases are mapped directly to increasing levels of thinking budget in the system: "think" < "think hard" < "think harder" < "ultrathink." Each level allocates progressively more thinking budget for Claude to use. I had a poke around and it's not a feature of the Claude model, it's specific to Claude Code. There's a "megathink" option too - it uses code that looks like this: let B = W.message.content.toLowerCase(); if ( B.includes("think harder") || B.includes("think intensely") || B.includes("think longer") || B.includes("think really hard") || B.includes("think super hard") || B.includes("think very hard") || B.includes("ultrathink") ) return ( l1("tengu_thinking", { tokenCount: 31999, messageId: Z, provider: G }), 31999 ); if ( B.includes("think about it") || B.includes("think a lot") || B.includes("think deeply") || B.includes("think hard") || B.includes("think more") || B.includes("megathink") ) return ( l1("tengu_thinking", { tokenCount: 1e4, messageId: Z, provider: G }), 1e4 ); Notes on how I found that here: https://simonwillison.net/2025/Apr/19/claude-code-best-practices/ https://simonwillison.net/2025/Apr/19/claude-code-best-pract...
- pyfon 1y agoWeird code to have in a modern AI system! Also 14 string scans seems a little inefficient!
- 1y ago
- panny 1y ago>Use Claude to interact with git Are they saying Claude needs to do the git interaction in order to work and/or will generate better code if it does?
- sagarpatil 1y agoIt doesn’t need to. Its optional.
- panny 1y agoI don't see how this is a best practice then. It seems like they are saying "Spend money on something easy to do, but can be catastrophic if the AI screws it up."
- jwr 1y agoI use Claude Code. I read the discussion here, and given the criticism, proceeded to try some of the other solutions that people recommended. After spending a couple of hours trying to get aider and plandex to run (and then with Google Gemini 2.5 pro), my conclusion is that these tools have a long way to go until they are usable. The breakage is all over the place. Sure, there is promise, but today I simply can't get them to work reasonably. And my time is expensive. Claude Code just works. I run it (even in a slightly unsupported way, in a Docker container on my mac) and it works. It does stuff. PS: what is it with all "modern" tools asking you to "curl somewhere.com/somescript.sh | bash". Seriously? Ship it in a docker container if you can't manage your dependencies.
- beefnugs 1y agoIsn't this bad that every model company is making their own version of the IDE level tool? Wasn't it clearly bad when facebook would get real close to buying another company... then decide naw, we got developers out the ass lets just steal the idea and put them out of business
- bob1029 1y agoI've developed a new mental model of the LLM codebase automation solutions. These are effectively identical to outsourcing your product to someone like Infosys. From an information theory perspective, you need to communicate approximately the same amount of things in either case. Tweaking claude.md files until the desired result is achieved is similar to a back and forth email chain with the contractor. The difference being that the contractor can be held accountable in our human legal system and can be made to follow their "prompt" very strictly. The LLM has its own advantages, but they seem to be a subset since the human contractor can also utilize an LLM. Those who get a lot of uplift out of the models are almost certainly using them in a cybernetic manner wherein the model is an integral part of an expert's thinking loop regarding the program/problem. Defining a pile of policies and having the LLM apply them to a codebase automatically is a significantly less impactful use of the technology than having a skilled human developer leverage it for immediate questions and code snippets as part of their normal iterative development flow. If you've got so much code that you need to automate eyeballs over it, you are probably in a death spiral already. The LLM doesn't care about the terrain warnings. It can't "pull up".
- stepbeek 1y agoThis matches well with my experience so far. It’s why the chat interface has remained my preference over autocomplete in an IDE.
- ixaxaar 1y ago> These are effectively identical to outsourcing your product to someone like Infosys. But in my experience, the user has to be better than an Infosys employee to know how to convey the task to the LLM and then verify iteratively. So more like an experienced engg outsourcing work to a service company engg.
- anamexis 1y agoThat’s exactly what they were saying.
- charlie0 1y agoThe benefit of doing it like this is that I also get to learn from the LLM. It will surprise me from time to time about things I didn't know and it gives me a chance to learn and get better as well.
- imafish 1y agoWhy do people use Claude Code over e.g. Cursor or Windsurf?
- consumer451 1y agoI have not yet used Claude Code personally, but I believe that Cursor and Windsurf both optimize token usage by limiting how much of your code each prompt analyzes. With Claude Code, all bets are off there. You get a better understanding of your code in each prompt, and the bill can rack up, what, 50x faster? If I got really stuck on a problem involving many lines of code, I could see myself spinning up Claude Code for that one issue, then quickly going back to Windsurf.
- submeta 1y agoI love Claude Code. It just gets the job done where Cursor (even with Claude Sonnet 3.7) will get lost in changing files without results. Did anyone have equal results with the „unofficial“ fork „Anon Kode“? Or with Roo Code with Gemini Pro 2.5?
- kkukshtel 1y agoI recently wrote a big blog post on my experience spending about $200 with Claude Code to "vibecode" some major feature enhancements for my image gallery site mood.site https://kylekukshtel.com/vibecoding-claude-code-cline-sonnet-ai-programming-gpt-mood https://kylekukshtel.com/vibecoding-claude-code-cline-sonnet... Would definitely recommend people reading it for some insight into hands on experience with the tool.
- appleaday1 1y agoThis is a pretty desperate post imho.
- ccarse 1y agoWhat are these "subagents" this doc refers to?
- joshstrange 1y agoThe most interesting part of this article for me was: > Have multiple checkouts of your repo I don’t know why this never occurred to me probably because it feels wrong to have multiple checkouts, but it makes sense so that you can keep each AI instance running at full speed. While LLM‘s are fast, this is one of the annoying parts of just waiting for an instance of Aider or Claude Code to finish something. Also, I had never heard of git worktrees, that’s pretty interesting as well and seems like a good way to accomplish effectively having multiple checkouts.
- cadamsdotcom 1y agoYou might want to consider Claude Squad, https://github.com/smtg-ai/claude-squad https://github.com/smtg-ai/claude-squad which manages all the worktrees for you. Disclaimer, I haven’t tried it personally - if you do, let us know how you go!
- m0rde 1y agoI've never used Claude Code or other CLI-based agents. I use Cursor a lot to pair program, letting the AI do the majority of the work but actively guiding. How do you keep tabs on multiple agents doing multiple things in a codebase? Is the end deliverable there a bunch of MRs to review later? Or is it a more YOLO approach of trusting the agents to write the code and deploy with no human in the loop?
- oxidant 1y agoMultiple terminal sessions. Well written prompts and CLAUDE.md files. I like to start by describing the problem and having it do research into what it should do, writing to a markdown file, then get it to implement the changes. You can keep tabs on a few different tasks at a time and you don't need to approve Yolo mode for writes, to keep the cost down and the model going wild.
- rfoo 1y agoIn the same way how you manage a group of brilliant interns.
- remoquete 1y agoWhat's the Gemini equivalent of Claude Code and OpenAI's Codex? I've found projects like reugn/gemini-cli, but Gemini Code Assist seems limited to VS Code?
- peterldowns 1y agoI would also like to know — I think people are using Cursor/Windsurf/Roo(Cline) for IDEs that let you pick the model, but I don't know of a CLI agentic editor that lets you use arbitrary models.
- manojlds 1y agohttps://aider.chat/ https://aider.chat/
- peterldowns 1y agoThanks! Any others, or any thoughts you can share on it?
- danenania 1y agoHey, I'm the creator of Plandex (https://github.com/plandex-ai/plandex https://github.com/plandex-ai/plandex), which takes a more agentic approach than aider, and combines models from Anthropic, OpenAI, and Google. You might find it interesting. I did a Show HN for it a few days ago: https://news.ycombinator.com/item?id=43710576 https://news.ycombinator.com/item?id=43710576
- jasir 1y agoThere's Aider, Plandex and Goose, all of which let you chose various providers and models. Aider also has a well known benchmark[0] that you can check out to help select models. - Aider - https://aider.chat/ https://aider.chat/ | https://github.com/Aider-AI/aider https://github.com/Aider-AI/aider - Plandex - https://plandex.ai/ https://plandex.ai/ | https://github.com/plandex-ai/plandex https://github.com/plandex-ai/plandex - Goose - https://block.github.io/goose/ https://block.github.io/goose/ | https://github.com/block/goose https://github.com/block/goose [0] https://aider.chat/docs/leaderboards/ https://aider.chat/docs/leaderboards/
- zomglings 1y agoIf anyone from Anthropic is reading this, your billing for Claude Code is hostile to your users. Why doesn’t Claude Code usage count against the same plan that usage of Claude.ai and Claude Desktop are billed against? I upgraded to the $200/month plan because I really like Claude Code but then was so annoyed to find that this upgrade didn’t even apply to my usage of Claude Code. So now I’m not using Claude Code so much.
- fcoury 1y agoI totally agree with this, I would rather have some kind of prediction than using the Claude Code roulette. I would definitely upgrade my plan if I got Claude Code usage included.
- datavirtue 1y agoI don't what you guys are on about but I have been using the free GitHub Copilot in VS Code chats to absolutely crank out new UI features in Vue. All that stuff that makes you groan at the thought of it: more divs, bindings, form validation, a whole new widget...churned out in 30 seconds. Try it live. Works? Keep. I'm surprised at the complexity and correctness at which it infers from very simple, almost inadequate, prompts.
- zomglings 1y agoThey did it!
- cypherpunks01 1y agoClaude Pro and other website/desktop subscription plans are subject to usage limits that would make it very difficult to use for Claude Code. Claude Code uses the API interface and API pricing, and writes and edits code directly on your machine, this is a level past simply interacting with a separate chat bot. It seems a little disingenuous to say it's "hostile" to users, when the reality is yeah, you do pay a bit more for more reliable usage tier, for a task that requires it. It also shows you exactly how much it's spent at any point.
- 1y ago
- m00dy 1y agowell, the best practice is to use gemini 2.5 pro instead :)
- replwoacause 1y agoYep I learned this the hard way after racking up big bills just using Sonnet 3.7 in my IDE. Gemini is just as good (and not nearly as willing to agree with every dumb thing I say) and it’s way cheaper.
- xpe 1y ago> Gemini is ... way cheaper. Yep. Here are the API pricing numbers for Gemini vs Claude. All per 1M tokens. 1. Gemini 2.5: in: $0.15; out: $0.60 non-thinking or $3.50 thinking 2. Claude 3.7: in: $3.00; out: $15 [1] https://ai.google.dev/gemini-api/docs/pricing https://ai.google.dev/gemini-api/docs/pricing [2] https://www.anthropic.com/pricing#api https://www.anthropic.com/pricing#api
- ryeguy 1y agoYour gemini pricing is for flash, not pro. Also, claude uses prompt caching and gemini currently does not. The pricing isn't super straightforward because of that.
- sbszllr 1y agoThe issue with many of these tips is that they require you use to claude code (or codex cli, doesn't matter) to spend way more time in it, feed it more info, generate more outputs --> pay more money to the LLM provider. I find LLM-based tools helpful, and use them quite regularly but not 20 bucks+, let alone 100+ per month that claude code would require to be used effectively.
- ramoz 1y agoInteresting, I have $100 days with Claude Code. Beyond effective.
- dist-epoch 1y ago> let alone 100+ per month that claude code would require I find this argument very bizarre. $100 is pay for 1-2 hours of developer time. Doesn't it save at least that much time in a whole month?
- panny 1y agoJust a few days ago Cursor saved a lot of developer time by encouraging all the customers to quit using a product. https://news.ycombinator.com/item?id=43683012 https://news.ycombinator.com/item?id=43683012 Developer time "saved" indeed ;-)
- rpastuszak 1y agoSo sad that people are happy to spend 100$ pd on a tool like this, and we're so unlikely (in general) to pay $5 to an author of an article/blog posts that possibly saved you the same amount of time. (I'm not judging a specific person here, this is more of a broad commentary regarding our relationship/sense of responsibility/entitlement/lack of empathy when it comes to supporting other people's work when it helps us)
- owebmaster 1y agoNo, it doesn't. If you are still looking for product market fit, it is just cost. After 2 years of GPT4 release, we can safely say that LLMs don't make finding PMF that much easier nor improve general quality/UX of products, as we still see a general enshittification trend. If this spending was really game-changing, ChatGPT frontend/apps wouldn't be so bad after so long.
- bugglebeetle 1y agoClaude Code works fairly well, but Anthropic has lost the plot on the state of market competition. OpenAI tried to buy Cursor and now Windsurf because they know they need to win market share, Gemini 2.5 pro is better at coding than their Sonnet models, has huge context and runs on their TPU stack, but somehow Anthropic is expecting people to pay $200 in API costs per functional PR costs to vibe code. Ok.
- owebmaster 1y ago> but somehow Anthropic is expecting people to pay $200 in API costs per functional PR costs to vibe code. Ok. Reading the thread, somehow people are paying. It is mindblowing how in place of getting cheaper, development just got more expensive for businesses.
- tylersmith 1y ago$200 per PR is significantly cheaper development than businesses are paying.
- xpe 1y agoIn terms of short-term outlay, perhaps. But don't forget to factor in the long-term benefits of having a human team involved.
- frainfreeze 1y ago3.5 was amazing for code, and topped benchmarks for months. It'll take a while for other models to take over that mental space.
- zoogeny 1y agoSo I have been using Cursor a lot more in a vibe code way lately and I have been coming across what a lot of people report: sometimes the model will rewrite perfectly working code that I didn't ask it to touch and break it. In most cases, it is because I am asking the model to do too much at once. Which is fine, I am learning the right level of abstraction/instruction where the model is effective consistently. But when I read these best practices, I can't help but think of the cost. The multiple CLAUDE.md files, the files of context, the urls to documentation, the planning steps, the tests. And then the iteration on the code until it passes the test, then fixing up linter errors, then running an adversarial model as a code review, then generating the PR. It makes me want to find a way to work at Anthropic so I can learn to do all of that without spending $100 per PR. Each of the steps in that last paragraph is an expensive API call for us ISV and each requires experimentation to get the right level of abstraction/instruction. I want to advocate to Anthropic for a scholarship program for devs (I'd volunteer, lol) where they give credits to Claude in exchange for public usage. This would be structured similar to creator programs for image/audio/video gen-ai companies (e.g. runway, kling, midjourney) where they bring on heavy users that also post to social media (e.g. X, TikTok, Twitch) and they get heavily discounted (or even free) usage in exchange for promoting the product.
- Wowfunhappy 1y ago> So I have been using Cursor a lot more in a vibe code way lately and I have been coming across what a lot of people report: sometimes the model will rewrite perfectly working code that I didn't ask it to touch and break it. I don't find this particularly problematic because I can quickly see the unnecessary changes in git and revert them. Like, I guess it would be nice if I didn't have to do that, but compared to the value I'm getting it's not a big deal.
- zoogeny 1y agoI agree with this in the general sense but of course I would like to minimize the thrash. I have become obsessive about doing git commits in the way I used to obsess over Ctrl-S before the days of source control. As soon as I get to a point I am happy, I get the LLM to do a check-point check in so I can minimize the cost of doing a full directory revert. But from a time and cost perspective, I could be doing much better. I've internalized the idea that when the LLM goes off the rails it was my fault. I should have prompted it better. So I am now consider: how do I get better faster? And the answer is I do it as much as I can to learn. I don't just want to whine about the process. I want to use that frustration to help me improve, while avoiding going bankrupt.
- jasonjmcghee 1y agoSurprised that "controlling cost" isn't a section in this post. Here's my attempt. --- If you get a hang of controlling costs, it's much cheaper. If you're exhausting the context window, I would not be surprised if you're seeing high cost. Be aware of the "cache". Tell it to read specific files (and only those!), if you don't, it'll read unnecessary files, or repeatedly read sections of files or even search through files. Avoid letting it search - even halt it. Find / rg can have a thousands of tokens of output depending on the search. Never edit files manually during a session (that'll bust cache). THIS INCLUDES LINT. The cache also goes away after 5-15 minutes or so (not sure) - so avoid leaving sessions open and coming back later. Never use /compact (that'll bust cache, if you need to, you're going back and forth too much or using too many files at once). Don't let files get too big (it's good hygiene too) to keep the context window sizes smaller. Have a clear goal in mind and keep sessions to as few messages as possible. Write / generate markdown files with needed documentation using claude.ai, and save those as files in the repo and tell it to read that file as part of a question. I'm at about ~$0.5-0.75 for most "tasks" I give it. I'm not a super heavy user, but it definitely helps me (it's like having a super focused smart intern that makes dumb mistakes). If i need to feed it a ton of docs etc. for some task, it'll be more in the few $, rather than < $1. But I really only do this to try some prototype with a library claude doesn't know about (or is outdated). For hobby stuff, it adds up - totally. For a company, massively worth it. Insanely cheap productivity boost (if developers are responsible / don't get lazy / don't misuse it).
- kiratp 1y agoThe productivity boost can be so massive that this amount of fiddling to control costs is counterproductive. Developers tend to seriously underestimate the opportunity cost of their own time. Hint - it’s many multiples of your total compensation broken down to 40 hour work weeks.
- pizza 1y agoHard agree. Whether it's 50 cents or 10 dollars per session, I'm using it to get work done for the sake of quickly completing work that aims to unblock many orders of magnitude more value. But in so far as cheaper correct sessions correlate with sessions where the problem solving was more efficient anyhow, they're fairly solid tips.
- 0x696C6961 1y agoI mostly work in neovim, but I'll open cursor to write boilerplate code. I'd love to use something cli based like Claude Code or Codex, but neither of them implement semantic indexing (vector embeddings) the way Cursor does. It should be possible to implement an MCP server which does this, but I haven't found a good one.
- xpe 1y agoGood point. I largely work in Zed -- looks like it had semantic search for a while but is working on a redesign https://github.com/zed-industries/zed/issues/9564 https://github.com/zed-industries/zed/issues/9564
- isaksamsten 1y agoI use a small plugin I’ve written my self to interact with Claude, Gemini 2.5 pro or GPT. I’ve not really seen the need for semantic searching yet. Instead I’ve given the LLM access to LSP symbol search, grep and the ability to add files to the conversation. It’s been working well for my use cases but I’ve never tried Cursor so I can’t comment on how it compares. I’m sure it’s not as smooth though. I’ve tried some of the more common Neovim plugins and for me it works better, but the preference here is very personal. If you want to try it out it’s here: https://github.com/isaksamsten/sia.nvim https://github.com/isaksamsten/sia.nvim
- sqs 1y agoTool-calling agents with search tools do very well at information retrieval tasks in codebases. They are slower and more expensive than good RAG (if you amortize the RAG index over many operations), but they're incredibly versatile and excel in many cases where RAG would fall down. Why do you think you need semantic indexing?
- 0x696C6961 1y ago> Why do you think you need semantic indexing? Unfortunately I can only give an anecdotal answer here, but I get better results from Cursor than the alternatives. The semantic index is the main difference, so I assume that's what's giving it the edge.
- Wowfunhappy 1y ago> Use /clear to keep context focused The only problem is that this loss is permanent! As far as I can tell, there's no way to go back to the old conversation after a `/clear`. I had one session last week where Claude Code seemed to have become amazingly capable and was implementing entire new features and fixing bugs in one-shot, and then I ran `/clear` (by accident no less) and it suddenly became very dumb.
- jasonjmcghee 1y agoThey've worked to improve this with "memories" (hash symbol to "permanently" record something - you can edit later if you want). And there's CLAUDE.md. it's like cursorrules. You can also have it modify it's own CLAUDE.md.
- zomglings 1y agoYou can ask it to store its current context to a file, review the file, ask it to emphasize or de-emphasize things based on your review, and then use `/clear`. Then, you can edit the file at your leisure if you want to. And when you want to load that context back in, ask it to read the file. Works better than `/compact`, and is a lot cheaper.
- datavirtue 1y agoCompared to my experience with the free GitHub Copilot in VS Code it sounds like you guys are in a horse and buggy.
- shmoogy 1y agoI'm excited for the improvements they've had recently but I have better luck with Cline in regular vs code, as well as cursor. I've tried Claude code this week and I really didn't like it - Claude did an okay job but was insistent on deleting some shit and hard coding a check instead of an actual conditional. It got the feature done in about $3, but I didn't really like the user experience and it didn't feel any better than using 3.7 in cursor.
- 1y ago
- curtisszmania 1y ago[dead]