Skip to content

Instantly share code, notes, and snippets.

@dui
dui / README.md
Created September 2, 2026 22:46
Cryptographically signed code reviews with a fail-closed merge gate

A merge gate the coding agent cannot impersonate

I am experimenting with separating writing code from authorizing code. The coding agent can push a branch and open a pull request. It cannot produce the cryptographic evidence required to merge that pull request, and it does not hold the merge credential.

This is the smallest useful version of the design behind Herdacat. The included demo is deliberately local and forge-independent so you can run it without creating bots, apps, or cloud infrastructure.

@dui
dui / AwakeMenubar.swift
Created August 17, 2026 12:05
Keep a clamshell Mac awake reliably: caffeinate -is LaunchAgent + toggle script + 97-line Swift menu bar app that shows the live pmset assertion state (truth, not config)
// AwakeMenubar — menu-bar truth indicator + toggle for the fi.dui.keepawake
// LaunchAgent (caffeinate -is). Shows the live assertion state, never config:
// cup (filled) = PreventSystemSleep held (survives monitor-pull, lid closed, on AC)
// zzz = not held (that pull will sleep the Mac)
// dotted circle = unknown (before the first read, or while toggling)
// Icons are SF Symbols template images, so they match the menu bar's own
// monochrome and adapt to light/dark. Left-click toggles via
// ~/.local/bin/awake on|off. Polls every 5s, reads off the main thread.
// Built locally with swiftc; no third-party code.
import AppKit
@dui
dui / README.md
Created August 6, 2026 21:10
A personal finance system where the rules engine is a markdown file — synthetic-data template (taxonomy, budgets, categorization guide, sample self-contained HTML report)

fincc — a personal finance system where the rules engine is a markdown file

This is a synthetic-data template of the personal finance system I run with Claude. All merchants, names, and amounts here are fake; the structure is the real thing.

The architecture

taxonomy.yaml # scopes + categories (the vocabulary)
@dui
dui / codex-remote.zsh
Created May 18, 2026 21:53
Run codex's TUI and app-server as separate processes so other TUIs/tools can attach to the same session
# Spawn codex's app-server on a free port and attach a TUI to it via --remote.
# By default, codex's TUI bundles its own app-server. Splitting them lets other
# TUIs or tools plug into the same running session.
#
# Usage:
# cr # random free port, server dies with TUI
# cr --keep # leave the server running after TUI exits
# cr 8765 # use port 8765 (start server if not already up)
# cr ws://host:8765 # attach TUI to an already-running app-server
codex-remote() {
@dui
dui / nanonu-codex-day1.md
Created May 7, 2026 00:04
nanonu — Codex day-1 transcript (iOS diet tracker, 18 turns, ~2h to working build)

nanonu — Codex day-1 transcript

Source: Codex VSCode session (~/.codex/sessions/2026/04/25/rollout-...jsonl).

Date: 2026-04-25 (single session, ~7h elapsed wall clock — ~2h to first working build on phone). Turns: 18 user prompts.

Filtered: user prompt + final assistant response per turn (running status commentary stripped).


@dui
dui / README.md
Created April 15, 2026 13:21
Claude Code statusline — two-line bar with context window breakdown, per-call tokens, 5h/7d rate limits, and $ cost

Claude Code Statusline

A two-line statusline for Claude Code showing:

Line 1 — working dir, git branch, context window bar with breakdown (system / messages / free / autocompact buffer), per-call token buckets (new / cache write / cache read / output), session totals, lines changed.

Line 2 — 5-hour rate-limit %, 7-day rate-limit %, session $ cost with per-bucket breakdown, 5h-window $ total, 7-day $ total, wall-clock time.

Requirements

@dui
dui / statusline.sh
Created April 11, 2026 00:07
Claude Code statusline — 2-line context bar with token buckets, 5h/7d rate limits, $ cost breakdown. Pairs with cc_cost.py.
#!/bin/bash
input=$(cat)
# One-shot debug dump: write the latest received JSON so we can verify what
# Claude Code actually sends. Safe to leave on; it's a single file overwrite.
echo "$input" > /tmp/claude-statusline-last.json
# ── Colors ────────────────────────────────────────────────────────
RESET="\033[0m"
GREEN="\033[38;2;74;222;128m"
YELLOW="\033[33m"
@dui
dui / cc_cost.py
Created April 11, 2026 00:05
cc_cost.py — historical token/cost reports against ~/.claude/projects (5h window, 7d, per-day, top windows). Dedupes globally on msg_id.
#!/usr/bin/env python3
"""
cc_cost — quick token / $-cost queries against ~/.claude/projects.
For LIVE current-session info, prefer the authoritative numbers from
Claude Code's statusline JSON (`cost.total_cost_usd`, `rate_limits.*`).
This script is for HISTORICAL queries (per-day, per-window, since-X) that
Claude Code doesn't surface directly.
Usage:
@dui
dui / cc_cost.py
Created April 10, 2026 00:39
cc_cost — see how much you're spending on Claude Code Max in API-equivalent dollars
#!/usr/bin/env python3
"""
cc_cost — quick token / $-cost queries against ~/.claude/projects.
For LIVE current-session info, prefer the authoritative numbers from
Claude Code's statusline JSON (`cost.total_cost_usd`, `rate_limits.*`).
This script is for HISTORICAL queries (per-day, per-window, since-X) that
Claude Code doesn't surface directly.
Usage:
@dui
dui / claude-usage-analysis.md
Last active April 7, 2026 23:31
Claude Code usage analysis — 5h window breakdown with cost ($) at Opus 4.6 list pricing, deduped on msg_id (corrected after discovering streaming-chunk + cross-file replication bugs)

Claude Code Usage Limit Analysis

User: @dui_toledo (Max 20x / $200 plan) Models in dataset: claude-opus-4-5 (Jan 20 – Feb 5) → claude-opus-4-6 (Feb 6 → present), reasoning effort high throughout. Both share the same price tier ($5 / $6.25 / $0.50 / $25 per MTok). Timezone: UTC-3 (BRT, São Paulo) Original report: 2026-04-06 (since corrected — see below) Latest revision: 2026-04-07 evening (added $-cost view, then found a second over-count bug — duplicate streaming chunks + cross-file replication. Numbers are now ~14x lower than the prior revision.)

Two methodology bugs (both now fixed)