Skip to content

DCP Command Guide: Monitor and Manual Pruning

What You'll Learn

  • Use /dcp context to view current session's token usage distribution
  • Use /dcp stats to view cumulative pruning statistics
  • Use /dcp sweep [n] to manually trigger pruning
  • Understand protected tools and files protection mechanisms
  • Learn token calculation strategies and savings effectiveness

Your Current Challenge

In long conversations, token consumption accelerates, but you don't know:

  • Where are the tokens being spent in the current session?
  • How much has DCP actually saved for you?
  • How to manually clean up tool outputs that are no longer needed?
  • Which tools are protected and won't be pruned?

Without understanding these issues, you may not fully leverage DCP's optimization effects, and you might accidentally delete important information at critical moments.

When to Use This

When you:

  • Want to understand the token composition of the current session
  • Need to quickly clean up conversation history
  • Want to verify DCP's pruning effectiveness
  • Want to clean up context before starting a new task

Core Concept

DCP provides 4 slash commands to help you monitor and control token usage:

CommandPurposeUse Case
/dcpDisplay helpView when you forget commands
/dcp contextAnalyze current session token distributionUnderstand context composition
/dcp statsView cumulative pruning statisticsVerify long-term effects
/dcp sweep [n]Manual tool pruningQuickly reduce context size

Protection Mechanism:

All pruning operations automatically skip:

  • Protected Tools: task, todowrite, todoread, discard, extract, batch, write, edit, plan_enter, plan_exit
  • Protected Files: File paths matching protectedFilePatterns in configuration

INFO

Protected tools and protected file settings can be customized through configuration files. See Configuration Guide for details.

Follow Along

Step 1: View Help Information

Type /dcp in the OpenCode chat box.

You should see:

╭───────────────────────────────────────────────────────────╮
│                      DCP Commands                         │
╰───────────────────────────────────────────────────────────╯

  /dcp context      Show token usage breakdown for current session
  /dcp stats        Show DCP pruning statistics
  /dcp sweep [n]    Prune tools since last user message, or last n tools

Checkpoint ✅: Confirm you see the descriptions of 3 subcommands.

Step 2: Analyze Current Session Token Distribution

Type /dcp context to view the current session's token usage.

You should see:

╭───────────────────────────────────────────────────────────╮
│                  DCP Context Analysis                     │
╰───────────────────────────────────────────────────────────╯

Session Context Breakdown:
────────────────────────────────────────────────────────────

System         15.2% │████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│  25.1K tokens
User            5.1% │████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│   8.4K tokens
Assistant       35.8% │██████████████████████████████████████▒▒▒▒▒▒▒│  59.2K tokens
Tools (45)      43.9% │████████████████████████████████████████████████│  72.6K tokens

────────────────────────────────────────────────────────────

Summary:
  Pruned:          12 tools (~15.2K tokens)
  Current context: ~165.3K tokens
  Without DCP:     ~180.5K tokens

Token Category Explanation:

CategoryCalculationDescription
SystemfirstAssistant.input + cache.read - tokenizer(firstUserMessage)System prompt
Toolstokenizer(toolInputs + toolOutputs) - prunedTokensTool calls (pruned portion deducted)
Usertokenizer(all user messages)All user messages
Assistanttotal - system - user - toolsAI text output + reasoning tokens

Checkpoint ✅: Confirm you see the percentage and token count for each category.

Step 3: View Cumulative Pruning Statistics

Type /dcp stats to view the historical cumulative pruning effectiveness.

You should see:

╭───────────────────────────────────────────────────────────╮
│                    DCP Statistics                         │
╰───────────────────────────────────────────────────────────╯

Session:
────────────────────────────────────────────────────────────
  Tokens pruned: ~15.2K
  Tools pruned:   12

All-time:
────────────────────────────────────────────────────────────
  Tokens saved:  ~284.5K
  Tools pruned:   156
  Sessions:       8

Statistics Explanation:

  • Session: Pruning data for current session (in memory)
  • All-time: Cumulative data for all historical sessions (disk persisted)

Checkpoint ✅: Confirm you see pruning statistics for current session and historical cumulative data.

Step 4: Manual Tool Pruning

There are two ways to use /dcp sweep:

Method 1: Prune All Tools Since Last User Message

Type /dcp sweep (without parameters).

You should see:

╭───────────────────────────────────────────────────────────╮
│                      DCP Sweep                            │
╰───────────────────────────────────────────────────────────╯

Swept 8 tool(s) since previous user message.
Tokens saved: ~12,345

  • Read: src/config.ts
  • Read: src/utils.ts
  • Bash: npm test
  • Read: package.json
  • Read: src/index.ts
  • Bash: git status
  • Read: README.md
  • Write: docs/tutorial.md

