Claude Code Best Practices

(anthropic.com)

92 points | by sqs 6 hours ago

10 comments

  • zomglings 2 hours ago
    If 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.

    • jdance 1 hour ago
      This would put anthropic in the business of minimizing the context to increase profits, same as Cursor and others who cheap out on context and try to RAG etc. Which would quickly make it worse, so I hope they stay on api pricing

      Some base usage included in the plan might be a good balance

      • zomglings 50 minutes ago
        You know, I wouldn't mind if they just applied the API pricing after Claude Code ran through the plan limits.

        It would definitely get me to use it more.

        • Wowfunhappy 1 minute ago
          But the Claude Pro plan is almost certainly priced under the assumption that some users will use it below the usage limit.

          If everyone used the plan to the limit, the plan would cost the same as the API with usage equal to the limit.

        • karbon0x 9 minutes ago
          Claude Code and Claude.ai are separate products.
    • twalkz 1 hour ago
      I’ve been using codemcp (https://github.com/ezyang/codemcp) to get “most” of the functionality of Claude code (I believe it uses prompts extracted from Claude Code), but using my existing pro plan.

      It’s less autonomous, since it’s based on the Claude chat interface, and you need to write “continue” every so often, but it’s nice to save the $$

      • zomglings 47 minutes ago
        Thanks, makes sense that an MCP server that edits files is a workaround to the problem.
    • fcoury 2 hours ago
      I 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.
    • replwoacause 1 hour ago
      Their API billing in general is hostile to users. I switched completely to Gemini for this reason and haven’t looked back.
    • cypherpunks01 1 hour ago
      Claude 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.

      • zomglings 58 minutes ago
        The writing of edits and code directly on my machine is something that happens on the client side. I don't see why that usage would be subject to anything but one-time billing or how it puts any strain on Anthropic's infrastructure.
      • fcoury 1 hour ago
        > ... usage limits that would make it very difficult to use for Claude Code.

        Genuinely interested: how's so?

        • cypherpunks01 1 hour ago
          Well, I think it'd be pretty irritating to see the message "3 messages remaining until 6PM" while you are in the middle of a complex coding task.
          • unshavedyak 34 minutes ago
            Conversely I have to manually do this and monitor the billing instead.
          • fcoury 1 hour ago
            No, that's the whole point: predictability. It's definitely a trade off, but if we could save the work as is we could have the option to continue the iteration elsewhere, or even better, from that point on offer the option to fallback to the current API model.

            A nice addition would be having something like /cost but to check where you are in regards to limits.

    • dist-epoch 1 hour ago
      Claude.ai/Desktop is priced based on average user usage. If you have 1 power user sending 1000 requests per day, and 99 sending 5, many even none, you can afford having a single $10/month plan for everyone to keep things simple.

      But every Claude Code user is a 1000 requests per day user, so the economics don't work anymore.

      • zomglings 1 hour ago
        I would accept a higher-priced plan (which covered both my use of Claude.ai/Claude Desktop AND my use of Claude Code).

        Anthropic make it seem like Claude Code is a product categorized like Claude Desktop (usage of which gets billed against your Claude.ai plan). This is how it signs off all its commits:

             Generated with [Claude Code](https://claude.ai/code)
        
        At the very least, this is misleading. It misled me.

        Once I had purchased the $200/month plan, I did some reading and quickly realized that I had been too quick to jump to conclusions. It still left me feeling like they had pulled a fast on one me.

        • dist-epoch 51 minutes ago
          Maybe you can cancel your subscription or charge back?

          I think it's just oversight on their part. They have nothing to gain by making people believe they would get Claude Code access through their regular plans, only bad word of mouth.

          • zomglings 48 minutes ago
            To be fair to them, they make it pretty easy to manage the subscription, downgrade it, etc.

            This is definitely not malicious on their part. Just bears pointing out.

      • fcoury 1 hour ago
        Well, take that into consideration then. Just make it an option. Instead of getting 1000 requests per day with code, you get 100 on the $10/month plan, and then let users decide whether they want to migrate to a higher tier or continue using the API model.

        I am not saying Claude should stop making money, I'm just advocating for giving users the value of getting some Code coverage when you migrate from the basic plan to the pro or max.

        Does that make sense?

    • ghuntley 1 hour ago
      $200/month isn't that much. Folks, I'm hanging around with are spending $100 USD to $500 USD daily as the new norm as a cost of doing business and remaining competitive. That might seem expensive, but it's cheap... https://ghuntley.com/redlining
      • oytis 1 hour ago
        When should we expect to see the amazing products these super-competitive businesses are developing?
      • zomglings 54 minutes ago
        $100/day seems reasonable as an upper-percentile spend per programmer. $500/day sounds insane.

        A 2.5 hour session with Claude Code costs me somewhere between $15 and $20. Taking $20/2.5 hours as the estimate, $100 would buy me 12.5 hours of programming.

        • bambax 7 minutes ago
          Asking very specific questions to Sonnet 3.7 costs a couple of tenths of a cent every time, and even if you're doing that all day it will never amount to more than maybe a dollar at the end of the day.

          On average, one line of, say, JavaScript represents around 7 tokens, which means there are around 140k lines of JS per million tokens.

          On Openrouter, Sonnet 3.7 costs are currently:

          - $3 / one million input tokens => $100 = 33.3 million input tokens = 420k lines of JS code

          - $15 / one million output tokens => $100 = 3.6 million output tokens = 4.6 million lines of JS code

          For one developer? In one day? It seems that one can only reach such amounts if the whole codebase is sent again as context with each and every interaction (maybe even with every keystroke for type completion?) -- and that seems incredibly wasteful?

        • ghuntley 5 minutes ago
          It sounds insane until you drive full agentic loops/evals. I'm currently making a self-compiling compiler; no doubt you'll hear/see about it soon. The other night, I fell asleep and woke up with interface dynamic dispatch using vtables with runtime type information and generic interface support implemented...
      • m00dy 1 hour ago
        Seriously? That’s wild. What kind of CS field could even handle that kind of daily spend for a bunch of people?
        • ghuntley 1 hour ago
          Consider L5 at Google: outgoings of $377,797 USD per year just on salary/stock, before fixed overheads such as insurance, leave, issues like ramp-up time and cost of their manager. In the hands of a Staff+ engineer, these tools enable replication of Staff+ engineers and don't sleep. My 2c: the funding for the new norm will come from either compressing the manager layer or engineering layer or both.
          • malfist 1 hour ago
            LLMs absolutely don't replicate staff+ engineers.

            If your staff engineers are mostly doing things AI can do, then you don't need staff. Probably don't even need senior

            • ghuntley 1 hour ago
              That's my point.

              - L3 SWE II - $193,712 USD (before overheads)

              - L4 SWE III - $297,124 USD (before overheads)

              - L5 Senior SWE - $377,797 USD (before overheads)

              These tools and foundational models get better every day, and right now, they enable Staff+ engineers and businesses to have less need for juniors. I suspect there will be [short-to-medium-term] compression. See extended thoughts at https://ghuntley.com/screwed

        • mmikeff 1 hour ago
          The kind of field where AI builds more in a day than a team or even contract dev does.
          • ghuntley 1 hour ago
            correct; utilised correctly these tools ship teams of output in a single day.
            • rudedogg 28 minutes ago
              Do you have a link to some of this output? A repo on Github of something you’ve done for fun?

              I get a lot of value out of LLMs but when I see people make claims like this I know they aren’t “in the trenches” of software development, or care so little about quality that I can’t relate to their experience.

              Usually they’re investors in some bullshit agentic coding tool though.

      • sbszllr 1 hour ago
        All can be true depending on the business/person:

        1. My company cannot justify this cost at all.

        2. My company can justify this cost but I don't find it useful.

        3. My company can justify this cost, and I find it useful.

        4. I find it useful, and I can justify the cost for personal use.

        5. I find it useful, and I cannot justify the cost for personal use.

        That aside -- 200/day/dev for a "nice to have service that sometimes makes my work slightly faster" is much in the majority of the world.

  • zoogeny 1 hour 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.

    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.

  • jasonjmcghee 1 hour ago
    Surprised 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).

    • BeetleB 29 minutes ago
      Oh wow. Reading your comment guarantees I'll never use Claude Code.

      I use Aider. It's awesome. You explicitly specify the files. You don't have to do work to limit context.

      • boredtofears 15 minutes ago
        Yeah, I tried CC out and quickly noticed it was spending $5+ for simple LLM capable tasks. I rarely break $1-2 a session using aider. Aider feels like more of a precision tool. I like having the ability to manually specify.

        I do find Claude Code to be really good at exploration though - like checking out a repository I'm unfamiliar with and then asking questions about it.

    • bugglebeetle 1 hour ago
      If I have to spend this much time thinking about any of this, congratulations, you’ve designed a product with a terrible UI.
      • jasonjmcghee 1 hour ago
        Some 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.

      • sqs 1 hour ago
        It's fundamentally hard. If you have an easy solution, you can go make a easy few billion dollars.
  • 0x696C6961 1 hour ago
    I 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.
    • isaksamsten 26 minutes ago
      I 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
    • sqs 24 minutes ago
      Tool-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 16 minutes 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.

  • sbszllr 1 hour ago
    The 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 1 hour 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 1 hour ago
        No, 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.

        • mikeg8 18 minutes ago
          Finding 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.
        • mrbombastic 19 minutes ago
          Enshittification is the result of shitty incentives in the market not because coding is hard
  • remoquete 2 hours ago
    What'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?
  • Wowfunhappy 54 minutes 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.

    • zomglings 22 minutes ago
      You 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 10 minutes ago
        Neat, 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.
    • jasonjmcghee 50 minutes ago
      They'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.

  • bugglebeetle 1 hour ago
    Claude 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.
  • m00dy 2 hours ago
    well, the best practice is to use gemini 2.5 pro instead :)
    • replwoacause 1 hour ago
      Yep 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.
  • curtisszmania 2 minutes ago
    [dead]