Skip to content

Instantly share code, notes, and snippets.

View tonydzi's full-sized avatar

Anton Dziatkovskii tonydzi

View GitHub Profile
@tonydzi
tonydzi / Fix-ClaudeDesktopMSIX.ps1
Created August 24, 2026 16:59
Claude Desktop (Windows MSIX) repair ladder for 'Modified, NeedsRemediation' - field-tested 2026-08-24; never registers a healthy package (0x80070005 corruption path), lets Windows' own remediation run first, Register only when partially staged, clean-reinstall end state (login survives in %LOCALAPPDATA%)
# Fix-ClaudeDesktopMSIX.ps1
#
# Diagnose + repair ladder for Claude Desktop (Windows MSIX) stuck in
# "Modified, NeedsRemediation" / refusing to launch.
#
# Field-tested 2026-08-24 on Windows 11 (build 26200) while debugging this class:
# https://github.com/anthropics/claude-code/issues/84333 (and siblings)
#
# Key facts this script encodes (all reproduced live):
# 1. Running `Add-AppxPackage -Register` on a HEALTHY package is a CORRUPTION
@tonydzi
tonydzi / README.md
Last active August 24, 2026 23:12
Claude Code workdir sentry: SessionStart hook that warns when a session starts outside the machine's canonical project dir (project memory/CLAUDE.md/history are keyed to cwd)

Claude Code workdir sentry

One tiny SessionStart hook that tells Claude (and you) when a session started in the wrong folder — before you lose a day of context.

The problem this fixes

Claude Code keys three things to the directory a session starts in:

  1. Project memory (auto-memory) — lives in ~/.claude/projects/<encoded-cwd>/memory/
  2. Session history — same per-directory bucket
@tonydzi
tonydzi / claude_task_audit.py
Created August 24, 2026 18:04
Audit Claude Desktop scheduled tasks: which are reusable, and which will stop on a permission prompt (reads per-task permissionMode from local session state; unions all task stores)
#!/usr/bin/env python3
"""claude_task_audit.py - audit Claude Desktop scheduled tasks: which ones are
reusable, and which ones will stop and ask for permission on their next run.
Why this exists
---------------
Scheduled ("routine") tasks each carry their OWN permission mode, and the desktop
UI is the only place that shows it. If a task falls back to a prompting mode, you
find out hours later, from a dialog nobody clicked. Two facts make that auditable
and largely avoidable, both verified by measurement (2026-08-24, Windows hub +
@tonydzi
tonydzi / README.md
Last active August 26, 2026 21:18
scheduled-tasks-doctor: find and restore Claude Desktop routines that vanished from the Routines list (registry is per-account; prompts survive on disk)

scheduled-tasks-doctor

Your Claude Desktop routines vanished from the Routines list — after an app update, after signing in with a different account, or for no visible reason at all. This finds them and puts them back.

They are almost certainly not deleted. The app splits a routine across two places:

what where survives an app update?
@tonydzi
tonydzi / api_wait_gaps.py
Created August 25, 2026 07:57
Measure API-wait stalls across a whole Claude Code transcript corpus (stdlib only, read-only)
#!/usr/bin/env python3
"""api_wait_gaps.py - measure API-wait stalls across a whole Claude Code transcript corpus.
A "stall" here = wall-clock time in which the RUNTIME owed the next event and no bytes
arrived. Only two record pairs qualify:
tool_result -> assistant (tool came back, model has not spoken yet)
assistant -> assistant (mid-stream continuation)
Why the restriction matters: a naive "every gap >= 60s" scan over a corpus is dominated by
@tonydzi
tonydzi / headroom_v208_residual_check.py
Created August 26, 2026 21:21
headroom v2.0.8: simulate the shipped MessageDeduper against a log tree and classify what survives it (replay + partial-snapshot classes)
"""Verify headroom v2.0.8's MessageDeduper against a Windows hub log tree.
Simulates the shipped O(1) rule (drop a usage record whose message.id equals the
PREVIOUS record's message.id) and measures what inflation survives it, then
classifies the survivors:
A REPLAY - the identical record (same uuid) is written again later in the file
B PARTIAL - one message.id carries DIFFERENT usage payloads (streaming snapshots)
Ground truth for "how many real messages" = distinct uuid, since uuid is unique
per written record and a replay repeats it verbatim.
0 LLM tokens, read-only.