Drupal is a registered trademark of Dries Buytaert
Release: Leaflet 10.4.11 Minor update available for module leaflet (10.4.11). Release: Session Inspector 1.0.8 Minor update available for module session_inspector (1.0.8). Release: Migrate QA 2.0.4 Minor update available for module migrate_qa (2.0.4). Release: CKEditor Description List 3.0.0 Major update available for module ckeditor_descriptionlist (3.0.0). Release: FlowDrop 2.4.0 Minor update available for module flowdrop (2.4.0). Release: JWT Token Refresh 1.0.4 Minor update available for module jwt_token_refresh (1.0.4). Release: ConReg 1.0.0-beta1 First beta version released for module conreg (1.0.0-beta1). Release: AI Image Studio 1.0.0-beta8 New beta version released for module ai_image_studio (1.0.0-beta8). Usage Milestone: Role Theme Switcher Module role_theme_switcher crossed 1,000 active installs. Module Revived: Decoupled Router 2.0.7 Module decoupled_router updated after 11 months of inactivity (2.0.7).

Drush Token Killer

8 sites Security covered
View on drupal.org

This module provides compressed output for Drush commands to reduce token usage by AI agents. It allows you to selectively enable these optimizations on a per-command, per-session, or permanent basis, without altering the output for standard terminal use. Compression works by modifying existing commands to output fewer fields and use CSV formatting, significantly shrinking the data returned.

Drush DTK - the "Drush Token Killer" - provides token-saving output defaults for common Drush commands. Inspired by RTK (the "Rust Token Killer"), it shrinks the output of frequently-run, read-only Drush commands so that AI agents (and humans) spend far fewer tokens reading them.

Opt-in compression. Enabling the module changes nothing for humans at a terminal - you (or your agent) switch it on per command, per session, or permanently. See "Enabling compression" below.

It works with lightweight Drush hooks that, when you have not asked for specific output yourself, select a compact set of fields and force CSV to drop the wide ASCII table chrome. No commands are added for everyday use - the module only alters the output of existing core and contrib Drush commands.

How it works

Each supported command has an INITIALIZE hook that, when compression is enabled, sets sensible defaults (--fields and/or --format=csv) before the command runs. config:status also has an ALTER_RESULT hook that rewrites its verbose state strings to short tokens. The original commands and their behaviour are otherwise untouched.

Enabling compression

Three opt-in surfaces, highest precedence first:

  • --ai-compress flag - one command, e.g. drush pml --ai-compress
  • DTK_COMPRESS=1 environment variable - one session; recommended for agents, since they invoke Drush through wrappers where injecting flags is awkward
  • Config - drush config:set dtk.settings compress 1 for always-on

DTK_COMPRESS=0 (also false, no, off) explicitly disables compression, overriding the config. --no-ai-compress on any command beats everything and restores native output. There is deliberately no TTY or "am I an agent?" detection - output only changes when something asked for it.

Agent hooks

One command wires DTK_COMPRESS=1 into an agent's project-level config:

drush dtk:install claude     # merges into .claude/settings.json
drush dtk:install codex      # adds to .codex/config.toml
drush dtk:install opencode   # prints the manual step
drush dtk:install copilot    # prints the manual step

Compressed commands

Defaults applied when compression is enabled:

Command Default applied Savings pm:list (pml) --status=<wbr>enabled|<wbr>disabled--fields=<wbr>name; otherwise --fields=<wbr>name,<wbr>status; CSV up to 90% core:requirements (rq) --severity=1 (warnings + errors only), --fields=<wbr>title,<wbr>severity, CSV up to 97% config:status (cst) CSV + state tokens (see below) up to 45% watchdog:show (ws) --fields=<wbr>type,<wbr>severity,<wbr>message, CSV up to 50% role:list (rls) --fields=<wbr>rid,<wbr>label, CSV (native default is YAML) up to 50% queue:list CSV small migrate:status (ms) CSV varies migrate:messages (mmsg) --fields=<wbr>level,<wbr>source_ids,<wbr>message, CSV up to 40% field:info (fi) CSV varies field:base-info (fbi) --fields=<wbr>field_name,<wbr>field_type,<wbr>required,<wbr>cardinality, CSV up to 70% field:types --fields=<wbr>id,<wbr>label (native YAML kept — result can't render as CSV) up to 80% field:formatters --fields=<wbr>id,<wbr>label,<wbr>field_types (native YAML kept — result can't render as CSV) up to 70% field:widgets --fields=<wbr>id,<wbr>label,<wbr>field_types (native YAML kept — result can't render as CSV) up to 70% updatedb:status (updbst) --fields=<wbr>module,<wbr>update_id,<wbr>description, CSV up to 50% user:information (uinf) --fields=<wbr>uid,<wbr>name,<wbr>mail,<wbr>user_status, CSV up to 60% deploy:hook-status CSV small

Contrib module compressed commands

Compressed only when the owning module is installed; with it absent the hook never fires. The Devel rows also require Drush 13.7+ (see Requirements).

Command Module Default applied Savings devel:services (dcs) Devel CSV (single id column) ~67% devel:token (token) Devel --fields=group,token, CSV ~85% search-api:list (sapi-l) Search API --fields=id,serverName,status, CSV Varies search-api:status (sapi-s) Search API --fields=id,complete,indexed,total, CSV Varies search-api:server-list (sapi-sl) Search API --fields=id,status, CSV Varies search-api:search (sapi-search) Search API CSV Small views:bulk-operations:list (vbo-list) Views Bulk Operations --fields=id,entity_type_id, CSV Small

config:status state tokens

The verbose state strings are collapsed to single tokens:

The --state filter still works with the original strings (e.g. drush config:status --state='Only in DB'), because the tokenisation runs after the command has already filtered.

Opting out

Even when compression is enabled, add --no-ai-compress to any command to get its native, uncompressed output:

drush pml --no-ai-compress

Compression is also skipped automatically whenever you choose your own output, i.e. you pass --field or --fields (and, for format, any --format other than the command's native default).

Limitations

  • Pre-bootstrap commands cannot be compressed. Commands that run before Drupal's modules load - notably core:status and cache:rebuild (cr) - never receive this module's hooks. core:status --no-ai-compress even reports "option does not exist". This is inherent to module-provided Drush hooks.
  • config:import / config:export previews are not reformatted. Those commands print their change preview as a hardcoded Symfony Console table straight to the terminal, mid-command, before the confirmation prompt - there is no formatter hook to retarget it. To preview pending config changes as CSV, use config:status instead (its only_sync / only_db / different tokens are the same information framed as create / delete / update).

Requirements

  • Drupal ^11
  • Drush 13+

Installation

drush en dtk
drush cr

Contributing

The Drush Token Killer module's issue queue is intended for reporting bugs, submitting feature requests, and planning.


Additionally, you can join the #ai-contrib or #ai-learners channels on Drupal Slack.

Activity

Tracked releases
3
Tracked since
Jul 2026
Latest release
1 month ago
Releases (12 mo)
3 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Release date
1.0.0 Stable Jul 10, 2026
1.0.0-beta1 Pre-release Jul 9, 2026
1.0.x-dev Dev Jul 7, 2026