Add statusline scripts, context-load improvements, and prior distill updates

- Add statusline.sh and set-topic.sh for per-session status line topics
- Update context-load with improved directory walking and output format
- Update CLAUDE.md with status line docs and early-call safety note
- Update MEMORY.md and README.md with new script/skill entries
- Add memory files: script-statusline, skill-decompose, skill-orchestrate, gotchas-gitea
- Add networking.md best practice (nftables, systemd sockets, Docker forwarding, TLS)
- Update best practices from prior distill: documentation, kubernetes, scripting,
  secrets-management, skills-development
- Prune reflected session logs, add new session logs
- Update reflection state

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul O'Reilly
2026-03-25 11:11:40 +13:00
parent 6c0f2db169
commit e7c8214499
25 changed files with 396 additions and 98 deletions

View File

@@ -36,8 +36,8 @@ emit_file() {
emit_tree() {
local dir="$1"
emit_header "TREE: $dir (depth $TREE_DEPTH)"
tree -L "$TREE_DEPTH" --charset utf-8 -I '.git|node_modules|__pycache__|.venv|venv' "$dir" 2>/dev/null \
|| find "$dir" -maxdepth "$TREE_DEPTH" -not -path '*/.git/*' -not -path '*/.git' | sort
tree -L "$TREE_DEPTH" --charset utf-8 -I '.git|node_modules|__pycache__|.venv|venv|customers' "$dir" 2>/dev/null \
|| find "$dir" -maxdepth "$TREE_DEPTH" -not -path '*/.git/*' -not -path '*/.git' -not -path '*/customers/*' -not -path '*/customers' | sort
echo ""
}

28
scripts/set-topic.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Usage: set-topic.sh <cwd> <topic text>
# Finds the session ID for the given cwd and writes the topic file
set -euo pipefail
CWD="$1"
shift
TOPIC="$*"
HASH=$(echo -n "$CWD" | md5sum | cut -d' ' -f1)
SESSION_FILE="/tmp/claude-session-id-$HASH"
if [[ ! -f "$SESSION_FILE" ]]; then
# Session ID file doesn't exist yet — the statusline hook hasn't run.
# Write the topic to a pending file so statusline.sh can pick it up
# on its first run for this cwd.
PENDING_FILE="/tmp/claude-pending-topic-$HASH"
echo "$TOPIC" > "$PENDING_FILE"
echo "Topic queued (session ID not yet available). Will be applied after next response."
exit 0
fi
SESSION_ID=$(cat "$SESSION_FILE")
TOPIC_DIR="$HOME/.claude/status/$SESSION_ID"
mkdir -p "$TOPIC_DIR"
echo "$TOPIC" > "$TOPIC_DIR/claude-topic.txt"
echo "Topic set for session $SESSION_ID: $TOPIC"

40
scripts/statusline.sh Executable file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Claude Code status line: shows topic, model, and context usage
# Reads session JSON from stdin, displays topic from per-session file
set -euo pipefail
DATA=$(cat)
SESSION_ID=$(echo "$DATA" | jq -r '.session_id // empty')
MODEL=$(echo "$DATA" | jq -r '.model.display_name // "unknown"')
CONTEXT_PCT=$(echo "$DATA" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)
TOPIC=""
if [[ -n "$SESSION_ID" ]]; then
# Write session ID to a known location so Claude can discover it
CWD=$(echo "$DATA" | jq -r '.cwd // empty')
if [[ -n "$CWD" ]]; then
HASH=$(echo -n "$CWD" | md5sum | cut -d' ' -f1)
echo "$SESSION_ID" > "/tmp/claude-session-id-$HASH"
# Apply any pending topic that was set before the session ID existed
PENDING_FILE="/tmp/claude-pending-topic-$HASH"
if [[ -f "$PENDING_FILE" ]]; then
TOPIC_DIR="$HOME/.claude/status/$SESSION_ID"
mkdir -p "$TOPIC_DIR"
mv "$PENDING_FILE" "$TOPIC_DIR/claude-topic.txt"
fi
fi
TOPIC_FILE="$HOME/.claude/status/$SESSION_ID/claude-topic.txt"
if [[ -f "$TOPIC_FILE" ]]; then
TOPIC=$(cat "$TOPIC_FILE")
fi
fi
if [[ -n "$TOPIC" ]]; then
echo "[$MODEL] $TOPIC | ${CONTEXT_PCT}% context"
else
echo "[$MODEL] ${CONTEXT_PCT}% context"
fi