LibrAgent Code Quality Validation
This skill provides comprehensive code quality validation for the LibrAgent project, which uses a dual-stack architecture with React/TypeScript frontend and Rust/Tauri backend.
Quick Start
For complete validation before commits or PRs:
pnpm refactor:validate
This runs all checks in sequence and ensures code quality across the entire stack.
Individual Validation Commands
Frontend (TypeScript/React)
# Linting - Check code style and potential errors pnpm lint # Format checking pnpm format:check # Auto-fix formatting issues pnpm format # Type checking and build pnpm build # Dead code detection pnpm dead-code # Run tests pnpm test:run
Backend (Rust)
# Format checking pnpm rust:fmt:check # Auto-format Rust code pnpm rust:fmt # Lint with clippy pnpm rust:clippy # Type checking pnpm rust:check # Check with all features pnpm rust:check:all # Run tests pnpm rust:test # Complete Rust validation pnpm rust:validate
Complete Validation Pipeline
The refactor:validate command executes:
- •ESLint - JavaScript/TypeScript code quality
- •Prettier - Code formatting consistency
- •Vitest - Test suite execution
- •Rust fmt - Rust code formatting
- •Rust clippy - Rust linting
- •Rust check - Rust compilation check with all features
- •Rust test - Rust test suite
- •Vite build - Production build verification
- •Unimported - Unused code detection
Common Validation Scenarios
Before Committing
pnpm refactor:validate
Wait for all checks to pass. Fix any errors reported.
Quick Frontend Check
pnpm lint && pnpm format && pnpm build
Quick Backend Check
pnpm rust:validate
Fix Formatting Issues
# Fix frontend formatting pnpm format # Fix Rust formatting pnpm rust:fmt
Critical Project Rules
TypeScript Rules
- •Never use
any- Use precise types,unknownwith type guards, or generics - •No ESLint-disable comments - Fix the underlying issue instead
- •Use centralized logger -
getLogger('ComponentName')notconsole.* - •No inline import types - Use proper import statements at top of file
Rust Rules
- •Use
rustfmt- Always format before committing - •Fix clippy warnings - No warnings allowed (
-D warningsin CI) - •Handle errors explicitly - Use
Result<T, E>types - •Document public APIs - Use
///doc comments
Architecture Rules
- •Feature-based organization - Components in
src/features/ - •Service layer pattern - Business logic in
src/lib/ - •Compound components - Use patterns like
Chat.Header,Chat.Messages - •Type safety - Define interfaces in
src/models/
Troubleshooting
ESLint Errors
Check .eslintrc.js or eslint.config.js for rules. Fix code to match standards.
Prettier Conflicts
Run pnpm format to auto-fix formatting issues.
Rust Clippy Warnings
Read clippy suggestions carefully - they often indicate actual bugs or improvements.
Build Failures
- •Check TypeScript errors:
tsc --noEmit - •Check Rust errors:
cd src-tauri && cargo check - •Verify dependencies:
pnpm install
Dead Code Detection
Review unimported output. Remove unused exports or add to ignore list if intentional.
Integration with CI/CD
The project uses GitHub Actions for CI. All validation commands must pass before merge:
- •ESLint must pass
- •Prettier formatting must be correct
- •TypeScript must compile without errors
- •Rust must compile without warnings
- •All tests must pass
- •No dead code (with approved exceptions)
Best Practices
- •Run validation early and often - Don't wait until PR time
- •Fix issues incrementally - Easier to debug when changes are small
- •Read error messages carefully - They often contain the solution
- •Keep tests passing - Don't commit broken tests
- •Document exceptions - If you must disable a rule, explain why
Reference
For detailed project guidelines, see:
- •
.github/copilot-instructions.md- Complete coding standards - •
agents.md- Agent-specific guidelines - •
docs/architecture/- Architecture documentation - •
CONTRIBUTING.md- Contribution guidelines