/church:observability-crusade [path] [--scope all|api|web] [--illuminate]from church
Audits codebase for observability anti-patterns across logging, tracing, metrics, and error handling. Reports sins like empty catches, bare console calls, untraced endpoints, and missing correlation IDs. Optionally applies fixes with --illuminate.
Ships in church. Installing the plugin adds it to Claude Code.
"In the beginning, there was darkness upon the codebase. And the Observability Purists said: LET THERE BE LIGHT."
This command orchestrates a multi-squad crusade to eliminate observability sins and bring full instrumentation to your codebase.
# Survey darkness only (report mode)
/observability-crusade
# Survey specific scope
/observability-crusade --scope api
/observability-crusade --scope web
# Survey and apply fixes
/observability-crusade --illuminate
# Target specific directory
/observability-crusade apps/api/src/domains/orders
/observability-crusade apps/api/src/domains/orders --illuminate
First, we scan the codebase to identify every sin against observability:
Sins to detect:
catch (e) {}, catch {}, catch blocks with only commentsconsole.log, console.error, console.warn in non-test files/health endpointScan commands:
# Empty catch blocks
rg 'catch\s*\([^)]*\)\s*\{\s*\}' --type ts --type tsx
# Bare console calls (exclude test files)
rg 'console\.(log|error|warn|info|debug)' --type ts --type tsx -g '!*.spec.ts' -g '!*.test.ts' -g '!*.e2e.ts'
# Catch blocks with only comments
rg 'catch.*\{[^}]*//[^}]*\}' --type ts --type tsx
# Missing correlation ID usage in services
rg 'logger\.(info|error|warn)' -A 2 --type ts | rg -v 'correlationId'
# Unstructured string concat logs
rg "logger\.(info|error|warn)\(['\"].*\+.*\)" --type ts
# Missing health check endpoints
rg -L '@Get.*health' apps/api
# Promise without catch
rg 'await\s+\w+\(.*\)' --type ts -g '!*.spec.ts' | rg -v 'try|catch'
Present findings in a structured report:
╔════════════════════════════════════════════════════════════════╗
║ THE DARKNESS REPORT ║
║ "For they coded without light, and production fell" ║
╠════════════════════════════════════════════════════════════════╣
║ Sin Category │ Count │ Severity ║
╠═════════════════════════════════╪═══════╪══════════════════════╣
║ Empty Catch Blocks │ XX │ CRITICAL ║
║ Bare console.log Calls │ XX │ HIGH ║
║ Untraced API Endpoints │ XX │ HIGH ║
║ Untraced External Calls │ XX │ HIGH ║
║ Missing Correlation IDs │ XX │ HIGH ║
║ Unstructured Log Messages │ XX │ MEDIUM ║
║ Swallowed Errors │ XX │ CRITICAL ║
║ Missing Health Checks │ XX │ CRITICAL ║
║ Missing Business Metrics │ XX │ MEDIUM ║
║ Error Responses Without Logs │ XX │ HIGH ║
╠════════════════════════════════════════════════════════════════╣
║ TOTAL SINS DETECTED: XXX ║
╚════════════════════════════════════════════════════════════════╝
Darkness details:
For each sin category, show:
Example revelation:
🔥 EMPTY CATCH BLOCKS (23 found) — CRITICAL
When these fail in production, you will have NO INFORMATION.
The error will be swallowed into the void. Users will suffer.
Engineers will be blind.
Examples:
apps/api/src/domains/orders/application/order.service.ts:45
try {
await this.processPayment(order);
} catch (e) {
// Silent death. No log. No trace. Only darkness.
}
apps/api/src/domains/users/infrastructure/user.repository-impl.ts:89
try {
return await this.db.query(sql);
} catch {
// Not even a variable name. Pure void.
}
[+20 more occurrences]
Deploy specialized squads to eliminate each category of sin:
Squad 1: Logging Purification Squad
Objective: Replace bare console calls with structured logging, add context to all logs
Scope: All files with console.log, console.error, console.warn
Actions:
console.log with appropriate logger (NestJS Logger, winston, pino)logger.info('message', { context })Success criteria: Zero bare console calls outside test files
Squad 2: Error Handling Squad
Objective: Fix empty catch blocks, swallowed errors, add proper error logging
Scope: All empty catch blocks, catch blocks with only comments, catch-and-return-null
Actions:
Success criteria: Zero empty catch blocks, all errors logged before handling
Squad 3: Distributed Tracing Squad
Objective: Add correlation ID propagation, instrument endpoints, trace external calls
Scope: All API controllers, HTTP clients, database query methods
Actions:
Success criteria: All endpoints traced, correlation IDs in every log, external calls timed
Squad 4: Health & Metrics Squad
Objective: Add health checks, instrument business operations with metrics
Scope: Application entry point, business use cases
Actions:
/health endpoint that checks all dependencies (db, cache, queues)Success criteria: Health check exists and works, business metrics tracking all critical operations
Squad sizing:
Squad prompts:
Each squad is spawned with its specialist agent:
observability-logging-purist agentobservability-error-purist agentobservability-tracing-purist agentobservability-metrics-purist agentYou are Squad {N}: {Squad Name}
Your sacred mission: {Objective}
Target scope: {File pattern or directory}
Your tasks:
{Specific actions}
Success criteria: {Measurable outcomes}
Files to focus on: {Specific file paths from darkness survey}
Do NOT modify files outside the target scope.
Report back:
- Number of sins eliminated
- Files modified
- Patterns added (e.g., correlation ID middleware, health check endpoint)
- Remaining issues (if any)
Remember: NEVER log sensitive data (PII, tokens, passwords).
Respect existing instrumentation patterns.
Enhance, don't duplicate.
War cry before deployment:
╔════════════════════════════════════════════════════════════════╗
║ THE CRUSADE BEGINS ║
╚════════════════════════════════════════════════════════════════╝
And the Observability Purists spoke unto the codebase:
"LET THERE BE LIGHT"
{N} squads descend upon {M} files.
Squad 1 (Logging Purification): {X} files, {Y} sins to purge
Squad 2 (Error Handling): {X} files, {Y} sins to purge
Squad 3 (Distributed Tracing): {X} files, {Y} sins to purge
Squad 4 (Health & Metrics): {X} files, {Y} sins to purge
Every silent failure shall SPEAK.
Every lost request shall be FOUND.
Every metric shall be MEASURED.
Every health check shall VERIFY.
The darkness ends TODAY.
After all squads return, verify the light has been brought:
Verification steps:
The Illumination Report:
╔════════════════════════════════════════════════════════════════╗
║ THE ILLUMINATION REPORT ║
║ "And there was light, and it was good" ║
╠════════════════════════════════════════════════════════════════╣
║ ║
║ DARKNESS ELIMINATED: ║
║ ║
║ Empty Catch Blocks Filled: XX ║
║ console.log Calls Consecrated: XX ║
║ API Endpoints Traced: XX ║
║ External Calls Instrumented: XX ║
║ Correlation IDs Propagated: XX ║
║ Health Checks Added: XX ║
║ Business Metrics Instrumented: XX ║
║ Error Handlers Enlightened: XX ║
║ Structured Logs Created: XX ║
║ ║
╠════════════════════════════════════════════════════════════════╣
║ REMAINING DARKNESS: XX ║
╠════════════════════════════════════════════════════════════════╣
║ ║
║ NEW LIGHT SOURCES CREATED: ║
║ ║
║ ✓ Correlation ID Middleware: {file path} ║
║ ✓ Health Check Endpoint: {file path} ║
║ ✓ Request Logging Interceptor: {file path} ║
║ ✓ Exception Filter: {file path} ║
║ ✓ Metrics Service: {file path} ║
║ ║
╠════════════════════════════════════════════════════════════════╣
║ OBSERVABILITY STATUS: {percentage}% ILLUMINATED ║
╚════════════════════════════════════════════════════════════════╝
If darkness remains:
⚠️ DARKNESS PERSISTS in {N} locations:
Critical issues requiring manual attention:
1. {File}:{Line} - {Issue description}
2. {File}:{Line} - {Issue description}
...
These require human judgment due to:
- Complex error handling logic
- External library integration
- Legacy code dependencies
- Business logic considerations
Final summary:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
THE CRUSADE IS COMPLETE.
Before: XXX sins detected across YYY files
After: XX sins remain across YY files
Illumination rate: ZZ%
Your production systems shall no longer suffer in darkness.
When incidents occur, you shall have LIGHT to guide you.
Logs shall speak. Traces shall connect. Metrics shall measure.
But vigilance is eternal. New darkness will emerge.
The Observability Purist must return periodically.
May your logs be structured, your traces complete,
and your metrics actionable.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Limit the crusade to a specific part of the codebase:
--scope api: Only backend (apps/api)--scope web: Only frontend (apps/web)--scope all: Entire codebase (default)Without this flag: Report-only mode. Identifies sins but doesn't fix them.
With this flag: Apply fixes automatically. Squads will modify code.
Safety considerations when using --illuminate:
Target a specific directory:
/observability-crusade apps/api/src/domains/orders
Only files within this path will be scanned and illuminated.
1. Parse arguments (path, scope, illuminate flag)
2. Determine target directories based on scope
3. Run parallel darkness detection greps
4. Aggregate results into Darkness Report
5. Present Darkness Report to user
6. If --illuminate flag:
a. Ask user confirmation
b. Calculate squad count based on codebase size
c. Partition files by sin category
d. Spawn squads in parallel with specialist agents:
- Logging Purification → observability-logging-purist
- Error Handling → observability-error-purist
- Distributed Tracing → observability-tracing-purist
- Health & Metrics → observability-metrics-purist
e. Wait for all squads to complete
f. Aggregate squad results
7. Run verification greps
8. Generate Illumination Report
9. Highlight remaining darkness (if any)
10. Provide next steps
// Pseudo-code for scope resolution
function getTargetPaths(scope: string, path?: string): string[] {
if (path) {
return [path]; // User-specified directory
}
switch (scope) {
case 'api':
return ['apps/api/src'];
case 'web':
return ['apps/web/src'];
case 'all':
default:
return ['apps/', 'packages/'];
}
}
function calculateSquadCount(fileCount: number): number {
if (fileCount < 50) return 2;
if (fileCount < 200) return 3;
return 4;
}
function getSquadConfiguration(squadCount: number) {
if (squadCount === 2) {
return [
{ name: 'Logging & Errors', tasks: ['logging', 'errors'] },
{ name: 'Tracing & Metrics', tasks: ['tracing', 'metrics'] },
];
}
if (squadCount === 3) {
return [
{ name: 'Logging Purification', tasks: ['logging'] },
{ name: 'Error & Tracing', tasks: ['errors', 'tracing'] },
{ name: 'Health & Metrics', tasks: ['metrics'] },
];
}
// squadCount === 4
return [
{ name: 'Logging Purification', tasks: ['logging'] },
{ name: 'Error Handling', tasks: ['errors'] },
{ name: 'Distributed Tracing', tasks: ['tracing'] },
{ name: 'Health & Metrics', tasks: ['metrics'] },
];
}
Before completing, always grep for potential sensitive data in logs:
# Check for common PII patterns in log statements
rg 'logger.*\b(password|token|secret|key|creditCard|ssn|email)\b' --type ts
# Check for direct variable logging (may contain PII)
rg 'logger.*\buser\.' --type ts | rg -v 'userId|user\.id'
If found, WARN and provide guidance on redacting.
Before running with --illuminate:
After fixes are applied:
pnpm lint to catch formatting issuespnpm type-check to catch type errorspnpm test to ensure nothing brokeIf issues arise:
# If changes haven't been committed
git restore .
# If changes were committed
git revert HEAD
# If multiple commits
git reset --hard HEAD~{N}
User: /observability-crusade
Files this command reads when invoked
What the command file sets; muted values are Claude Code's defaults
observability, logging, tracing, metrics, error-handling, code-audit
7-day visitors to each command page
14 commands in this plugin
/a11y-crusadeA11y Crusade: The March for Universal ReadabilityUnleash parallel A11y Purist agents to audit WCAG compliance, semantic HTML, keyboard navigation, ARIA usage, and perceivability across the codebase. Universal Readability awaits./adaptive-crusadeTHE MISSIONUnleash parallel Adaptive UI Purist agents to audit foldable support, touch targets, focus management, DPI awareness, and state preservation across the codebase. No viewport sin survives the fold./arch-crusadeArchitecture Crusadenpx claudepluginhub btachinardi/church --plugin church