Guidelines for AI agents (Claude Code, Copilot, Cursor, etc.) working on this codebase.
AIPocket scans for exposed AI infrastructure via FOFA + Shodan (+ GitHub artifact source), extracts and validates leaked API key/URL pairs, checks balances, and flags high-value findings.
Monorepo layout:
crates/— Rust 2024 workspace;Axum + Clap + SQLx + redis-rs + Reqwestfrontend/— React 19 + Vite + Tailwind v4 + shadcn/ui,pnpm- Infra: PostgreSQL 16, Redis 7 (see
docker-compose.yml)
- Read
CLAUDE.mdfor architecture, commands, and conventions. - Read
.env.exampleto understand configuration. - Never commit secrets or
.envfiles.
- Source:
crates/aipocket-*,依赖方向保持api → services → discovery/prober/clients/db/core。 - Validate:
cargo test --workspace - Lint:
cargo fmt --all -- --check && cargo clippy --workspace --all-targets -- -D warnings - Coverage:
cargo llvm-cov --workspace --fail-under-lines 86 - All HTTP I/O is async through shared
reqwest::Client. - Config env names/defaults must stay compatible with
.env.example; never add a required env without a compatible default. - Schema changes must be additive and idempotent. Never drop/rebuild production tables or change Redis key formats.
- New API routes belong in
aipocket-api; business logic belongs inaipocket-services, not handlers.
- Source:
frontend/src/ - Build check:
cd frontend && pnpm build - Lint:
cd frontend && pnpm lint - UI components use shadcn/ui (
components/ui/). Don't install alternative component libraries. - Server state:
@tanstack/react-query. Don't use Redux or other state managers. - Routing:
react-router-domv6. - API client:
lib/api.ts. All backend calls go through this module.
| Task | Steps |
|---|---|
| Add a platform prober | Implement Prober in aipocket-prober, register it, add behavioral tests |
| Add an API endpoint | Add route/DTO in aipocket-api, reuse a service/repository, add a contract test |
| Add a frontend page | Create page in pages/, add route in App.tsx, add sidebar link |
| Add an env var | Add a backward-compatible default to Rust Settings and .env.example |
- Introduce synchronous HTTP calls in Rust backend code
- Store runtime state, credentials, or scan results in git-tracked files
- Modify production PG/Redis volumes, URLs, database names, or ports for the Rust migration
- Add destructive migrations, flush Redis, or require
.envedits for deployment - Skip
cargo test --workspace, fmt, clippy, and frontend build validation