xiaohongshu
xiaohongshu
check-error-handling
Validates error handling follows AppResult/AppError pattern, detects anyhow regression, ensures ErrorCode usage
Full skill instructions
Quick validation that error handling follows the unified AppResult/AppError pattern (commit b592b5e). Detects anyhow regression and ensures proper use of ErrorCode enum.
Run this skill:
rg)# Check for anyhow regression
echo "🔍 Checking for anyhow usage..."
# 1. Check imports (FORBIDDEN)
if rg "use anyhow::|use anyhow;" src/ --type rust --quiet; then
echo "❌ FAIL: anyhow imports detected!"
rg "use anyhow" src/ --type rust -n | head -10
exit 1
else
echo "✓ PASS: No anyhow imports"
fi
# 2. Check macro usage (FORBIDDEN)
if rg "anyhow!\(" src/ --type rust --quiet; then
echo "❌ FAIL: anyhow! macro detected!"
rg "anyhow!\(" src/ --type rust -n | head -10
exit 1
else
echo "✓ PASS: No anyhow! macro"
fi
# 3. Check AppResult usage
APPRESULT_COUNT=$(rg "AppResult<" src/ --type rust | wc -l)
echo "✓ AppResult usage: $APPRESULT_COUNT occurrences"
# 4. Check ErrorCode usage
ERRORCODE_COUNT=$(rg "ErrorCode::" src/ --type rust | wc -l)
echo "✓ ErrorCode usage: $ERRORCODE_COUNT occurrences"
echo ""
echo "✅ Error handling check PASSED"
#!/bin/bash
set -e
echo "🔍 Comprehensive Error Handling Check"
echo "======================================"
# 1. Anyhow Imports
echo ""
echo "1. Checking for anyhow imports..."
ANYHOW_IMPORTS=$(rg "use anyhow" src/ --type rust | wc -l)
if [ "$ANYHOW_IMPORTS" -gt 0 ]; then
echo "❌ Found $ANYHOW_IMPORTS anyhow imports:"
rg "use anyhow" src/ --type rust -n | head -10
exit 1
else
echo "✓ No anyhow imports"
fi
# 2. Anyhow Macro
echo ""
echo "2. Checking for anyhow! macro..."
if rg "anyhow!\(" src/ --type rust --quiet; then
echo "❌ anyhow! macro usage detected:"
rg "anyhow!\(" src/ --type rust -n
exit 1
else
echo "✓ No anyhow! macro"
fi
# 3. Context Method
echo ""
echo "3. Checking for .context() method..."
CONTEXT_COUNT=$(rg "\.context\(\"" src/ --type rust | wc -l)
if [ "$CONTEXT_COUNT" -gt 0 ]; then
echo "⚠️ Warning: Found $CONTEXT_COUNT .context() usages (prefer .map_err())"
rg "\.context\(" src/ --type rust -n | head -5
else
echo "✓ No .context() usage"
fi
# 4. AppResult Usage
echo ""
echo "4. Validating AppResult usage..."
APPRESULT_COUNT=$(rg "AppResult<" src/ --type rust | wc -l)
if [ "$APPRESULT_COUNT" -lt 100 ]; then
echo "⚠️ Warning: Only $APPRESULT_COUNT AppResult usages (expected >100)"
else
echo "✓ AppResult usage: $APPRESULT_COUNT"
fi
# 5. ErrorCode Usage
echo ""
echo "5. Validating ErrorCode usage..."
ERRORCODE_COUNT=$(rg "ErrorCode::" src/ --type rust | wc -l)
echo "✓ ErrorCode usage: $ERRORCODE_COUNT"
# Most common error codes
echo ""
echo "Top ErrorCodes:"
rg "ErrorCode::" src/ --type rust -o | sort | uniq -c | sort -rn | head -5
# 6. Error Type Exports
echo ""
echo "6. Checking error module exports..."
if rg "pub use.*AppError|pub use.*AppResult|pub use.*ErrorCode" src/lib.rs --type rust --quiet; then
echo "✓ Error types exported from lib.rs"
else
echo "⚠️ Error types may not be exported"
fi
# 7. Cargo.toml Check
echo ""
echo "7. Checking Cargo.toml..."
if rg "^anyhow\s*=" Cargo.toml --quiet; then
echo "⚠️ anyhow in main dependencies (should be dev-dependencies only)"
else
echo "✓ anyhow not in main dependencies"
fi
echo ""
echo "✅ Comprehensive error handling check PASSED"
use anyhow imports in src/anyhow!() macro usage🔍 Checking for anyhow usage...
✓ PASS: No anyhow imports
✓ PASS: No anyhow! macro
✓ AppResult usage: 287 occurrences
✓ ErrorCode usage: 412 occurrences
✅ Error handling check PASSED
🔍 Checking for anyhow usage...
❌ FAIL: anyhow imports detected!
src/new_feature.rs:5:use anyhow::{anyhow, Result};
src/new_feature.rs:23: return Err(anyhow!("Something failed"));
// ❌ Before
use anyhow::{anyhow, Context, Result};
// ✅ After
use crate::errors::{AppError, AppResult, ErrorCode};
// ❌ Before
return Err(anyhow!("Database connection failed"));
// ✅ After
return Err(AppError::new(
ErrorCode::DatabaseError,
"Database connection failed".to_string()
));
// ❌ Before
let user = db.get_user(id).context("Failed to fetch user")?;
// ✅ After
let user = db.get_user(id)
.map_err(|e| AppError::new(
ErrorCode::DatabaseError,
format!("Failed to fetch user {}: {}", id, e)
))?;
src/errors.rs - ErrorCode and AppError definitionssrc/lib.rs - Error type exportserror-handling-guardian - Comprehensive error validation# One-line check
rg "use anyhow|anyhow!\(" src/ --type rust && echo "FAIL" || echo "PASS"
# Check specific file
rg "use anyhow" src/new_feature.rs --type rust
# Count error patterns
echo "AppResult: $(rg 'AppResult<' src/ --type rust | wc -l)"
echo "ErrorCode: $(rg 'ErrorCode::' src/ --type rust | wc -l)"
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience