skills/debugging/SKILL.md
Systematic debugging for Rust applications. Root cause analysis, logging strategies, profiling, and issue reproduction. All debug changes removed before final report.
npx skillsauth add terraphim/codex-skills debuggingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are a debugging specialist for Rust applications. You systematically investigate issues, gather evidence, identify root causes, and provide clear solutions.
use tracing::{debug, error, info, instrument, span, warn, Level};
#[instrument(skip(large_data), fields(data_len = large_data.len()))]
fn process_data(large_data: &[u8]) -> Result<Output, Error> {
info!("Starting processing");
let result = parse(large_data)
.inspect_err(|e| error!(?e, "Parse failed"))?;
debug!(?result, "Parsed successfully");
Ok(result)
}
// Structured logging for debugging
fn investigate_issue(request: &Request) {
let span = span!(Level::DEBUG, "investigate", request_id = %request.id);
let _guard = span.enter();
debug!(headers = ?request.headers, "Request headers");
debug!(body_size = request.body.len(), "Request body size");
}
// Only run in debug builds
debug_assert!(index < self.len(), "Index out of bounds: {}", index);
// With more context
debug_assert!(
self.is_valid(),
"Invalid state: {:?}",
self.debug_state()
);
#[cfg(debug_assertions)]
fn debug_dump(&self) {
eprintln!("Current state: {:?}", self);
eprintln!("History: {:?}", self.history);
}
#[cfg(not(debug_assertions))]
fn debug_dump(&self) {}
# Build with debug symbols
cargo build
# Run with LLDB
rust-lldb target/debug/my-app
# Common LLDB commands
(lldb) b main # Set breakpoint
(lldb) r # Run
(lldb) n # Next line
(lldb) s # Step into
(lldb) p variable # Print variable
(lldb) bt # Backtrace
# Install Miri
rustup +nightly component add miri
# Run tests with Miri
cargo +nightly miri test
# Run binary with Miri
cargo +nightly miri run
// Symptoms: Intermittent failures, different results each run
// Debug approach:
// 1. Add logging with thread IDs
info!(thread = ?std::thread::current().id(), "Accessing shared state");
// 2. Use thread sanitizer
// RUSTFLAGS="-Z sanitizer=thread" cargo +nightly run
// 3. Review synchronization
// - Are all shared accesses protected?
// - Is the lock scope correct?
// - Could there be deadlocks?
// Symptoms: Crashes, corruption, valgrind errors
// Debug approach:
// 1. Run with address sanitizer
// RUSTFLAGS="-Z sanitizer=address" cargo +nightly run
// 2. Check unsafe blocks
// - Are all pointers valid?
// - Are lifetimes correct?
// - Is alignment correct?
// 3. Use Miri for UB detection
// Symptoms: Slowness, high CPU/memory
// Debug approach:
// 1. Profile with flamegraph
// cargo flamegraph
// 2. Add timing
let start = std::time::Instant::now();
let result = expensive_operation();
debug!(elapsed = ?start.elapsed(), "Operation completed");
// 3. Check allocations
// Use heaptrack or Instruments
// Symptoms: Task hangs forever
// Debug approach:
// 1. Add timeout wrappers
tokio::time::timeout(Duration::from_secs(30), async_operation())
.await
.map_err(|_| {
error!("Operation timed out - possible deadlock");
Error::Timeout
})?;
// 2. Dump task state
// tokio-console for runtime inspection
// 3. Check for:
// - Blocking calls in async context
// - Circular await dependencies
// - Channel full/empty deadlocks
## Issue Summary
[One sentence description]
## Reproduction Steps
1. [Step 1]
2. [Step 2]
3. [Observe error]
## Environment
- Rust version: X.Y.Z
- OS: [OS and version]
- Relevant dependencies: [list]
## Investigation
### Evidence Gathered
- [Log excerpt]
- [Error message]
- [Timing information]
### Hypotheses Tested
1. **[Hypothesis 1]**: [Result]
2. **[Hypothesis 2]**: [Result]
### Root Cause
[Explanation of what caused the issue]
## Solution
[Description of fix]
### Changes Made
- [File 1]: [Change description]
- [File 2]: [Change description]
### Verification
- [How fix was verified]
- [Tests added/modified]
## Prevention
[How to prevent similar issues]
development
Xero Accounting API integration skill. Helps with OAuth2 authentication setup, invoice management, contact management, and accounting operations. Provides guidance on rate limits, token refresh, and API best practices.
development
Design and implement visual regression testing for UI changes. Defines screenshot coverage, rendering stabilization, baseline management, and CI integration (e.g., Playwright screenshots, Percy/Chromatic). Use when UI/styling/layout changes need protection against regressions, or when adding screenshot-based tests to a web/WASM/desktop UI.
testing
Run Ultimate Bug Scanner for automated bug detection across multiple languages. Detects 1000+ bug patterns including null pointers, security vulnerabilities, async/await issues, and resource leaks. Integrates with quality-gate workflow.
testing
Comprehensive test writing, execution, and failure analysis. Creates unit tests, integration tests, property-based tests, and benchmarks. Analyzes test failures and improves test coverage.