boundary-bbcr-fallback
Execute automatic BBCR (Collapse-Rebirth Correction) when knowledge boundaries are exceeded or reasoning fails.
Comprehensive audit of Rust codebase against Clean Architecture principles, identifying violations and improvement opportunities
$ npx -y skills add qdhenry/Claude-Command-Suite --agent claude-codeHow it fires
How this command gets triggered: by you, by Claude, or both.
/audit-clean-archContext preview
What this command does when you run it.
Comprehensive audit of Rust codebase against Clean Architecture principles, identifying violations and improvement opportunities
name: rust:audit-clean-arch description: Comprehensive audit of Rust codebase against Clean Architecture principles, identifying violations and improvement opportunities allowed-tools: Read, Grep, Glob, Bash author: Quintin Henry (https://github.com/qdhenry/)
Perform a comprehensive audit of a Rust codebase against Clean Architecture principles, identifying violations, anti-patterns, and improvement opportunities.
Audit the Rust codebase for clean architecture compliance: **$ARGUMENTS**
> **Note:** `$ARGUMENTS` can specify a path, specific concerns, or be empty for full audit. > Examples: > > - `/rust:audit-clean-arch` - Full audit of current directory > - `/rust:audit-clean-arch src/` - Audit specific path > - `/rust:audit-clean-arch --focus dependencies` - Focus on dependency violations
---
┌─────────────────────────────────────────────────────────────┐ │ Infrastructure │ │ (Setup, Config, DB Pools, Environment, Third-party Deps) │ │ ┌───────────────────────────────────────────────────────┐ │ │ │ Adapters │ │ │ │ (HTTP Handlers, Persistence Impl, Crypto, Gateways) │ │ │ │ ┌─────────────────────────────────────────────────┐ │ │ │ │ │ Application │ │ │ │ │ │ (Use Cases, Ports/Traits, App Errors) │ │ │ │ │ │ ┌───────────────────────────────────────────┐ │ │ │ │ │ │ │ Domain │ │ │ │ │ │ │ │ (Entities, Domain Services, Value Objs) │ │ │ │ │ │ │ └───────────────────────────────────────────┘ │ │ │ │ │ └─────────────────────────────────────────────────┘ │ │ │ └───────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────┘ THE DEPENDENCY RULE: Dependencies may only point INWARD - Domain depends on NOTHING external - Application depends only on Domain - Adapters depend on Application (and implement its ports) - Infrastructure depends on all inner layers (for wiring)
---
First, map the codebase structure to identify layers:
# Find all Rust source files find . -name "*.rs" -type f | head -50 # Look for common clean architecture patterns ls -la src/ # Check for layer directories for dir in domain application adapters infrastructure core lib api handlers services; do [ -d "src/$dir" ] && echo "Found: src/$dir" done
Map discovered directories to architectural layers:
| Layer | Common Directory Names | | ------------------ | --------------------------------------------------------------------------------------------------- | | **Domain** | `domain/`, `entities/`, `models/`, `core/domain/` | | **Application** | `application/`, `use_cases/`, `usecases/`, `services/` (business), `core/` | | **Adapters** | `adapters/`, `api/`, `handlers/`, `controllers/`, `repositories/`, `persistence/`, `http/`, `grpc/` | | **Infrastructure** | `infrastructure/`, `infra/`, `config/`, `db/`, `main.rs` setup code |
**Document the mapping:**
## Layer Mapping for This Codebase - Domain: `src/???` - Application: `src/???` - Adapters: `src/???` - Infrastructure: `src/???` - Unclear/Mixed: `src/???`
---
For each layer, check what it imports:
# Check domain layer imports (should be minimal) grep -rn "^use " src/domain/ 2>/dev/null | grep -v "use crate::domain" | grep -v "use std::" | grep -v "use uuid::" # Check application layer imports (should only use domain) grep -rn "^use crate::" src/application/ 2>/dev/null # Check adapters imports (should use application, not domain directly for business logic) grep -rn "^use crate::" src/adapters/ 2>/dev/null
**CRITICAL VIOLATIONS (Red Flags):**
| Violation | Pattern to Find | Severity | | ---------------------------------- | -------------------------------------------------- | -------- | | Domain imports adapters | `use crate::adapters` in domain/ | CRITICAL | | Domain imports infrastructure | `use crate::infrastructure` in domain/ | CRITICAL | | Domain imports application | `use crate::application` in domain/ | CRITICAL | | Application imports adapters | `use crate::adapters` in application/ | HIGH | | Application imports infrastructure | `use crate::infrastructure` in application/ | HIGH | | Domain depends on web framework | `use axum`, `use actix`, `use rocket` in domain/ | CRITICAL | | Domain depends on DB | `use sqlx`, `use diesel`, `use sea_orm` in domain/ | CRITICAL |
Check if dependencies are properly scoped:
# Review Cargo.toml for dependency placement cat Cargo.toml # Check for feature flags that might isolate dependencies grep -A5 "\[features\]" Cargo.toml
**Ideal Dependency Separation:**
---
Look for traits that define boundaries (ports):
# Find async traits (common for repository ports) grep -rn "async_trait" src/ # Find trait definitions in application layer grep -rn "^pub tr
A comprehensive development toolkit designed following Anthropic's Claude Code Best Practices for AI-assisted software development.
Repo: qdhenry/Claude-Command-Suite
Execute automatic BBCR (Collapse-Rebirth Correction) when knowledge boundaries are exceeded or reasoning fails.
Analyze semantic position relative to knowledge boundaries to prevent hallucination and identify uncertainty zones.
Generate a visual heatmap of knowledge boundaries showing safe zones, risk areas, and semantic coverage.
Evaluate the current risk level and provide detailed analysis of potential hallucination or reasoning failure.
Find and construct semantic bridges to safely navigate from current position to target concept without crossing dangerous boundaries.
Takes an input prompt and returns ONLY a token-optimized version that preserves meaning while minimizing token count. Based on LLM tokenization principles:…