agentleFS
agentidxagentidx/agentindex/CLAUDE.md

agentindex

CLAUDE.md2 starsChanged 4 months agoMITView on GitHub

Read this file first. It is the map to everything else. Then read ~/agentindex/PROGRAM.md — the operating board: everything running (timers+guards), in flight, staged, held on Anders, the decision log, and the north-star values. It is the single source of truth for program state. STANDING RULE — the board is not optional. Every Code session MUST end by updating PROGRAM.md: move status (RUNNING/IN PROGRESS/STAGED/HELD/FROZEN-TEST/DONE), log any signed decision in the Decision Log with today's date, reorder the staged queue, refresh…

  • In this repositoryOne other file it gives its agents.

The file

We split this CLAUDE.md into the rules it gives an agent

6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    When things happen in the system that neither you nor Anders did, it is probably Buzz.

    line 21
  2. Very specific:

    LaunchAgents: Use launchctl stop/start com.nerq.api -- NEVER pkill (auto-restarts).

    line 57
  3. Distinctive:

    Welcome all traffic: Do not propose blocking or rate-limiting crawlers without explicit user reconsideration.

    line 60
  4. Distinctive:

    Read task file, implement, test, commit

    line 149
  5. Distinctive:

    Write results in task file "## Result" section before moving

    line 151
  6. Distinctive:

    Delete or modify backup files

    line 160

≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md -- Orientation for Claude sessions working on Nerq/ZARQ

Read this file first. It is the map to everything else.

Then read ~/agentindex/PROGRAM.md — the operating board: everything running (timers+guards), in flight, staged, held on Anders, the decision log, and the north-star values. It is the single source of truth for program state.

STANDING RULE — the board is not optional. Every Code session MUST end by updating PROGRAM.md: move status (RUNNING/IN PROGRESS/STAGED/HELD/FROZEN-TEST/DONE), log any signed decision in the Decision Log with today's date, reorder the staged queue, refresh north-star values, and bump the "Last board update" date. A session that changed program state but didn't update the board isn't finished. The heartbeat flags the board as a silent-death class if it goes >8 days untouched.

If there is a docs/session-handoff-<date>.md file newer than this one, read that first — it contains the most recent session's context and specific tasks for you to pick up.


The critical fact you must know before touching anything

Nerq is operated 24/7 by an autonomous AI agent named Buzz, running inside openclaw (~/.openclaw/). Buzz was configured by a previous Claude instance. The system has three participants:

  1. Anders Nilsson -- strategic decisions
  2. Buzz -- 24/7 operations, health monitoring, self-healing
  3. Claude (you) -- advisory, building, fixing

When things happen in the system that neither you nor Anders did, it is probably Buzz. Do not assume you know what Buzz is doing without reading its config.

Required reading before operational work: docs/buzz-context.md


What is this system?

  • ZARQ (zarq.ai) is a crypto risk intelligence platform -- "Moody's for crypto". Trust Score, Distance-to-Default, crash probability.
  • Nerq (nerq.ai) is an AI asset search engine indexing 5M+ AI assets (204K agents & tools, 4.7M models & datasets) with Trust Scores.
  • Both run on the same FastAPI backend on one Mac Studio M1 Ultra (64 GB RAM).

Critical paths

  • Main app: ~/agentindex/agentindex/api/discovery.py (mounts as agentindex.api.discovery:app on port 8000)
  • SQLite DB (analytics): ~/agentindex/logs/analytics.db (8.77 GB as of 2026-04-09, growing)
  • SQLite DB (ratings/pipeline): ~/agentindex/agentindex/crypto/crypto_trust.db (1.5 GB as of 2026-07-21, up from 379 MB — append-only NDD/DtD/price-history time-series; frozen since 2026-07-14 when the pre-migration crypto pipeline stopped. Biggest: crypto_ndd_alerts 1.56M rows, crypto_price_history 1.24M. NOT touched by the daily market refresh/scoring, which writes to the SEO db below.)
  • SQLite DB (SEO): ~/agentindex/data/crypto_trust.db (20 MB)
  • Templates: ~/agentindex/agentindex/crypto/templates/
  • LaunchAgent: ~/Library/LaunchAgents/com.nerq.api.plist
  • Healthcheck: ~/agentindex/system_healthcheck.py
  • Autoheal: ~/agentindex/system_autoheal.py (invocation path unclear -- may be called by Buzz, not cron)
  • Redis: /opt/homebrew/bin/redis-cli (full path required)
  • Postgres: /opt/homebrew/Cellar/postgresql@16/16.11_1/bin/psql -U anstudio -d agentindex
  • DB topology (current state): docs/adr/ADR-003a-current-db-topology.md — Nbg de-facto primary without Patroni, Hel PG off, Mac Studio local replica stale. ADR-003 describes the intended HA design but is not implemented. PgBouncer at /opt/homebrew/etc/pgbouncer.ini routes agentindex_write → Nbg (100.119.193.70) per the 2026-05-30 repoint; agentindex_read → local socket.
  • Nbg dual role (added 2026-06-02): Nbg (nerq-nbg-1) runs BOTH postgresql@16-main AND nerq-api.service (systemd uvicorn, 4 workers + MemoryMax=4G). It is an HA peer to Mac Studio's API, not PG-only. Service file: /etc/systemd/system/nerq-api.service.
  • Infra healthcheck: scripts/infra_healthcheck.py + com.nerq.infra-healthcheck LaunchAgent (every 5 min). Surfaces dead PG hosts + disk + pg_wal bloat to zarq.infrastructure_alerts.
  • Cloudflare Tunnel ID: a17d8bfb-9596-4700-848a-df481dc171a4 — ACTIVE HA tunnel, NOT ghost. Both Mac Studio cloudflared and Nbg cloudflared register the same tunnel ID; Cloudflare LB picks between origins per request. Apex hostnames (nerq.ai, zarq.ai, agentcrawl.dev) are served by either node; api.*, dash.*, mcp.* subdomains are Mac Studio-only (Nbg cloudflared ingress lacks rules for them). This asymmetric-HA is documented in ADR-003a.

