SLOPSHOPPER

context-gauge

Context fill as a bar on the prompt hint line, with a /clear nudge as context grows

newbandspinner
★ 3v0.1.0no licenseupdated 2026-10-09puffin/dotfiles/config/claude-mods/context-gauge
A shopper browsing a rack in a slop shop
README

Dotfiles

A collection of neovim, tmux, and zsh configurations for macOS. Built for DevOps workflows with Terraform, Python, YAML, and JSON.

light theme

Contents

Setup and Installation

Clone the dotfiles repository to your home directory as ~/.dotfiles.

git clone https://github.com/puffin/dotfiles.git ~/.dotfiles
cd ~/.dotfiles

Backup

Run install/backup.sh to back up any existing symlinked files to ~/dotfiles-backup. The installation scripts will not overwrite existing files.

Installation

Install XCode CLI tools and Homebrew first:

xcode-select --install

Follow instructions at https://brew.sh/ to install Homebrew, then:

./install.sh

This will:

  • Symlink all *.symlink files to your home directory (e.g. zshrc.symlink becomes ~/.zshrc)
  • Symlink the config directory contents to ~/.config/
  • Install Homebrew packages from Brewfile
  • Run macOS-specific configurations via install/osx.sh, including remapping Caps Lock to Control on every keyboard (via hidutil, persisted with a LaunchAgent)

Uninstallation

./uninstall.sh

Reverses the above: removes the symlinks (only if they still point at this repo), reverts the shell change, uninstalls exactly the packages/casks/taps listed in Brewfile, clears zinit/fzf/tf-helper/nvim/tmux-plugin caches, and deletes the specific macOS defaults keys install/osx.sh set. It prompts for confirmation before doing anything, since most of it is destructive, and it deliberately leaves ~/.ssh, ~/.gnupg (besides the generated gpg-agent.conf), and any nvim/tmux session history alone, since those can hold data of your own. Note claude-code is itself a Brewfile cask, so it gets uninstalled too.

Terminal Capabilities

To support italic fonts in tmux:

tic -x resources/xterm-256color-italic.terminfo
tic -x resources/tmux.terminfo

ZSH Setup

ZSH is configured in zshrc.symlink. Key features:

  • EDITOR set to nvim
  • Zinit plugin manager for zsh plugins
  • Sources ~/.localrc for machine-specific config (API keys, etc.)
  • Custom prompt with git status on RPROMPT

Git Prompt Symbols

  • + New files added
  • ! Existing files modified
  • ? Untracked files
  • >> Files renamed
  • ✘ Tracked file deleted
  • $ Stashed files
  • = Unmerged files
  • ⇡ Branch ahead of remote
  • ⇣ Branch behind remote
  • ⇕ Branches diverged
  • ✔ Working directory clean

Neovim Setup

Neovim is configured entirely in Lua with the following structure:

~/.config/nvim/
├── init.lua                  -- Entry point
└── lua/user/
    ├── options.lua           -- Editor settings
    ├── keymaps.lua           -- Key mappings
    ├── autocmds.lua          -- Autocommands
    ├── plugins.lua           -- Plugin declarations (lazy.nvim)
    └── lsp.lua               -- LSP server configuration

Plugins are managed by lazy.nvim and installed automatically on first launch. Run :Lazy inside neovim to manage plugins.

LSP and Autocompletion

Language servers are managed by Mason and configured via Neovim's native vim.lsp.config (0.11+). Autocompletion is powered by blink.cmp.

LanguageServerFeatures
TerraformterraformlsCompletions, diagnostics, prefill required fields
Pythonpyright + ruffPyright for completions/types, Ruff for linting/formatting
YAMLyamllsSchema-aware completions (K8s, Docker Compose, GitHub Actions, etc.)
JSONjsonlsSchema-aware completions (package.json, tsconfig, etc.)

Schemas are provided by SchemaStore.nvim (300+ schemas).

Note: For Terraform, run terraform init in each project directory for provider-aware completions.

LSP Keymaps

KeyAction
gdGo to definition
gyGo to type definition
giGo to implementation
grFind references
KShow documentation
<leader>rnRename symbol
<leader>caCode action

Completion Keymaps

KeyAction
TabNext completion
S-TabPrevious completion
CRConfirm selection
C-SpaceTrigger / toggle docs
C-eDismiss completion
C-b / C-fScroll documentation

