$ recombobulate _
home / tips / ask-claude-to-add-logging-and-observability-to-your-code-without-changing-the-logic
134

Ask Claude to Add Logging and Observability to Your Code Without Changing the Logic

recombobulate @recombobulate · Mar 29, 2026 · Workflows
ask-claude-to-add-logging-and-observability-to-your-code-without-changing-the-logic

You can't debug what you can't see. Adding logging and observability is important but tedious — you need to know what to log, where to log it, and how to structure it consistently. Claude reads your code and instruments it systematically.

Add structured logging to all service methods in src/services/. 
Log the method name, input parameters (redacting sensitive fields), 
execution duration, and outcome (success/failure). Use our existing 
logger from src/lib/logger.

Claude reads each method, identifies the key events worth logging, and adds instrumentation without changing the business logic:

// Claude adds timing and structured context automatically
async function processOrder(order) {
  const start = performance.now();
  logger.info('processOrder.start', { orderId: order.id, itemCount: order.items.length });
  
  try {
    const result = await executeOrder(order);
    logger.info('processOrder.success', { 
      orderId: order.id, 
      durationMs: performance.now() - start 
    });
    return result;
  } catch (error) {
    logger.error('processOrder.failed', { 
      orderId: order.id, 
      error: error.message, 
      durationMs: performance.now() - start 
    });
    throw error;
  }
}

Target different observability needs:

# Add performance timing
Wrap all database queries in src/repositories/ with timing. 
Log any query that takes longer than 100ms as a warning.

# Add request tracing
Add a request ID to every log line in the API layer. 
Generate the ID in middleware and pass it through the context.

# Add business metric events
Identify the key business events in the checkout flow 
(cart created, payment attempted, order confirmed, etc.) 
and add analytics-friendly log events for each.

# Add health check data
Instrument the external service calls so we can track 
availability and response times for each third-party dependency.

Ask Claude to match your existing logging conventions:

Read how logging is done in UserService — that's the pattern to follow. 
Apply the same structure to OrderService and PaymentService, which 
currently have no logging at all.

Observability is the difference between "it's broken" and "it broke here, at this time, with these inputs" — let Claude add the instrumentation so the next bug is visible from the start.

via Claude Code

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 day ago