TRILHA 5

🏗️ Infrastructure

Domine permissions, settings, sessions, context compaction, analytics, migrations, plugins, hooks e error handling do Claude Code.

9
Modulos
~54
Topicos
~7h
Duracao
Avancado
Nivel

Navegacao Rapida

5.1 ~50 min

Permissions

O pipeline de decisao de permissoes: 5 modos, rule matching, AI classifier, shadowed rule detection e permission explainer.

1
🛡️ Decision Pipeline (Steps 1a-3)
Deny first, safety checks, mode transformations
2
🔒 The 5 Permission Modes
default, plan, acceptEdits, bypass, dontAsk, auto
3
📋 Rule Matching System
exact, prefix (legacy), wildcard, MCP rules
4
🤖 Auto Mode & AI Classifier
Fast paths, safe allowlist, denial limits
5
🔍 Shadowed Rule Detection
Deny-shadowed, ask-shadowed, unreachable rules
6
💡 Permission Explainer & Rule Sources
Side API call, 8 rule sources, priority
Ver Completo
5.2~50 min

Settings & Config

Cascade de 5 camadas, merge semantics, 3-tier cache, change detection e remote managed settings.

1
📚 5-Layer Settings Cascade
user -> project -> local -> flag -> policy
2
🔄 Merge Semantics & 3-Tier Cache
settingsMergeCustomizer, clone-on-read, fanOut
3
🔍 Change Detection & Hot-Reload
chokidar, internal write suppression, MDM poll
4
🌐 Remote Managed Settings
ETag caching, fail-open, security check
5
🔒 Security Constraints
projectSettings exclusion, managed-only locks
6
💾 Settings Sync & Backward Compatibility
CCR sync, schema contract, drop-in directory
Ver Completo
5.3~55 min

Session Management

Persistencia JSONL, linked list via parentUuid, state machine tri-state, interrupt detection e cloud sync.

1
💾 JSONL Storage & Write Queue
Append-only, batched writes, lazy materialization
2
🔗 parentUuid Linked List
Chain walk, branching, compact boundary
3
🚦 Session State Machine
idle/running/requires_action, CCR bridge
4
🔄 Interrupt Detection & Recovery
interrupted_prompt, interrupted_turn, synthetic messages
5
☁️ Cloud Sync & Resume Orchestrator
CCR v2 hydration, worktree resume, skill restore
6
📋 Session Listing & Tail Window
Lite reads, 64KB tail, reAppendSessionMetadata
Ver Completo
5.4~50 min

Context Compaction

4 estrategias de compactacao: microcompact, session memory, full LLM summary (9 secoes) e reactive compact.

1
📊 Thresholds & Token Warning States
Effective window, 20k reserve, circuit breaker
2
⚡ Microcompact - Zero API Cost
Time-based, cached MC, token estimation
3
📝 Session Memory & Full LLM Compact
Zero-call summary, 9-section prompt, analysis scratchpad
4
🚨 Reactive Compact & Context Collapse
413 error handler, API-round grouping
5
🧹 Post-Compact Cleanup
Cache invalidation, subagent safety, file restoration
6
📊 /context Command & Accurate Token Display
Pre-API transforms, microcompact applied
Ver Completo
5.5~45 min

Analytics & Telemetry

Pre-sink queue, Datadog transport, metadata enrichment, PII sanitization, GrowthBook feature flags e kill-switch.

1
📨 Pre-Sink Queue & Sink Routing
Zero-dep API, sampling, PII separation
2
📊 Datadog Transport & Cardinality
Batch flush, model name normalization, user buckets
3
📝 Metadata Enrichment & PII Safety
EnvContext, ProcessMetrics, type-enforced sanitization
4
🎯 GrowthBook Feature Flags
Remote eval, 3-level override, exposure dedup
5
🚫 Kill-Switch & Disable Conditions
tengu_frond_boric, fail-open, Bedrock/Vertex disable
6
💎 Event Sampling & Key Takeaways
Inverse probability weighting, graceful shutdown
Ver Completo
5.6~40 min

Migrations

Sistema de migracoes idempotentes: settings promotions, model alias upgrades, one-shot resets e version gate.

1
🏗️ runMigrations() & Version Gate
CURRENT_MIGRATION_VERSION=11, preAction hook
2
🔄 5 Migration Types
Settings, model alias, config rename, reset, async file
3
🔒 Two Idempotency Patterns
Completion flag vs self-idempotent data check
4
🛡️ Settings Layer Discipline
Only touch userSettings, never merged settings
5
📋 Migration Catalogue (11 sync + 1 async)
Model migrations, MCP approval, config renames
6
💎 Adding a New Migration - Recipe
7-step checklist, try/catch requirement
Ver Completo
5.7~50 min

Plugin System

6 marketplace sources, manifest schema, versioned cache, dependency resolution DFS e background autoupdate.

1
🌍 6 Marketplace Sources
GitHub, git, git-subdir, URL, npm, local
2
📋 Manifest Schema (plugin.json)
Commands, hooks, MCP, LSP, agents, skills, userConfig
3
📦 Versioned Cache & Dependency Resolution
Immutable per-version, DFS closure, fixed-point demote
4
🔧 Command, Skill & Hook Loading
Namespacing, variable substitution, hot reload
5
🔒 Security, Policy & Scopes
Policy blocking, delisting, 4 install scopes
6
🔄 Background Autoupdate
Non-blocking, non-in-place, restart prompt
Ver Completo
5.8~50 min

Hooks System

27 hook events, 5 command types, exit code semantics, 6 config sources e HTTP/agent hook security.

1
📋 27 Hook Events & Exit Codes
Lifecycle, tool, agent, compaction, filesystem
2
🔧 5 Hook Command Types
command, prompt, agent, http, function
3
📚 6 Config Sources & Policy
Merge all, allowManagedHooksOnly, disableAllHooks
4
🔒 HTTP Hooks Security Model
URL allowlist, env var allowlist, SSRF guard
5
⚡ Async/AsyncRewake & Session Hooks
Background execution, rewake on exit 2, Map mutation
6
💎 Real-World Patterns & if Filter
Lint-on-write, session context, .envrc auto-load
Ver Completo
5.9~45 min

Error Handling

Error taxonomy, API retry engine com 529 fallback, terminal error overlay e conversation recovery de 4 estagios.

1
📋 Error Taxonomy
ClaudeError, AbortError, ShellError, isAbortError 3-way
2
🔄 API Retry Engine (withRetry)
529 model fallback, context overflow, OAuth refresh
3
📟 Tool Error Formatting
10k char cap, center-truncation, Zod -> LLM-friendly
4
🖥️ Terminal Error Overlay
StackUtils, code-excerpt, SentryErrorBoundary
5
🔄 Conversation Recovery Pipeline
4-stage deserialization, interrupt classification
6
💎 End-to-End Error Flow
3 paths: runtime, API, session recovery
Ver Completo