Key conventions -- READ THESE

  1. All shell commands MUST be wrapped in heredoc: bash << 'EOF' ... EOF. Prefer Python for anything involving markdown, multi-line text, or special characters -- heredocs are fragile with those. Use base64 for anything with embedded markdown or quotes sent through a layer of bash from a zsh shell.
  2. LaunchAgents: Use launchctl stop/start com.nerq.api -- NEVER pkill (auto-restarts). For a full restart use kill -9 + launchctl kickstart (avoids race conditions in stop+start).
  3. PostgreSQL pool: max pool_size=5, max_overflow=5
  4. ZARQ design: light theme, DM Serif Display, JetBrains Mono, DM Sans, --warm: #c2956b
  5. Welcome all traffic. Do not propose blocking or rate-limiting crawlers without explicit user reconsideration. The default answer is always "let them in."
  6. Expansion-first. Robustness is the foundation, but the goal is 50 languages and 100 verticals before monetization. See docs/adr/ADR-003-cloud-native-expansion-first.md (active strategy). ADR-002 partially superseded (DR tier ordering and infra placement replaced; expansion-first principle preserved). ADR-001 remains deferred.
  7. North-star metrics (rewritten 2026-07-21 — the old "150K human visits/day" trigger is DEAD). The human-visit number was ~99% residential-proxy garbage flood that the counter couldn't ASN-filter; true organic humans are low hundreds/day, and the 150K/day trigger was measured against a ~40×-inflated figure. Do NOT benchmark against human-visit counts. The judgment-layer thesis ("make the judgment layer irreplaceable") is measured by: (a) AI-referral count (weekly external-AI-engine referrals — the acquisition-channel signal); (b) MCP distinct external clients/week (agent-native consumption); (c) prediction-ledger age + length (zarq.ai/ledger — the time-moat); (d) incidents-where-ZARQ-was-prior (verified calls before the event); (e) gateway-feed pulls (layer-B product demand). Review quarterly against the AI-referral test verdict. Monetization follows indispensability on these axes, not a human-visit threshold.
  8. Crawler edits get a smoke test (2026-07-21 — a docstring ate the discovery layer for 5 weeks). Commit e19f619 buried import os inside crawler docstrings; every crawler threw NameError at runtime while run_all_crawlers printed "finished in 0.1s". Any commit touching agentindex/crypto/crawlers/crawl*.py MUST pass venv/bin/python scripts/crawler_smoke_test.py <files> (import + run() + no docstring-trapped imports; --discover runs one live cycle). The Mac pre-commit hook enforces it automatically. "Ran green, found nothing" is a failure, not a pass — discovery is proven by new-entity counts, not exit codes. The heartbeat's discovery_health guard watches new-entities/week per crawler source (2-consecutive-under-floor-weeks → DEGRADED). New crawlers ship with a floor entry there per §0.

Database tables (important -- schema guide)

RUNBOOK — big time-series joins (recurs for every drift/attention/time-derivative query). A two-date self-join over daily_snapshots (94.8M rows) TIMES OUT even with date indexes — PG materializes + hash-joins ~2M rows before filtering. Working pattern: build a TEMP TABLE of the smaller/earlier date-slice (optionally pre-filtered to meaningful rows), CREATE INDEX ON tmp(entity_id, registry), then JOIN the later slice via the (entity_id, date) index — targeted probes, seconds not minutes. Chain temp tables for 3-point (rate) comparisons. Push materiality filters as late as they must be, but shrink the driving slice first. (Also: daily_snapshots.downloads is CUMULATIVE/monotonic and only moves on enrichment — for velocity use weekly_downloads (the rate), not download deltas.)

Column drift between code and schema has caused multiple production incidents. Known safe patterns:

  • nerq_risk_signals (205 tokens). Columns: token_id, risk_level, structural_weakness, trust_score, ndd_current, sig6_structure, trust_p3. Does NOT have token_symbol, crash_probability, or chain -- requires joins to get those.
  • entity_lookup (Postgres, ~5M rows, 3 GB). Does NOT have language, trust_calculated_at, or tags. Use LEFT JOIN agents a ON a.id = el.id for those columns.
  • agents (Postgres, ~4.98M rows, 17 GB). Has language, tags, primary key id.
  • crash_model_v3_predictions
  • crypto_rating_daily
  • defi_protocol_tokens

