Claude Code v2.1.85: Conditional Hooks, Fixed /compact, and Headless PreToolUse

Claude Code v2.1.85: Conditional Hooks, Fixed /compact, and Headless PreToolUse

Version 2.1.85 fixes critical /compact failures, adds conditional hooks to reduce overhead, and enables headless integrations via PreToolUse hooks.

GAla Smith & AI Research Desk·1d ago·4 min read·2 views·AI-Generated
Share:
Source: github.comvia gh_claude_releasesSingle Source
Claude Code v2.1.85: Conditional Hooks, Fixed /compact, and Headless PreToolUse

What Changed — The Specific Update

Claude Code v2.1.85, released this week, delivers 25+ improvements focused on stability, performance, and enterprise integration. This follows a week where Claude Code appeared in 162 articles across our coverage, showing intense developer interest in the tool's evolution.

The most significant changes include:

  • Fixed /compact failures when conversations grow too large for the compact request itself
  • Conditional if fields for hooks using permission rule syntax (e.g., Bash(git *))
  • PreToolUse hooks can now satisfy AskUserQuestion by returning updatedInput alongside permissionDecision: "allow"
  • MCP server environment variables (CLAUDE_CODE_MCP_SERVER_NAME, CLAUDE_CODE_MCP_SERVER_URL) for headersHelper scripts
  • Deep link query support extended to 5,000 characters with scroll warnings

What It Means For Your Daily Workflow

/compact Now Works on Massive Conversations

Previously, /compact could fail with "context exceeded" when the conversation had grown so large that even the compact request couldn't fit in the context window. This was particularly frustrating for long-running sessions where compaction is most needed. Now, Claude Code handles this edge case gracefully, ensuring your longest sessions remain manageable.

Conditional Hooks Reduce Process Overhead

The new conditional if field for hooks lets you filter when they run using permission rule syntax. Instead of spawning processes for every hook invocation, you can now write:

{
  "hooks": [
    {
      "type": "PreToolUse",
      "if": "Bash(git commit *)",
      "script": "./scripts/validate-commit.sh"
    }
  ]
}

This hook only runs for git commit commands, not every Bash command. For teams using complex hook systems, this can significantly reduce system load.

Headless Integrations Get Superpowers

PreToolUse hooks can now programmatically answer AskUserQuestion prompts by returning:

{
  "permissionDecision": "allow",
  "updatedInput": "user's answer here"
}

This enables headless CI/CD pipelines and automation systems to interact with Claude Code without manual intervention. Your integration can now:

  1. Detect when Claude asks a question
  2. Programmatically determine the answer
  3. Continue execution automatically

One headersHelper Script, Multiple MCP Servers

If you manage multiple MCP servers requiring similar authentication headers, you can now use environment variables in your headersHelper script:

#!/bin/bash
# Use CLAUDE_CODE_MCP_SERVER_NAME to differentiate servers
echo "Authorization: Bearer $(get_token_for_server $CLAUDE_CODE_MCP_SERVER_NAME)"

This aligns with our recent coverage of MCP security in "Audit Your MCP Servers Now: 66% Have Critical Vulnerabilities" — simplifying server management while maintaining security.

Try It Now — Commands and Config Updates

Update Your Claude Code Installation

# Check your current version
claude code --version

# Update via your package manager
# For npm/yarn users:
npm update -g @anthropic-ai/claude-code

Implement Conditional Hooks

Add this to your claude_code_config.json:

{
  "hooks": [
    {
      "type": "PreToolUse",
      "if": "Bash(rm -rf *)",
      "script": "./scripts/confirm-destructive.sh",
      "description": "Confirm destructive deletions"
    },
    {
      "type": "PreToolUse",
      "if": "Http(*api*)",
      "script": "./scripts/log-api-calls.sh",
      "description": "Log all API calls"
    }
  ]
}

Test the Fixed /compact Command

Start a long session with Claude Code, let it run through multiple complex tasks, then try:

/compact

Even if your transcript is massive, it should now compact successfully.

Enable OTEL Tool Details (If Needed)

If you're debugging OpenTelemetry integration and need tool parameters in events:

export OTEL_LOG_TOOL_DETAILS=1
claude code

Performance and Stability Wins

Beyond the headline features, v2.1.85 delivers subtle but important improvements:

  • Scroll performance with large transcripts improved by replacing WASM yoga-layout with pure TypeScript
  • UI stutter reduced when compaction triggers on large sessions
  • @-mention file autocomplete now faster on large repositories
  • Memory leak fixed in remote sessions when streaming responses are interrupted
  • Terminal keyboard fixes for Ghostty, Kitty, WezTerm users (Ctrl+C/Ctrl+D now work after quitting)

These changes collectively make Claude Code feel snappier during intensive development sessions, especially when working with large codebases.

Enterprise and Security Updates

For organizations using managed settings:

  • Plugins blocked by managed-settings.json are now properly hidden from marketplace views
  • The deniedMcpServers setting now correctly blocks claude.ai MCP servers
  • MCP OAuth follows RFC 9728 Protected Resource Metadata discovery

This continues Claude Code's trend toward enterprise readiness, following last week's Auto Mode preview release and critical bug fixes for production environments.

AI Analysis

**Immediate Actions for Claude Code Users:** 1. **Update immediately** if you use `/compact` on long sessions. The fix for "context exceeded" errors is critical for maintaining workflow continuity. Test compaction on your largest recent sessions to verify the fix works for your use case. 2. **Audit your hooks** for optimization opportunities. Any hook that runs on broad permission rules (like `Bash(*)`) should be reviewed. Add conditional `if` fields to limit execution to only necessary commands. This is especially valuable for teams running Claude Code in resource-constrained CI environments. 3. **Explore headless automation** if you're building integrations. The new `AskUserQuestion` handling in PreToolUse hooks opens possibilities for fully automated Claude Code pipelines. Start with simple confirmation prompts and work toward more complex interactive workflows. **Workflow Changes:** - **Deep link users** can now send much more complex queries (up to 5,000 chars) via `claude-cli://open?q=...`. Use this for prefilling detailed task descriptions, but heed the "scroll to review" warning for long prompts. - **MCP server developers** should update `headersHelper` scripts to use the new environment variables if managing multiple servers with similar auth requirements. This simplifies configuration management. - **PowerShell users** benefit from improved dangerous command detection, but maintain your existing safety practices—this is an enhancement, not a replacement for careful review. This release solidifies Claude Code's position as both a developer productivity tool and an automation platform, following the trend of increased enterprise adoption we've tracked across 393 articles.
Enjoyed this article?
Share:

Related Articles

More in Products & Launches

View all