When working on this project, you MUST follow these guidelines to ensure code quality and project stability.
Before completing ANY task, you MUST:
- Run Diagnostics: Check for syntax, type, and linting errors
- Fix All Errors: Address every error found - do not leave the codebase broken
- Verify Build: Ensure the project builds successfully
- Run Tests: Execute relevant tests to verify functionality (if tests exist)
This is a monorepo with three main components:
frontend/- Next.js application (TypeScript, React)backend/- NestJS application (TypeScript, Node.js)contract/- Soroban smart contracts (Rust, Stellar blockchain)
# Navigate to frontend
cd frontend
# Install dependencies if needed
pnpm install
# Run type checking
pnpm run type-check
# Run linting
pnpm run lint
# Build the project
pnpm run build
# Run tests (if applicable)
pnpm run test# Navigate to backend
cd backend
# Install dependencies if needed
pnpm install
# Run type checking
pnpm run build
# Run linting
pnpm run lint
# Run tests
pnpm run test
# Verify database migrations compile
pnpm run migration:show# Navigate to contract directory
cd contract
# Ensure Rust toolchain is installed
# Install from https://rustup.rs/ if needed
# Add wasm32 target if not already added
rustup target add wasm32-unknown-unknown
# Format check
cargo fmt --all -- --check
# Lint with clippy (strict mode)
cargo clippy --all-targets --all-features -- -D warnings
# Run all tests
cargo test
# Build for WebAssembly (production target)
cargo build --target wasm32-unknown-unknown --release
# Or use the convenience script
./check-all.sh- Make Changes: Implement the requested feature or fix
- Check Diagnostics: Use getDiagnostics tool on modified files
- Fix Errors: Address all syntax, type, and linting issues
- Build Verification: Run build commands for affected components
- Test Execution: Run relevant tests if they exist
- Final Confirmation: Verify no errors remain
- Syntax Errors: Fix immediately - these break the build
- Type Errors: Resolve all TypeScript errors (frontend/backend) and Rust compiler errors (contracts)
- Linting Errors: Fix critical linting issues (ESLint for TS, Clippy for Rust)
- Linting Warnings: Address when possible, document if intentional
- Test Failures: Fix failing tests or update them appropriately
- WASM Build Errors: Ensure contracts compile to wasm32-unknown-unknown target
# Frontend
cd frontend && pnpm run type-check && pnpm run lint
# Backend
cd backend && pnpm run build && pnpm run lint
# Contract
cd contract && cargo fmt --all -- --check && cargo clippy --all-targets --all-features -- -D warnings# Frontend
cd frontend && pnpm run build
# Backend
cd backend && pnpm run build && pnpm run test
# Contract
cd contract && ./check-all.sh- Check import paths and module resolution
- Verify type definitions are installed
- Ensure tsconfig.json is properly configured
- Clear build cache:
rm -rf .next(frontend) orrm -rf dist(backend) - Reinstall dependencies:
rm -rf node_modules && npm install - Check for circular dependencies
- Auto-fix when possible:
npm run lint -- --fix - Review eslint.config.mjs for project-specific rules
- Document intentional rule violations with inline comments
- Run
cargo fmt --allto auto-format code - Address all clippy warnings:
cargo clippy --all-targets --all-features -- -D warnings - Ensure wasm32 target is installed:
rustup target add wasm32-unknown-unknown - Check Cargo.toml for dependency version conflicts
- Review contract-specific documentation in
contract/docs/
The contract/ directory contains Stellar Soroban smart contracts written in Rust. When working with contracts:
Available Contracts:
agent_registry/- Agent registration and managementchioma/- Main contract with emergency pause mechanismdispute_resolution/- Dispute handling with timeout mechanismsescrow/- Escrow management with timeout protectionpayment/- Payment processingproperty_registry/- Property registrationrent_obligation/- Rent obligation NFTsuser_profile/- User profile management
Critical Contract Features:
- Emergency pause mechanism (Chioma contract)
- Timeout mechanisms for escrow and disputes
- Event emission for monitoring
- Admin-only operations for critical functions
Contract Development Rules:
- Always run
cargo fmt --allbefore committing - Zero tolerance for clippy warnings (
-D warningsflag) - All contracts must compile to wasm32-unknown-unknown
- Test coverage is mandatory for new functions
- Document all public contract methods
- Follow Soroban best practices for storage and gas optimization
Testing Contracts:
# Run all contract tests
cd contract && cargo test
# Run tests for specific contract
cd contract && cargo test -p agent_registry
# Run tests with output
cd contract && cargo test -- --nocaptureBuilding Contracts:
# Build all contracts for WASM
cd contract && cargo build --target wasm32-unknown-unknown --release
# Build specific contract
cd contract && cargo build -p chioma --target wasm32-unknown-unknown --release
# Optimized build (if soroban-cli is installed)
cd contract && soroban contract build- getDiagnostics: Check for errors in modified files
- executeBash: Run build and test commands
- readFile: Review configuration files when debugging
- strReplace/editCode: Fix identified issues
❌ NEVER complete a task with:
- Unresolved syntax errors
- TypeScript compilation errors
- Rust compilation errors
- Failing builds (including WASM builds for contracts)
- Broken imports or missing dependencies
- Clippy warnings in contracts (strict mode: -D warnings)
✅ ALWAYS ensure:
- Code compiles successfully
- All modified files pass type checking
- Build completes without errors
- Tests pass (or are updated appropriately)
Before marking any task as complete:
- All syntax errors resolved
- All type errors fixed
- Linting passes (or violations documented)
- Build succeeds for affected components
- Tests pass (if applicable)
- No console errors in development mode
- Changes are properly committed (if in git workflow)
If you encounter persistent build failures:
- Document the exact error message
- Check recent changes that might have caused the issue
- Verify environment configuration (.env files)
- Check for version mismatches in package.json (frontend/backend) or Cargo.toml (contracts)
- Review recent migrations or schema changes (backend)
- Verify Rust toolchain and wasm32 target installation (contracts)
- Consult project documentation in
/docsfolders orcontract/docs/
A task is NOT complete until the project builds successfully.
Your responsibility is to leave the codebase in a working state, not just to implement features. Quality and stability are paramount.