2026-09-04 Dotfiles Comprehensive Audit and TDD Fixes

What I set out to do

Review the dotfiles codebase for improvements and obsolete cruft, clean up confirmed directory leftovers, ground and verify findings, and apply targeted fixes using test-driven development (TDD) for code changes under the Mandatory Dotfiles Change Protocol.

What I actually did

  1. Storage and Cruft Cleanup:

    • Removed orphaned Sonarr backup sonarr.backup.20260101 (46 MB reclaimed).
    • Removed obsolete superpowers directory containing ~94,000 JSONL session logs (765 MB reclaimed).
  2. Documentation and Bootstrap Fixes:

    • Resolved ADR filename collision by renumbering 0011-update-changelogs-resolution.md to 0027-update-changelogs-resolution.md.
    • Corrected manual bootstrap flake output targets in README.md to valid system double aarch64-darwin / x86_64-linux. Commit d2f5a24.
  3. Build Tooling and Pre-Commit Scoping:

    • Scoped just check and prek recipes with --config .pre-commit-config.yaml to avoid walking into nested subprojects where Astral’s ty hook collided on missing root pyproject.toml.
    • Fixed E501 line length in claude_ops/db.py. Commit 81b6430.
  4. Git and Shell Declarations:

    • Updated deprecated Git alias stash save to stash push in nix/home-manager/modules/git.nix. Commit 6db6f2e.
    • Removed erroneous Ghostty bundle ID from jankyborders launchd agent in nix/home-manager/modules/shell.nix. Commit c8deca9.
  5. Gemini Upstream Skills Path:

    • Corrected upstreamSkillsDir in gemini.nix to .gemini/antigravity-cli/skills, matching the upstream Home Manager module output and eliminating duplicate generated skill derivations in home.file. Commit 03d508e.
  6. Neovim Claude Session Path (TDD):

    • Extracted session path helper user.claude_session_path with URL-style path encoding and branch resolver caching.
    • Wired cache invalidation on FocusGained and DirChanged in project-session.lua so branch switches within the same working directory reflect accurately without stale session bindings.
    • Wrote headless test suite in nvim/tests/claude_session_path_spec.lua covering encoding, path formatting, directory changes, and explicit cache invalidation. Commit 22bcb88.
  7. Neovim Autocmds Optimization (TDD):

    • Wrote headless test suite in nvim/tests/autocmds_spec.lua asserting no active 1000ms polling timers and verifying pure in-process Python project root detection.
    • Removed redundant 1-second timer_start polling loop checktime_safe from config.autocmds, relying on existing event-driven autocmds (FocusGained, BufEnter, CursorHold, CursorHoldI, TermLeave, TermClose).
    • Replaced synchronous git rev-parse --show-toplevel process execution in setup_test_tab with vim.fs.root and vim.uv.fs_stat, eliminating external subprocess spawning during startup. Commit 5a5d18a.
  8. Pre-commit Unscoped Execution:

    • Reverted config scoping in justfile so check and prek execute across all files and discovered nested subprojects under nix/projects/. Commit 1867ea7.
  9. Detached HEAD Handling in Claude Session Path (TDD):

    • Updated user.claude_session_path and test suite claude_session_path_spec.lua so detached HEAD checkouts (during bisect, rebasing, or detached commits) do not collapse onto a shared HEAD session string, falling back to clean directory sessions. Commit 4340d8f.
  10. Test Tab Generalization & Neotest Safeguard (TDD):

    • Updated config.autocmds and test suite autocmds_spec.lua to generalize project root detection to Rust, Go, and JS/TS projects (Cargo.toml, go.mod, package.json).
    • Replaced synchronous fd subprocess invocation with in-process vim.fs.find.
    • Guarded Neotest window commands (Neotest summary, Neotest output-panel) inside an active Neotest check. Commit 4a19e3b.
  11. Claude Polling Timer Lifecycle:

    • Wired a BufWipeout/TermClose buffer-local autocmd in project-session.lua to terminate and close the Claude session polling timer immediately if the terminal buffer closes before 10 attempts elapse. Commit 3af28e2.
  12. Dependency-Only Project Pre-Commit Cleanup:

    • Removed unused ty and pytest-unit hooks from nix/projects/obsidian-mcp-proxy/.pre-commit-config.yaml because it contains no first-party Python source files. Commit fab3be0.
  13. Antigravity Skills Target Directory Alignment:

    • Updated targetSkillsDir in gemini.nix to .gemini/config/skills, aligning with Antigravity’s machine-global customization discovery path. Commit 44dccf9.
  14. Codex Auto-Review and Guardian Configuration:

    • Configured approvals_reviewer = "auto_review" and review_model = "openrouter/z-ai/glm-5.3-flash" in nix/home-manager/modules/coding-agents/codex/codex.nix.
    • Applied declarative configuration via hm switch to update ~/.codex/config.toml.
    • Verified pre-commit checks with just check and verified live execution with codex doctor and test turn. Commit b9da28b.
  15. Antigravity Default Agent Mode:

    • Configured agentMode = "accept-edits" in nix/home-manager/modules/coding-agents/gemini/gemini.nix.
    • Applied declarative configuration via hm switch to update ~/.gemini/antigravity-cli/settings.json.
    • Verified pre-commit checks with just check. Commit 8eab966.

Verification

  • Headless Neovim test suites (autocmds_spec.lua, claude_session_owner_spec.lua, claude_session_path_spec.lua, and claude_window_spec.lua) all pass cleanly.
  • just check runs across all files and nested projects with zero errors.
  • Flake checks for both root and Home Manager flakes pass all derivations and unit tests.
  • Codex configuration verified via hm switch and codex doctor.
  • Antigravity settings verified via hm switch and inspected settings.json.