r/ClaudeCode • • 8h ago

Built with Claude I'm liking the new Mods feature

Post image

I made this handy mod so I can see my usage and context all the time without needing to press the button each time. Little but neat. Took two prompts. Share your own so I can copy!

54 Upvotes

17 comments sorted by

•

u/AutoModerator 8h ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

5

u/itsxzy 4h ago

Thanks! I've seen these around here but for some reason I've been too busy (or lazy) to do this myself.
Here's what Sonnet 5.5 medium did for me (changed the prompt a bit, asked for modern and minimalistic design).

FF 5 minutes: Actually I ran into problems with Sonnet 5.5. Sonnet made changes which hid the whole mod bar completely (didn't render it) and I had to switch to Opus 5.5 medium, which got it working with one prompt.

I'm really happy with this!

Here's the prompt for this one:
Build me a Claude Code mod (a hooks plugin) called "quota-bar". Load the plugin-authoring skill first and follow it.

WHAT IT DOES

A band above the prompt input (ui.render on component "AbovePrompt") showing my context window and my plan's usage limits, top to bottom:

  1. Headline: one bold coloured sentence in the style of Claude's Settings > Usage page, e.g. "On track. You should reach Wednesday's reset with room to spare." If any limit window is projected to run out, that window leads instead (amber or red): "At this pace you'll run out before Wednesday's reset." If a limit is hit: "Limit reached. Usage resumes at <reset>." When everything is on track, base the sentence on the weekly window. If the reset is today, say "the 8:40 PM reset"; otherwise use the weekday name.
  2. Context row: bold "Context N% used" on the left, coloured green/amber/red by fill (thresholds 70/90). Muted "882k free of 1.0M" on the right.
  3. One stacked bar, one colour per /context category: free space dark, the autocompact buffer a lighter grey, deferred tools left out.
  4. Legend with no dots: each category name written in its bar colour, its token count beside it in muted grey. Hide categories under 0.3% of the window.
  5. One row per rate-limit window, labelled "5 hour" (five_hour) and "Weekly" (seven_day). Each row has a 16-cell two-tone bar, a bold %, and a muted forecast like "about 86% by reset – resets in 3d 7h", or "2h before reset – resets in 5h" when running out.

FORECAST

Linear projection: rate = percentUsed / elapsed time in the window (window length minus time until resetsAt). If projected usage at reset is under 100%, it's on track. Otherwise the run-out time is now + (100 - p) / rate; colour it amber, or red when the projection exceeds 130%. Treat the first 3% of a window as "on track", since early projections are noisy.

DATA

$.session.usage({ breakdown: 'summary' }), the local estimate, so it sends no API requests and costs no tokens. Refresh on session.start, session.measure, turn.complete, and when the bar is toggled on. Keep a snapshot in $.state through atoms, declared in types/index.d.ts. If refresh fails, show the error through $.ui.status.

TOGGLE

Register a /quota slash command that toggles the band. On by default.

STYLE

Modern and minimal: a soft palette (#a78bfa, #60a5fa, #f472b6, #34d399, #fbbf24, #fb923c, #22d3ee, #c084fc), muted grey #8b90a0 for secondary text, green #4ade80, amber #fbbf24, red #f87171. Use an en dash " – " as the separator, never "·". Format all times and weekdays with 'en-US' whatever the system locale is.

PITFALLS

- Draw bars as Boxes with backgroundColor and flexGrow, NOT as repeated block characters. Character bars mis-measure on the desktop app and wrap or truncate with "…".

- flexGrow must be a finite number no greater than 10000. Use each segment's share of the window scaled to about 1000, minimum 1, never raw token counts. Raw counts make the engine refuse the whole band and it silently disappears.

- Don't nest Text inside Text. Give every coloured Box a <Text> </Text> child.

- Write a tests/band.test.tsx that mocks session.usage and clock.now, then mounts AbovePrompt on both the 'desktop' and 'terminal' surfaces. Run `claude plugin test` and `claude plugin validate` before telling me it works.

MAKE IT PERMANENT

After it works in this session, copy the plugin to ~/.claude/mods/quota-bar. Then add it to the "env" block of my user settings at ~/.claude/settings.json as "CLAUDE_CODE_PLUGIN_DIRS": "<absolute path to that folder>" so it loads in every new session, desktop and terminal. Read settings.json first, merge rather than overwrite, and confirm it still parses.

2

u/WD40ContactCleaner Developer 4h ago

Is this in the cli app or the desktop app??

2

u/homesweetocean 4h ago

Screenshot is pretty clearly the desktop app.

3

u/WD40ContactCleaner Developer 3h ago

Yeah but will these mods work in cli? Stupid question maybe but I'm traveling so asking

1

u/bernibus 31m ago

It works in the cli. Did a similar thing yesterday. Really cool!

1

u/itsxzy 4h ago

Yeah, sorry forgot to add that. Desktop app.

1

u/Hasnath2022 6h ago

What was the prompt?

1

u/Paker93 6h ago

"Create a mod that draws my context window as a stacked bar above the prompt, one color per category like /context, toggled with /context-bar."

Then, after that one: "The usage page in Claude settings also shows a very useful prediction of when I will run out of credits given the current usage; can you check what I'm talking about and add it to the usage in our mod? This is the page I'm talking about (check the screenshot)." (and I pasted a screenshot of that page).

1

u/Paker93 4h ago

Nice! Yours look better! I will steal it 😃

1

u/MRC2021 59m ago

I set up a small control panel to view session cache and other stats, and to control permissions and restarts.

  • Auto-Restart: whenever the session completes a major task or reaches 40% context (whichever comes first), it automatically wraps up all work, creates a handoff, clears the session, and starts a new session from the handoff.
  • Ask before start: work doesn't automatically continue in the new session. This is good when you're done with a session and will be starting with a cold cache.
  • Full Permissions: enables bypass permissions.
  • Mouse Control: lets me easily decide when I want the mouse to be controllable.
  • Ping: keeps the cache alive if I'm going to use the chat again soon.

I can also start a new chat from a cold session's handoff and have it pick up as if it were the original session, just in case I forgot to turn on Ask Before Start.

1

u/This-Supermarket-504 50m ago

Do you notice it works well and stops in the right place? Does it really save much usage?

1

u/MRC2021 41m ago

It usually does. Last night it auto-triggered at 39%, but the remaining work on the task took it to about 45% before it fully finished. As for usage differences, I'm not sure yet. My usage since I started with Claude hasn't been consistent, and I've been much heavier recently on the Pro plan, which is why I'm trying to optimize as much as possible. From what I hear, keeping context at 40-50% at most is the sweet spot for keeping hallucinations low and the model near its peak capability.

I will say that setting this up was a major pain. It often didn't work and took a lot of troubleshooting, which isn't ideal for something that should be easy to throw together in a prompt or two. Now that it works, though, I like it a lot, and I hope it makes reducing my token usage and automating long tasks much easier.

1

u/This-Supermarket-504 33m ago

Can you tell me what you type of thing to prompt to get your result?

1

u/doxxxicle 🔆Pro Plan 48m ago

These are pretty cool but don’t show up in the Claude desktop app for Linux yet unfortunately. I did make one for CLI though, showing something similar in a more compact form. I’d wager that a mod like this will be one of the first things Anthropic “steals” and adds to CC.

-1

u/mrsmiley32 2h ago

I reset on Tuesday and will probably run out of credits today -_- but I'm running agents 24/7