Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
••••••••••••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

Building a 24/7 Claude Code Wrapper? Here's Why Each Subprocess Burns 50K Tokens

If you use Claude Code with plugins or MCP servers and spawn subagents (the Task tool), you might be burning through your token quota much faster than expected. Here's why, and a concrete fix. The Problem When Claude Code…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

If you use Claude Code with plugins or MCP servers and spawn subagents (the Task tool), you might be burning through your token quota much faster than expected. Here's why, and a concrete fix.






The Problem



When Claude Code spawns a subagent via the Task tool, each subprocess is a fresh claude CLI process. That process inherits your entire global configuration:





  • ~/CLAUDE.md (your project instructions)

  • All enabled plugins and their skills

  • Every MCP server's tool descriptions

  • User-level settings from ~/.claude/settings.json



Every single turn of every subprocess re-injects all of this. In our case (building MAMA, a memory plugin with hooks + MCP server), a single subagent turn consumed ~50K tokens before doing any actual work.



Run /context in a fresh session to see for yourself — MCP tool descriptions alone can eat 10-20K tokens.






The Numbers






Before isolation:
Subprocess turn 1: ~50K tokens (system prompt + plugins + MCP tools)
Subprocess turn 5: ~250K tokens cumulative

After isolation:
Subprocess turn 1: ~5K tokens
Subprocess turn 5: ~25K tokens cumulative






That's a 10x reduction.






The Fix: 4-Layer Agent Isolation



We solved this by isolating each subprocess from the user's global settings:






Layer 1: Scoped Working Directory






// Set cwd to a scoped workspace, NOT os.homedir()
// This prevents ~/CLAUDE.md from being auto-loaded
cwd: path.join(os.homedir(), '.mama', 'workspace')









Layer 2: Git Boundary






// Create a .git/HEAD to block upward CLAUDE.md traversal
const gitDir = path.join(workspaceDir, '.git');
fs.mkdirSync(gitDir, { recursive: true });
fs.writeFileSync(path.join(gitDir, 'HEAD'), 'ref: refs/heads/main\n');









Layer 3: Empty Plugin Directory






// Point --plugin-dir to an empty directory
'--plugin-dir', path.join(os.homedir(), '.mama', '.empty-plugins')









Layer 4: Setting Sources






// Exclude user-level settings (which contain enabledPlugins)
'--setting-sources', 'project,local'









Why Each Layer Matters

































Layer What it blocks Without it
Scoped cwd ~/CLAUDE.md auto-load ~5K tokens/turn of instructions
.git/HEAD Upward CLAUDE.md traversal Claude Code walks to ~ and finds it
--plugin-dir Global plugin skills Plugins inject skills every turn
--setting-sources enabledPlugins list settings.json re-enables plugins





One-Shot vs Persistent Process



Pattern A: One-shot with resume




claude -p "<prompt>" \
--append-system-prompt "<identity>" \
--resume <session-id>






Each call re-sends full history + system prompt. After 10 turns the system prompt has been sent 10 times.



Pattern B: Persistent stream-json (our approach)




claude --print \
--input-format stream-json \
--output-format stream-json \
--session-id <id>






Process stays alive. System prompt sent once. Messages go through stdin.



Both patterns need the 4-layer isolation.






Try It Yourself




  1. Open Claude Code with your usual setup

  2. Run /context — note total token count

  3. Imagine that multiplied by every subagent turn





1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Remote Code Execution (RCE) Defense
1 Warnungen
title: Detect Exploitation - Building a 24/7 Claude Code Wrapper? Here's Why Each Subprocess Burns 50K Tokens
id: 32db5e75-6d25-464d-896e-5951fc6cdae5
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-25
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-25"
        description = "YARA Signature for "
    strings:
        $str = "Building a 24/7 Claude Code Wr" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Building a 247 Claude Code Wrapper Heres")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Building a 247 Claude Code Wrapper Heres*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Building a 247 Claude Code Wrapper Heres"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Building a 24/7 Claude Code Wrapper? Her.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Building a 24/7 Claude Code Wrapper? Here's Why Each Subprocess Burns 50K Tokens

Thematisch verwandte Begriffe: Building, Claude, Code, Wrapper · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-87722 | Uncontrolled Resource Consumption (CWE-400 / CWE-1333) in regex search q…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel • Rechts: nächster Artikel • unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...
↗ Original-Quelle