Method 2: Prune Last N Tools

Type /dcp sweep 5 to prune the last 5 tools.

You should see:

╭───────────────────────────────────────────────────────────╮
│                      DCP Sweep                            │
╰───────────────────────────────────────────────────────────╯

Swept last 5 tool(s).
Tokens saved: ~7,892

  • Read: src/index.ts
  • Bash: git status
  • Read: README.md
  • Write: docs/tutorial.md
  • Bash: npm run build

Protected Tools Prompt:

If protected tools were skipped, the output will display:

Swept 5 tool(s).
Tokens saved: ~7,892
(2 protected tool(s) skipped)

WARNING

Protected tools (like write, edit) and protected file paths are automatically skipped and will not be pruned.

Checkpoint ✅: Confirm you see the list of pruned tools and the amount of saved tokens.

Step 5: Review Pruning Effectiveness Again

After pruning, type /dcp context again to view the new token distribution.

You should see:

  • Tools category percentage decreased
  • Increased number of pruned tools in Summary
  • Reduced Current context total

Checkpoint ✅: Confirm token usage has significantly decreased.

Common Pitfalls

❌ Mistake: Accidentally Deleting Important Tools

Scenario: You just used the write tool to create a critical file, then executed /dcp sweep.

Wrong Result: The write tool is pruned, and the AI may not know the file was created.

Correct Approach:

  • Tools like write, edit are protected by default
  • Don't manually modify protectedTools configuration to remove these tools
  • Wait a few turns after completing critical tasks before cleaning up

❌ Mistake: Pruning at the Wrong Time

Scenario: The conversation just started, and you execute /dcp sweep with only a few tool calls.

Wrong Result: Very few tokens saved, and context coherence may be affected.

Correct Approach:

  • Wait until the conversation progresses to a certain extent (e.g., 10+ tool calls) before cleaning
  • Clean up previous round's tool outputs before starting a new task
  • Use /dcp context to determine if cleaning is worthwhile

❌ Mistake: Over-relying on Manual Pruning

Scenario: You manually execute /dcp sweep in every conversation.

Wrong Result:

  • Automatic pruning strategies (deduplication, overwrite writes, error clearing) are wasted
  • Increases operational burden

Correct Approach:

  • Keep automatic pruning strategies enabled by default (config: strategies.*.enabled)
  • Use manual pruning as a supplement only when necessary
  • Verify automatic pruning effectiveness through /dcp stats

Summary

DCP's 4 commands help you monitor and control token usage:

CommandCore Function
/dcpDisplay help information
/dcp contextAnalyze current session token distribution
/dcp statsView cumulative pruning statistics
/dcp sweep [n]Manual tool pruning

Token Calculation Strategy:

  • System: System prompt (calculated from first response)
  • Tools: Tool inputs and outputs (pruned portion deducted)
  • User: All user messages (estimated)
  • Assistant: AI output + reasoning tokens (residual)

Protection Mechanism:

  • Protected tools: task, todowrite, todoread, discard, extract, batch, write, edit, plan_enter, plan_exit
  • Protected files: Configured glob patterns
  • All pruning operations automatically skip these contents

Best Practices:

  • Regularly view /dcp context to understand token composition
  • Execute /dcp sweep before new tasks to clean up history
  • Rely on automatic pruning, use manual pruning as a supplement
  • Verify long-term effectiveness through /dcp stats

Next Lesson Preview

Next, we'll learn Protection Mechanism.

You'll learn:

  • How turn protection prevents accidental pruning
  • How to customize the protected tools list
  • Protected file pattern configuration methods
  • Special handling for subagent sessions

Appendix: Source Code Reference

Click to expand source code locations

Last updated: 2026-01-23

FunctionFile PathLine Number
/dcp help commandlib/commands/help.ts19-32
/dcp context commandlib/commands/context.ts238-247
Token calculation strategylib/commands/context.ts5-38
/dcp stats commandlib/commands/stats.ts46-67
/dcp sweep commandlib/commands/sweep.ts123-259
Protected tools configurationlib/config.ts461
Default protected tools listREADME.md150-151

Key Constants:

  • DEFAULT_PROTECTED_TOOLS: Default protected tools list

Key Functions:

  • handleHelpCommand(): Handle /dcp help command
  • handleContextCommand(): Handle /dcp context command
  • analyzeTokens(): Calculate token count for each category
  • handleStatsCommand(): Handle /dcp stats command
  • handleSweepCommand(): Handle /dcp sweep command
  • buildToolIdList(): Build tool ID list