feat: AIDLC_DISABLE_USAGE_TRACKING kill switch for Claude usage tracking (2.5.53) - #720
Merged
Conversation
apackeer
force-pushed
the
feat/usage-tracking-optout
branch
from
August 6, 2026 10:56
e0cb5fc to
2c2e28e
Compare
leandrodamascena
approved these changes
Aug 6, 2026
leandrodamascena
left a comment
Contributor
There was a problem hiding this comment.
Approved from my review. The kill switch consistently gates ledger writes, transcript pointers, statusline reads, and completion rollups while preserving existing history. Focused tests and repository checks pass.
Non-blocking: update the PR body’s stale 2.5.42 reference to 2.5.53.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a kill switch for the Claude Code token-usage and cost tracking that shipped in 2.5.40 (#673). Local tracking stays on by default; set
AIDLC_DISABLE_USAGE_TRACKING=1to turn all of it off.Why
2.5.40 shipped the usage ledger, the statusline
↑in ↓out $costsegment, and the completion-event cost rollups with no way to turn them off short of hand-editing the installedsettings.json. Every other behavior-bearing hook already has anAIDLC_DISABLE_*escape hatch (reviewer-scope, review-freeze); this brings the usage producer in line.Default-on was kept deliberately: cost history cannot be backfilled after the fact, so an install that wants it later should not have silently missed it. The flag is for installs that do not want a cost readout on screen or a usage ledger on disk at all.
Behavior
With
AIDLC_DISABLE_USAGE_TRACKING=1:STAGE_COMPLETED/WORKFLOW_COMPLETEDadd no rollup fields.aidlc/.aidlc-sessions/usage-ledger.jsonmanually if the history should go too.Unset or any value other than the exact string
1leaves tracking on, matching theAIDLC_DISABLE_*convention. Metrics emission is unchanged (still separately opt-in viaAIDLC_METRICS_ENDPOINT).Design
One predicate (
usageTrackingDisabled()incore/tools/aidlc-usage.ts) gates both ends of the seam: the producer (foldTranscriptIntoLedger,writeCurrentTranscriptPath, plus an early exit in the fold hook itself) and the consumers (stageUsageAuditFields,workflowUsageAuditFields,sessionUsageAggregate). Consumers are gated too so a pre-existing ledger goes quiet everywhere with one flag. Read at call time, never cached.Versioning
Re-slotted to 2.5.53; based on v2 @ e135e8e.
Testing
t271-usage-tracking-kill-switch(4 tests): exact-"1" flag parse, silent producer (no ledger file, no pointers), quiet consumers over a recorded ledger, and ledger survival + history resume across a toggle.costSegmentrenders↑10 ↓100 $0.00with the flag unset,""with it set, ledger file intact.package.ts --check,gen-coverage-registry --check, typecheck, biome all clean.