8 ms·
Claude Code: Best practices for agentic coding
- 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.
- 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?
- rfoo 1y agoIn the same way how you manage a group of brilliant interns.
- mh- 1y agoReally? My LLMs seem entirely uninterested in free snacks and unlimited vacation.
- 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.
- 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!
- 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.
- 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?
- 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.
- mrbombastic 1y agoEnshittification is the result of shitty incentives in the market not because coding is hard
- mikeg8 1y agoFinding product market fit is a human directional issue, and LLMs absolutely can help speed up iteration time here. I’ve built two RoR MVPs for small hobbby projects spending ~$75 in Claude code to make something in a day that would have previously taken me a month plus. Again, absolutely bizarre that people can’t see the value here, even as these tools are still working through their kinks.
- owebmaster 1y ago
- 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.
- istjohn 1y agoWhy do you think it's supposed to be cheap? Developers are expensive. Claude doesn't have to be cheap to make software development quicker and cheaper. It just has to be cheaper than you. There are ways to use LLMs cheaply, but it will always be expensive to get the most out of them. In fact, the top end will only get more and more costly as the lengths of tasks AIs can successfully complete grows.
- zoogeny 1y agoI am not implying in any sense a value judgement on cost. I'm stating my emotions at the realization of the cost and how that affects my ability to use the available tools in my own education. It would be no different than me saying "it sucks university is so expensive, I wish I could afford to go to an expensive college but I don't have a scholarship" and someone then answers: why should it be cheap. So, allow me the space to express my feelings and propose alternatives, of which scholarships are one example and creative programs are another. Another one I didn't mention would be the same route as universities force now: I could take out a loan. And I could consider it an investment loan with the idea it will pay back either in employment prospects or through the development of an application that earns me money. Other alternatives would be finding employment at a company willing to invest that $100/day through me, the limit of that alternative being working at an actual foundational model company for presumably unlimited usage. And of course, I could focus my personal education on squeezing the most value for the least cost. But I believe the balance point between slightly useful and completely transformative usages levels is probably at a higher cost level than I can reasonably afford as an independent.
- 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).
- bugglebeetle 1y agoIf I have to spend this much time thinking about any of this, congratulations, you’ve designed a product with a terrible UI.
- jasonjmcghee 1y agoSome tools take more effort to hold properly than others. I'm not saying there's not a lot of room for improvement - or that the ux couldn't hold the users hand more to force things like this in some "assisted mode" but at the end of the day, it's a thin, useful wrapper around an llm, and llms require effort to use effectively. I definitely get value out of it- more than any other tool like it that I've tried.
- 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.
- 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.
- sqs 1y agoIs it a very large codebase? Anything else distinctive about it? Are you often asking high-level/conceptual questions? Those are the questions that would help me understand why you might be seeing better results with RAG.
- 0x696C6961 1y agoI'll ask something like "where does X happen?" But "X" isn't mentioned anywhere in the code because the code is a complete nightmare.
- 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
- 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.
- Wowfunhappy 1y agoNeat, thanks, I had no idea! Edit: It so happens I had a Claude Code session open in my Terminal, so I asked it: Save your current context to a file. Claude produced a 91 line md file... surely that's not the whole of its context? This was a reasonably lengthy conversation in which the AI implemented a new feature.
- zomglings 1y agoWhat is in the file?
- Wowfunhappy 1y agoAn overview of the project and the features implemented. Edit: Here's the actual file if you want to see it. https://gist.github.com/Wowfunhappy/e7e178136c47c2589cfa7e5a25bc71d2 https://gist.github.com/Wowfunhappy/e7e178136c47c2589cfa7e5a...
- curtisszmania 1y ago[dead]
- 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.
- 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...
- orojackson 1y agoNot gonna lie: the "ultrathink" keyword that Sonnet 3.7 with thinking tokens watches for gives me "doubleplusgood" vibes in a hilarious but horrifying way.
- 4b11b4 1y agoAt this point should we get our first knob/slider on a language model... THINK ..as if we're operating this machine as analog synth
- soulofmischief 1y agoThere are already many such adjustable parameters such as temperature and top_k
- 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?