Diagnostics

Diagnostics show inline virtual text, gutter signs, and underlines. Holding the cursor on an error line auto-opens a floating window with the full message.

Plugins

UI: vim-one (colorscheme), lualine (statusline), nvim-web-devicons, vim-smoothie (smooth scrolling)

Editor: vim-surround, vim-repeat, vim-unimpaired, vim-sleuth, vim-abolish, Comment.nvim, splitjoin.vim, nvim-autopairs, editorconfig

Git: fugitive, gitsigns, diffview.nvim, vim-flog, vim-twiggy

Navigation: FZF (files, buffers, ripgrep), nvim-tree (file explorer)

Session: vim-obsession + vim-prosession (auto-save/restore sessions)

Syntax: Treesitter with parsers for Terraform, HCL, Python, TypeScript, JSON, YAML, Lua, and more

Tmux Configuration

Tmux is configured in ~/.tmux.conf with prefix set to control+a. Sessions are automatically saved every minute via tmux-continuum and restored on tmux start via tmux-resurrect.

Tmux Commands

KeyAction
prefix + IInstall plugins
prefix + UUpdate plugins
prefix + wWindow/pane selection
prefix + cNew window
prefix + ,Rename window
prefix + &Kill window
prefix + [1-9]Select window
prefix + -Split vertically
`prefix + \`Split horizontally
prefix + xKill pane
prefix + [h,j,k,l]Move to pane
prefix + zToggle pane fullscreen
prefix + shift + [h,j,k,l]Resize pane

Herdr Configuration

Herdr is an agent-aware terminal multiplexer - it covers the same sessions/windows/panes ground as tmux, plus status tracking for AI coding agents (Claude Code, Codex, etc.) running in its panes. It's configured in ~/.config/herdr/config.toml with the same control+a prefix as tmux, so the muscle memory carries over. Both tools are installed; use either as your daily driver, or reach for herdr specifically when running coding agents you want to keep tabs on. Sessions persist across restarts and reattaches natively, with no plugin manager needed.

Herdr Commands

KeyAction
prefix + wWorkspace/agent picker
prefix + cNew tab
prefix + shift + tRename tab
prefix + shift + xClose tab
prefix + [1-9]Select tab
alt + [1-9]Select tab (no prefix)
prefix + minusSplit stacked
`prefix + \`Split side-by-side
prefix + xClose pane
prefix + [h,j,k,l]Move to pane
prefix + zToggle pane fullscreen
prefix + shift + [h,j,k,l]Swap pane
prefix + rResize pane mode
prefix + [Copy mode (vim-style)
ctrl + shift + [left,right]Reorder current tab
prefix + qDetach

Herdr Plugins

Installed automatically by install.sh via herdr plugin install (source lives outside this repo under ~/.config/herdr/plugins/, gitignored - not vendored). The marketplace is a self-tagged, unreviewed GitHub index; these were picked and their READMEs checked by hand, not exhaustively vetted against the ~1000 plugins listed there.

PluginWhat it doesKey
herdr-auto-titleRenames tabs to match what's running in them(automatic)
vim-herdr-navigationctrl+h/j/k/l crosses seamlessly between herdr panes and Neovim splits (vim-tmux-navigator, ported to herdr)ctrl + [h,j,k,l]
herdr-reviewrDiff/review pane - comment on an agent's changes, send feedback back to itprefix + shift + c
herdr-sessionizerFuzzy-open projects/worktrees, bootstrap a workspace layout from TOMLprefix + shift + s

herdr-sessionizer needs bun to build (in the Brewfile via the oven-sh/bun tap).

Terminal Configuration

Terminal of choice is Alacritty. Configuration is in config/alacritty/alacritty.yml.

Fonts

SauceCodePro NF, installed via Homebrew.

Color Scheme

vim-one in light mode. Comments are displayed in light grey italic.

Toggle Light/Dark

Press Ctrl+x Ctrl+t to toggle between light and dark themes. This works in both neovim and the shell, and switches all three simultaneously:

  • Neovim colorscheme (vim-one light/dark)
  • Alacritty terminal colors
  • Tmux status bar

You can also run toggle-theme from the command line, optionally with light or dark as an argument.

Dark Theme

dark theme

Claude Code

Claude Code is integrated into Neovim via the claudecode.nvim plugin, providing an in-editor AI assistant panel.

Claude Code Keymaps

Leader key is Space.

KeyAction
<leader>acToggle Claude Code panel
<leader>asSend selection to Claude
<leader>aaAdd current file to Claude
<C-w>Navigate away from terminal (e.g. Claude panel)

Claude Code CLI Hooks

config/claude-hooks/ holds portable Claude Code hook scripts, symlinked into ~/.claude/hooks/ by install/link.sh. ~/.claude/settings.json itself is not tracked here (it's inherently per-machine — permissions, plugins, org-specific config), so after installing, register a hook manually in its hooks block, e.g.:

"hooks": {
    "PreCompact": [
        {
            "matcher": "auto",
            "hooks": [{ "type": "command", "command": "bash ~/.claude/hooks/precompact-nudge.sh" }]
        }
    ]
}
  • precompact-nudge.sh — fires only on automatic compaction and prints a visible reminder to /clear instead if you're switching to an unrelated task, rather than letting one session run indefinitely.

Claude Code Mods

config/claude-mods/ holds Claude Code mods (plugins of function hooks). zsh/config.zsh exports CLAUDE_CODE_PLUGIN_DIRS with every folder there that has a .claude-plugin/, so each claude launched from a shell loads them; no settings.json change is needed. Interactive sessions watch these folders, so editing a mod reloads it live. Check one with claude plugin validate config/claude-mods/<name>.

  • context-gauge — context fill as a bar at the end of the prompt hint line (ctx ▰▱▱▱▱▱▱▱▱▱ 6% · 62k), plus a band above the prompt from 50% of the window (red from 75%) suggesting /clear before switching tasks. Thresholds are WARN_PCT / HOT_PCT in hooks/register.tsx.
  • git — a status-line entry with the folder, git branch and the branch's PR checks and review (~/.dotfiles ⎇ my-branch · #31 ✓5 ✗1 ●2 approved). PR status comes from gh and is polled every minute.
  • preview — /preview [file.md] (default README.md) renders a markdown file in a side pane: markdown through glow with One Dark / One Light styles (styles/*.json) that follow bin/toggle-theme, and mermaid blocks drawn as text diagrams by termaid (both in the Brewfile). Falls back to Claude Code's own markdown renderer, or the mermaid source, when either tool is missing.
  • runwatch — watches Terrakube jobs, Jenkins builds and PR checks in a side pane and toasts when each finishes (Terrakube shows the plan summary, e.g. plan: +2 ~0 -1, and toasts when a job waits for approval). Runs started by terrakube.sh run … --confirm, jenkins.sh trigger, gh pr create or git push are picked up automatically; /watch tk|jenkins|pr … adds one by hand, and Claude can hand one off through the mod's watch tool, which wakes it with the result instead of it polling. Polls every 20s through the ge-cloudops skills' wrapper scripts, so credentials stay in them.
  • write-gate — holds every Jira/Confluence write (comment, transition, edit, create, link, worklog, page), Lucid comment/share/update, git push and gh pr create|merge until you pick Post it. The exact payload (and, for a push, the commits no remote has) shows in a pane; Reject, or anything typed under Other, blocks it and tells Claude why. Fails closed, and logs each decision to ~/.claude/write-gate.log.

Usage

Vim Quick Reference

Leader key is Space.

KeyAction
<leader>kToggle file explorer (see explorer keymaps)
<leader>stStart screen
<leader>bClose buffer (keep split)
<leader>tGit file finder
<leader>eAll files finder
<leader>rBuffer finder
<leader>sGit status files
:RgRipgrep search
<leader>gsGit status
<leader>gdGit 3-way diff
gdh / gdlTake left/right in diff
<leader>dvoOpen Diffview
<leader>dvcClose Diffview
<leader>dvhDiffview file history
]g / [gNext/previous git hunk
gsPreview git hunk
guReset git hunk
gc / gccComment toggle

File Explorer Keymaps

The file explorer (nvim-tree) uses coc-explorer-style keybindings. Confirmations (y/n) are single-keypress — no Enter needed.

KeyAction
yyCopy file/directory (toggle, visual mode supported)
ddCut file/directory (toggle, visual mode supported)
pPaste from clipboard
dfDelete file/directory (trash)
dFDelete permanently
ypCopy absolute path to system clipboard
ynCopy filename to system clipboard
ACreate new directory
aCreate new file
EOpen in vertical split
VVisual select (then yy/dd/df for multi-file operations)

Copied files are highlighted in green, cut files in red with strikethrough.

Zsh Shortcuts

KeyAction
Alt + Right/LeftMove one word forward/backward
Cmd + Right/LeftMove to end/beginning of line
Alt + DDelete word after cursor
Alt + BackspaceDelete word before cursor
Ctrl + UClear entire line
Ctrl + RCommand history
Ctrl + TFile history

Troubleshooting

If you encounter permission errors during installation:

sudo chown -R $(whoami):admin /usr/local/
sudo chmod -R 755 /usr/local

Questions

If you have questions or notice issues, please open an issue.

Source 2 files
hooks/register.tsx 84 lines
1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { Gauge } from '../types'
5
6// Thresholds are a share of the model's context window, so they follow the
7// model: a band from WARN_PCT, turning red from HOT_PCT.
8const WARN_PCT = 50
9const HOT_PCT = 75
10const BAR_CELLS = 10
11
12const gauge = atom({ plugin: 'context-gauge', key: 'gauge' } as const, null)
13const isHidden = atom({ plugin: 'context-gauge', key: 'isHidden' } as const, false)
14// Drawn at the end of the prompt's hint line: a $.ui.status entry would carry
15// the plugin's name as a label.
16const line = atom({ plugin: 'context-gauge', key: 'line' } as const, '')
17
18const fmt = (n: number) => (n >= 1000 ? `${Math.round(n / 1000)}k` : `${n}`)
19
20const bar = (percent: number) => {
21  const filled = Math.min(BAR_CELLS, Math.round((percent / 100) * BAR_CELLS))
22  return '▰'.repeat(filled) + '▱'.repeat(BAR_CELLS - filled)
23}
24
25async function refresh($: EngineInterface) {
26  const usage = (await $.session.usage()).context
27  if (usage.tokens === undefined) {
28    await update($, gauge, () => null)
29    await update($, line, () => '')
30    return
31  }
32  const percent = usage.percent ?? Math.round((usage.tokens / usage.window) * 100)
33  const next: Gauge = { tokens: usage.tokens, percent }
34  await update($, gauge, () => next)
35  await update($, line, () => `ctx ${bar(percent)} ${percent}% · ${fmt(usage.tokens)}`)
36
37  if (percent < WARN_PCT) await update($, isHidden, () => false)
38}
39
40export const register: Register = on => {
41  on('session.start', async ($, e, next) => {
42    const result = await next(e)
43    await refresh($)
44    return result
45  })
46
47  // turn.step streams, so its hook is a generator; refresh after each main-thread response.
48  on('turn.step', async function* ($, e, next) {
49    const result = yield* next(e)
50    if (e.agentId === undefined) await refresh($)
51    return result
52  })
53
54  on('turn.complete', async ($, e, next) => {
55    const result = await next(e)
56    await refresh($)
57    return result
58  })
59
60  on('ui.render', { component: 'PromptHint' }, async ($, e, next) => {
61    const tail = await read($, line)
62    return next(tail ? { ...e, props: { ...e.props, tail: `  ${tail}` } } : e)
63  })
64
65  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
66    const g = await read($, gauge)
67    if (e.props.hasSurvey || g === null || g.percent < WARN_PCT || (await read($, isHidden))) {
68      return next(e)
69    }
70
71    const { Box, Button, Text } = $.ui.resolve(e)
72    const isHot = g.percent >= HOT_PCT
73
74    return (
75      <Box>
76        <Text color={isHot ? 'red' : 'yellow'}>
77          Context is {fmt(g.tokens)} ({g.percent}%). Switching tasks? /clear first.{' '}
78        </Text>
79        <Button key="hide" label="Hide" onPress={() => update($, isHidden, () => true)} />
80      </Box>
81    )
82  })
83}
84
types/index.d.ts 8 lines
1export type Gauge = { tokens: number; percent: number }
2
3declare module 'claude-code' {
4  interface PluginState {
5    'context-gauge': { gauge: Gauge | null; isHidden: boolean; line: string }
6  }
7}
8