Known broken schema references (as of 2026-04-09, not yet fixed):

  • stale_score_detector queries entity_lookup.trust_calculated_at -- fails daily, needs LEFT JOIN agents
  • compatibility_matrix queries SQLite npm_weekly column -- doesn't exist, fails weekly
  • yield_crawler_status table missing from healthcheck.db -- warns in autoheal every 3 min

Repository orientation

Key files, indented to show structure:

~/agentindex/
    CLAUDE.md                                  (you are here)
    docs/
        buzz-context.md                        (READ FIRST if touching operations)
        health-audit-2026-04-09.md             (Day 34 incident audit, messy but useful)
        adr/
            ADR-003-cloud-native-expansion-first.md (active architecture strategy)
            ADR-002-expansion-first-strategy.md    (partially superseded by ADR-003)
        strategy/
            phase-0-cloud-migration-plan.md                 (active implementation plan)
            phase-0-1-implementation-plan.md                (superseded by above)
            nerq-vertical-expansion-master-plan-v3.md       (14 to 100 verticals)
            nerq-traffic-sprint-v2-complete.md              (traffic acquisition)
            nerq-revenue-sprint-safe.md                     (monetization trigger)
            nerq-ai-citation-optimization-sprint.md         (AI citation optimization)
            nerq-ai-onboarding-sprint.md                    (AI-to-human funnel)
            nerq-personalization-sprint.md                  (personalized trust scores)
            nerq-dimension-expansion-sprint.md              (10 dimensions framework)
            nerq-future-dimensions-and-click-psychology.md  (CTR optimization)
    agentindex/                                (main Python package)
    system_autoheal.py                         (may or may not be called by Buzz)
    scripts/

Strategic context

The agentic economy is accelerating faster than expected. Key signals:

  • Stripe Tempo: Stripe launched agent-to-agent payments. Agents need trust scores before transacting.
  • $110T stablecoin settlement: Stablecoin settlement volume hit $110T annualized. Autonomous agents will drive the next order of magnitude.
  • Sui a402 monitoring: Sui's HTTP 402 payment protocol creates machine-native payment rails. ZARQ's tier system (open->signal->degraded->402) mirrors this pattern.
  • On-chain oracle (long-term): Publishing ZARQ Trust Scores on-chain as a Chainlink-style oracle is a viable exit path. Protocols could gate DeFi actions on ZARQ ratings.
  • Positioning: ZARQ is the trust layer for the machine economy. Every autonomous financial decision -- swaps, lending, portfolio rebalancing -- needs a trust anchor. ZARQ provides that anchor: independent, quantitative, hash-chained, machine-readable risk intelligence.

Known broken things (as of 2026-04-09)

  1. OPERATIONSPLAN.md is stale (dated Feb 2026) -- Buzz operates on a 6-8 weeks outdated plan. Needs rewrite.
  2. Discord integration broken -- Anders not receiving Buzz reports for 24+ hours.
  3. Schema drift: see "Database tables" section above.
  4. Newsletter job hardcoded to claude-sonnet-4-20250514 (model not allowed, failing 2+ weeks).
  5. Memory pressure: Mac Studio runs at 95% RAM constantly, 75% swap used.
  6. Pending sudo fixes: scripts/apply_system_limits.sh, auto-login anstudio, UPS purchase. Sudo password unknown -- needs recovery.

Task system

  • New tasks: ~/agentindex/tasks/queue/
  • Read task file, implement, test, commit
  • Move task to done/ when complete, failed/ if it fails
  • Write results in task file "## Result" section before moving

What you must NOT do

  • Change database schema without explicit instruction
  • Restart LaunchAgents with pkill
  • Change Cloudflare configuration without explicit instruction
  • Delete or modify backup files
  • Modify nerq_risk_signals table directly
  • Associate Nerq or ZARQ with any legal entity name without explicit user confirmation
  • Propose 17-week migrations (ADR-001 is deferred, ADR-003 is the active strategy)
  • Unload LaunchAgents assuming they stay unloaded -- Buzz may re-load them
  • Make claims about Buzz's behavior without reading ~/.openclaw/cron/jobs.json and ~/.openclaw/workspace/OPERATIONSPLAN.md first

What you can expect from Anders

  • Strategic direction and final approval on architectural changes
  • Fast decisions when given clear options and tradeoffs
  • Pushback when you over-engineer or lose sight of expansion goals
  • Swedish casually, English technically -- both are fine
  • He is not a coder. Do not expect him to debug code for you. Do it yourself or explain clearly what you need verified.

If you are Claude Code in the terminal

You also have access to claude-code directly on this server. Anders can invoke you that way too. When working in that mode, you have full shell access and can operate directly on files. The same rules above apply.


This file should be updated whenever the operational context changes significantly. Last updated: 2026-04-09.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.