CLAUDE.md
CLAUDE.mdCLAUDE.mdroot
Quality
100/100
Scores the file, not the repository.Length
1,016 words
23 headings · 2 code blocksRepository
45
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# NightmareNet — Agent Instructions23## Project Overview45NightmareNet is an **Autonomous AI Self-Improvement Platform** using a sleep-inspired training paradigm. It forces neural networks to learn invariant structures through 4-phase cycles: Wake → Dream → Nightmare → Compress.67**Stack**: Python ≥3.9, PyTorch, Transformers, FastAPI, Next.js 14 (frontend)89## Repository Structure1011```12nightmarenet/ # Core Python package13 api/ # FastAPI endpoints (app.py, schemas.py)14 compression/ # Knowledge distillation15 data/ # Dataset loading & processing16 distortions/ # Dream & nightmare distortion engines17 evaluation/ # Robustness evaluation & metrics18 training/ # Training loops, DDP, experiment tracking19 utils/ # Config, early stopping, type hints20frontend/ # Next.js 14 + Framer Motion + Tailwind21 src/components/ # React components (cyberpunk UI)22 src/lib/api.ts # TypeScript API client23tests/ # pytest suite (206+ tests)24configs/ # YAML training configs25scripts/ # CLI entry points26```2728## Critical Build & Test Commands2930```bash31# Activate venv (ALWAYS use .venv312 — Python 3.12 + CUDA)32.venv312\Scripts\Activate.ps1 # Windows33source .venv/bin/activate # Unix3435# Run all tests36pytest tests/ -v --tb=short3738# Run specific test module39pytest tests/test_distortions.py -v4041# Lint (must pass with 0 errors)42ruff check .4344# Type check45mypy nightmarenet/4647# Start API server (--env-file ensures .env propagates to reload workers)48uvicorn nightmarenet.api.app:app --reload --port 8000 --env-file .env4950# Frontend51cd frontend && npm run dev # Dev server on :300052cd frontend && npm run build # Production build53```5455## Code Style & Conventions5657- **Line length**: 100 chars58- **Ruff rules**: E, F, W, I, N, UP, B (ignore UP007, UP045)59- **Imports**: isort via ruff — stdlib, third-party, local (alphabetical within groups)60- **Type hints**: Use `Union[X, Y]` not `X | Y` (Python 3.9 compat)61- **DO NOT** use `from __future__ import annotations` in any file that uses FastAPI `Body(...)` — it breaks Pydantic v2 at runtime62- **Docstrings**: Google style, only on public APIs63- **Error handling**: Raise with context (`raise X from e`), not bare `raise`6465## Architecture Constraints66671. **No `from __future__ import annotations`** in `nightmarenet/api/` — Pydantic v2 + FastAPI incompatibility682. **Python 3.9 minimum** — no walrus operator assumptions, use `Union[X, Y]` over `X | Y`693. **Optional deps are optional** — guard imports with try/except: `accelerate`, `wandb`, `tensorboard`704. **FastAPI Body singletons** — `_DISTORTION_BODY` and `_ROBUSTNESS_BODY` are module-level to avoid B008715. **CORS** — configured via `NIGHTMARENET_CORS_ORIGINS` env var (default: `*`)726. **Health** — optional `NIGHTMARENET_HEALTH_TEST_COUNT=1` enables subprocess `pytest --collect-only` in `/api/v1/health` (off by default; avoid in production)737. **Pipeline registry** — `NIGHTMARENET_MAX_PIPELINE_RUNNERS` caps in-memory runners (default 64); completed runs are evicted first748. **Next.js proxy** — `frontend/next.config.ts` uses `NEXT_API_REWRITE_URL` for where `/api/`* rewrites; see `frontend/README.md`7576## Testing Requirements7778- **206+ tests passing** — never commit code that reduces the test count79- Run `pytest` before claiming any task is complete80- Run `ruff check .` before claiming lint cleanliness81- Tests live in `tests/` — mirror the package structure82- Use `monkeypatch` for env vars, never modify `os.environ` directly8384## API Endpoints858687| Method | Path | Purpose |88| ------ | ----------------------------- | --------------------------------------------- |89| GET | `/api/v1/health` | Health check (status, version, tests) |90| POST | `/api/v1/generate/dream` | Dream distortion `{text, strength, seed}` |91| POST | `/api/v1/generate/nightmare` | Nightmare distortion `{text, strength, seed}` |92| POST | `/api/v1/evaluate/robustness` | Multi-strength eval `{text, strengths[]}` |939495## Frontend Notes9697- **Framework**: Next.js 14 (App Router), TypeScript, Tailwind CSS v498- **Design**: Cyberpunk dark theme — void (#020617), dream (#818CF8), nightmare (#EF4444), neural (#06B6D4)99- **Animations**: Framer Motion throughout100- **API client**: `frontend/src/lib/api.ts` — typed client for all 4 endpoints101- **Key constraint**: Tailwind v4 uses `@theme inline` block, not `tailwind.config.js`102103## Git Workflow104105- Conventional commits: `feat:`, `fix:`, `docs:`, `test:`, `refactor:`, `chore:`106- Run tests + lint before any commit107- Keep commits atomic — one concern per commit108109## Known Issues & Gotchas110111- `Accelerator` import is optional — guarded with `Accelerator: Any = None` fallback112- `evaluator._log_eval()` guards against `self.tracker is None`113- Rate limiting on API uses `slowapi` — 60 req/min on generate, 10 req/min on evaluate114115<!-- gitnexus:start -->116# GitNexus — Code Intelligence117118This project is indexed by GitNexus as **NightmareNet** (4310 symbols, 7685 relationships, 161 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.119120> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first.121122## Always Do123124- **MUST run impact analysis before editing any symbol.** Before modifying a function, class, or method, run `gitnexus_impact({target: "symbolName", direction: "upstream"})` and report the blast radius (direct callers, affected processes, risk level) to the user.125- **MUST run `gitnexus_detect_changes()` before committing** to verify your changes only affect expected symbols and execution flows.126- **MUST warn the user** if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.127- When exploring unfamiliar code, use `gitnexus_query({query: "concept"})` to find execution flows instead of grepping. It returns process-grouped results ranked by relevance.128- When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use `gitnexus_context({name: "symbolName"})`.129130## Never Do131132- NEVER edit a function, class, or method without first running `gitnexus_impact` on it.133- NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.134- NEVER rename symbols with find-and-replace — use `gitnexus_rename` which understands the call graph.135- NEVER commit changes without running `gitnexus_detect_changes()` to check affected scope.136137## Resources138139| Resource | Use for |140|----------|---------|141| `gitnexus://repo/NightmareNet/context` | Codebase overview, check index freshness |142| `gitnexus://repo/NightmareNet/clusters` | All functional areas |143| `gitnexus://repo/NightmareNet/processes` | All execution flows |144| `gitnexus://repo/NightmareNet/process/{name}` | Step-by-step execution trace |145146## CLI147148| Task | Read this skill file |149|------|---------------------|150| Understand architecture / "How does X work?" | `.claude/skills/gitnexus/gitnexus-exploring/SKILL.md` |151| Blast radius / "What breaks if I change X?" | `.claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md` |152| Trace bugs / "Why is X failing?" | `.claude/skills/gitnexus/gitnexus-debugging/SKILL.md` |153| Rename / extract / split / refactor | `.claude/skills/gitnexus/gitnexus-refactoring/SKILL.md` |154| Tools, resources, schema reference | `.claude/skills/gitnexus/gitnexus-guide/SKILL.md` |155| Index, status, clean, wiki CLI commands | `.claude/skills/gitnexus/gitnexus-cli/SKILL.md` |156157<!-- gitnexus:end -->158
Also in Adit-Jain-srm/NightmareNet
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| Adit-Jain-srm/NightmareNet.cursor/rules/agent-core.mdc · 45 | Cursor rules | gitsecuritydo-notagent-behaviour | 76/100 | 3 days ago | |
| Adit-Jain-srm/NightmareNet.cursor/rules/contribution-standards.mdc · 45 | Cursor rules | testgit | 54/100 | 3 days ago | |
| Adit-Jain-srm/NightmareNet.cursor/rules/diagrams.mdc · 45 | Cursor rules | styledo-notdocs | 27/100 | 3 days ago | |
| Adit-Jain-srm/NightmareNet.cursor/rules/grill.mdc · 45 | Cursor rules | builddo-not | 55/100 | 3 days ago | |
| Adit-Jain-srm/NightmareNet.cursor/rules/max-effort.mdc · 45 | Cursor rules | no sections | 39/100 | 3 days ago | |
| Adit-Jain-srm/NightmareNet.cursor/rules/prompt-amplifier.mdc · 45 | Cursor rules | do-not | 46/100 | 3 days ago | |
| Adit-Jain-srm/NightmareNet.cursor/rules/self-review.mdc · 45 | Cursor rules | gitdo-not | 46/100 | 3 days ago | |
| Adit-Jain-srm/NightmareNet.cursor/rules/skill-forge.mdc · 45 | Cursor rules | deploymentdo-not | 51/100 | 3 days ago | |
| Adit-Jain-srm/NightmareNet.cursor/rules/skill-orchestration.mdc · 45 | Cursor rules | no sections | 39/100 | 3 days ago |
Diff against .cursor/rules/agent-core.mdc Diff against .cursor/rules/contribution-standards.mdc Diff against .cursor/rules/diagrams.mdc Diff against .cursor/rules/grill.mdc Diff against .cursor/rules/max-effort.mdc Diff against .cursor/rules/prompt-amplifier.mdc Diff against .cursor/rules/self-review.mdc Diff against .cursor/rules/skill-forge.mdc Diff against .cursor/rules/skill-orchestration.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| bagisto/bagistoCLAUDE.md · 28k | CLAUDE.md | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| dotCMS/corecore-web/CLAUDE.md · 950 | CLAUDE.md | teststylearchtesting-strategy+3 | 100/100 | 3 days ago | |
| microsoft/playwrightCLAUDE.md · 94k | CLAUDE.md | buildtestlint-formatstyle+7 | 100/100 | 3 days ago | |
| nimbalyst/nimbalystpackages/android/CLAUDE.md · 1.4k | CLAUDE.md | setupbuildstylearch+2 | 100/100 | 3 days ago | |
| filamentphp/filamentCLAUDE.md · 32k | CLAUDE.md | buildtestlint-formatstyle+7 | 100/100 | 3 days ago | |
| dotCMS/coreCLAUDE.md · 950 | CLAUDE.md | setupbuildteststyle+7 | 99/100 | 3 days ago | |
| lollipopkit/flutter_server_boxCLAUDE.md · 8.3k | CLAUDE.md | buildteststylearch+2 | 98/100 | 3 days ago | |
| oven-sh/buntest/CLAUDE.md · 95k | CLAUDE.md | teststyletesting-strategydo-not | 97/100 | 3 days ago |
