Skip to content

HandyS11/DotnetTokenKiller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

DotnetTokenKiller

A .NET CLI proxy that reduces LLM token usage by filtering the verbose output of dotnet commands down to only what matters.

CI CD License

codecov Mutation testing badge

DotnetTokenKiller NuGet DotnetTokenKiller Downloads

The Problem

When AI coding agents run dotnet build or dotnet test, the output is packed with noise — SDK banners, MSBuild headers, progress indicators, ANSI escape codes, duplicate messages, and framework internals. A typical dotnet test run can produce 200+ lines where only 5–10 actually matter. Every extra line burns tokens, inflates cost, and wastes precious context window space.

Example: 27 lines of raw dotnet test output → 5 lines with dtk

Before (raw dotnet test):

Restore complete (0.4s)
  SampleApp.Tests succeeded (0.1s) → bin/Debug/net10.0/SampleApp.Tests.dll
  SampleApp succeeded (0.1s) → bin/Debug/net10.0/SampleApp.dll
  Build succeeded in 0.8s
Test run for /home/user/samples/SampleApp.Tests/bin/Debug/net10.0/SampleApp.Tests.dll (.NETCoreApp,Version=v10.0)
VSTest version 17.13.0 (x64)
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
  Failed AlwaysFails [5 ms]
  Error Message:
   Intentional failure
  Stack Trace:
     at SampleApp.Tests.IntentionallyFailingTests.AlwaysFails() in /home/user/samples/SampleApp.Tests/IntentionallyFailingTests.cs:line 8

Failed!  - Failed:     1, Passed:     3, Skipped:     0, Total:     4, Duration: 42 ms

After (dtk dotnet test):

FAILURES (1):
  SampleApp.Tests.IntentionallyFailingTests.AlwaysFails [5 ms]
    Intentional failure
    at samples/SampleApp.Tests/IntentionallyFailingTests.cs:line 8
dotnet test: 1 failed, 3 passed (1 project, 0.07s)

DTK strips all the noise and returns a compact, signal-only result. Fewer tokens in means lower cost and less context consumed.

Features at a Glance

  • Build filtering — strips MSBuild noise, keeps only errors, warnings, and a compact summary (~78% savings)
  • Test filtering — removes adapter banners, license warnings, and reflection stack frames (~84% savings)
  • Restore/Clean filtering — condenses output to essentials (~47–98% savings)
  • Format filtering — shows only violations with workspace-relative paths
  • 7 AI agent integrations — Claude Code, GitHub Copilot, Gemini CLI, Cursor, Windsurf, Aider, JetBrains AI
  • Token analytics — tracks per-command savings over time with dtk gain
  • Self-diagnosticsdtk doctor validates your setup in one command
  • Shell completion — bash, zsh, fish, and PowerShell
  • Log teeing — optionally saves raw output to disk for post-mortem inspection

Installation

# Requires .NET 10 SDK (https://dotnet.microsoft.com/download) — full SDK, not just runtime
dotnet tool install -g DotnetTokenKiller

To update an existing installation:

dotnet tool update -g DotnetTokenKiller

To uninstall:

dotnet tool uninstall -g DotnetTokenKiller

Usage

Prefix any supported dotnet command with dtk:

dtk dotnet build
dtk dotnet test --filter "Category=Unit"
dtk dotnet restore
dtk dotnet clean
dtk dotnet format
dtk dotnet format --verify-no-changes

Unknown subcommands pass through to dotnet unchanged.

AI Agent Setup

Install integration artifacts with one command:

Provider Command What it creates
Claude Code dtk integrate claude Skill file, PreToolUse hook, settings merge
GitHub Copilot dtk integrate copilot Section in .github/copilot-instructions.md
Gemini CLI dtk integrate gemini BeforeTool hook, settings merge, GEMINI.md section
Cursor dtk integrate cursor .cursor/rules/dtk.mdc
Windsurf dtk integrate windsurf .windsurf/rules/dtk.md
Aider dtk integrate aider Instructions file, .aider.conf.yml section
JetBrains AI dtk integrate jetbrains Section in .junie/guidelines.md

All commands are idempotent — re-running is safe. Pass --force to refresh existing files.

See AI Agent Setup for per-provider details and manual installation steps.

Token Savings Analytics

dtk gain               # last 30 days
dtk gain --days 7
dtk gain --project     # current project only
dtk gain --json

Example:

┌─────────┬──────┬──────────────┬──────────────┬─────────┬─────────────┐
│ Command │ Runs │ Without Tool │ Used by Tool │   Saved │ Avg Savings │
├─────────┼──────┼──────────────┼──────────────┼─────────┼─────────────┤
│ build   │  749 │      1925317 │       327044 │ 1598273 │       79.4% │
│ clean   │  145 │        85875 │          870 │   85005 │       98.0% │
│ restore │  242 │        28793 │         8959 │   19834 │       46.9% │
│ test    │ 1011 │       795760 │       201134 │  594626 │       78.9% │
│         │      │              │              │         │             │
│ TOTAL   │ 2147 │      2835745 │       538007 │ 2297738 │       81.0% │
└─────────┴──────┴──────────────┴──────────────┴─────────┴─────────────┘

To reset tracking data: dtk reset (or dtk reset --force to skip confirmation).

Diagnostics

dtk doctor

Checks dotnet SDK, config file, tracking database, and tee directory. Exits 1 if any check fails.

Configuration

Manage settings via CLI or edit ~/.config/dtk/config.json directly:

dtk config show                              # display all current values
dtk config set tracking.enabled false
dtk config set tracking.retentionDays 30
dtk config set display.width 100
dtk config set tee.mode Always

Supported keys: tracking.enabled, tracking.retentionDays, tracking.dbPath, tracking.tokenizer, display.colors, display.emoji, display.width, tee.mode, tee.directory, tee.maxFiles, tee.maxFileSizeBytes.

See Configuration for defaults, valid values, and the full JSON schema.

Shell Completion

bash — write to a dedicated file (preferred) or to the system-wide completions directory:

dtk completion bash > ~/.bash_completion
# or system-wide:
dtk completion bash > /etc/bash_completion.d/dtk

zsh — the script must live in $fpath, not be sourced inline:

mkdir -p ~/.zfunc && dtk completion zsh > ~/.zfunc/_dtk

Then add these two lines to ~/.zshrc (before any existing compinit call):

fpath=(~/.zfunc $fpath)
autoload -Uz compinit && compinit

fish

dtk completion fish > ~/.config/fish/completions/dtk.fish

PowerShell

dtk completion powershell >> $PROFILE

Log Files

DTK saves raw command output to disk for failed runs by default (tee.mode = failures). Pass --show-log to print the log path after any run:

dtk dotnet test --show-log

Inspiration

Inspired by rtk. DTK takes the same idea — filtering noisy CLI output for AI agents — and rebuilds it natively in .NET with per-command filters, a richer feature set (token analytics, shell completion, multi-agent integration), and first-class support for the full dotnet CLI surface.

Documentation

For more details see the full documentation.

About

.NET CLI proxy that aim to reduce the LLM token usage though the dotnet commands

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages