โ† Discover MCPs and Agents
G
AgentAI & MLGitHub

Geneclaw

Self-evolving AI agent framework with 5-layer safety gatekeeper. Agents observe failures, propose fixes, and safely apply them. Built on HKUDS/nanobot.

Links

README

From the repo.

๐Ÿงฌ Geneclaw โ€” Self-Evolving AI Agent Framework

Website Python License GEP Version Upstream

geneclaw.ai ยท GitHub ยท Protocol Spec ยท Quickstart

Built on nanobot โ€” adds closed-loop self-improvement via the Geneclaw Evolution Protocol (GEP)


Geneclaw extends the ultra-lightweight nanobot AI agent with a self-evolution engine โ€” enabling the agent to observe its own failures, diagnose root causes, propose constrained fixes, and safely apply them behind a multi-layered gatekeeper.

Everything is dry-run by default. Nothing is applied without explicit human approval.

๐Ÿ“– Visit geneclaw.ai for documentation, demos, and community resources.

Key Capabilities

CapabilityDescription
ObservabilityJSONL event recording for every agent interaction (inbound, tools, errors, outbound)
DiagnosisHeuristic failure analysis + optional LLM-assisted root cause identification
Evolution ProposalsStructured JSON proposals with unified diffs, risk levels, and rollback plans
Gatekeeper5-layer safety validation (allowlist, denylist, diff size, secret scan, code pattern detection)
Safe ApplyGit-branched patch application with automated test execution and rollback on failure
AutopilotConfigurable multi-cycle evolution loop with risk-based auto-approve
DashboardRead-only Streamlit web dashboard for evolution audit, timeline, and benchmark visualisation
BenchmarksPipeline performance measurement with synthetic workloads and JSONL persistence
Event StoreAppend-only evolution lifecycle logging with secret redaction
ReportingAggregated pipeline statistics (table + JSON output)
DoctorRead-only health checks with actionable suggestions

Architecture

                     Geneclaw Evolution Protocol (GEP v0)
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                                                             โ”‚
    โ”‚   Observe โ”€โ”€โ†’ Diagnose โ”€โ”€โ†’ Propose โ”€โ”€โ†’ Gate โ”€โ”€โ†’ Apply      โ”‚
    โ”‚      โ”‚            โ”‚            โ”‚          โ”‚         โ”‚       โ”‚
    โ”‚   recorder    evolver      evolver    gatekeeper  apply     โ”‚
    โ”‚   (JSONL)    (heuristic    (JSON +    (5 checks)  (git +   โ”‚
    โ”‚               + LLM)       diff)                  pytest)  โ”‚
    โ”‚      โ”‚            โ”‚            โ”‚          โ”‚         โ”‚       โ”‚
    โ”‚      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ”‚
    โ”‚                         โ”‚                                   โ”‚
    โ”‚                    event_store                               โ”‚
    โ”‚                    (audit log)                               โ”‚
    โ”‚                                                             โ”‚
    โ”œโ”€โ”€โ”€ autopilot   (multi-cycle controller)                     โ”‚
    โ”œโ”€โ”€โ”€ dashboard   (Streamlit read-only visualisation)          โ”‚
    โ”œโ”€โ”€โ”€ benchmarks  (performance measurement)                    โ”‚
    โ”œโ”€โ”€โ”€ doctor      (health checks)                              โ”‚
    โ””โ”€โ”€โ”€ report      (statistics aggregation)                     โ”‚
                                                                  โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ”‚                  nanobot (upstream)                          โ”‚
    โ”‚   agent/loop.py โ†โ†’ channels โ†โ†’ providers โ†โ†’ tools           โ”‚
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Project Structure

Clawland-AI/Geneclaw
โ”œโ”€โ”€ geneclaw/                      # GEP v0 evolution engine
โ”‚   โ”œโ”€โ”€ __init__.py                # Package metadata (v0.1.0)
โ”‚   โ”œโ”€โ”€ models.py                  # RunEvent, EvolutionProposal, EvoEvent
โ”‚   โ”œโ”€โ”€ redact.py                  # Secret redaction (regex-based)
โ”‚   โ”œโ”€โ”€ recorder.py                # JSONL run event recorder
โ”‚   โ”œโ”€โ”€ evolver.py                 # Heuristic + LLM proposal generator
โ”‚   โ”œโ”€โ”€ gatekeeper.py              # Safety validation (5 checks)
โ”‚   โ”œโ”€โ”€ apply.py                   # Git-branched diff application
โ”‚   โ”œโ”€โ”€ event_store.py             # Append-only evolution event log
โ”‚   โ”œโ”€โ”€ report.py                  # Statistics aggregation
โ”‚   โ”œโ”€โ”€ doctor.py                  # Health checks
โ”‚   โ”œโ”€โ”€ autopilot.py               # Multi-cycle evolution controller
โ”‚   โ”œโ”€โ”€ benchmarks.py              # Pipeline performance benchmarks
โ”‚   โ”œโ”€โ”€ cli.py                     # Typer CLI subcommands
โ”‚   โ””โ”€โ”€ dashboard/                 # Streamlit dashboard (read-only)
โ”‚       โ”œโ”€โ”€ app.py                 # Streamlit entry point
โ”‚       โ”œโ”€โ”€ loader.py              # Data loading, filtering, redaction
โ”‚       โ””โ”€โ”€ views/                 # Overview, Timeline, Audit, Benchmarks
โ”œโ”€โ”€ nanobot/                       # Upstream agent framework (HKUDS/nanobot)
โ”‚   โ”œโ”€โ”€ agent/                     # Core agent loop + tools
โ”‚   โ”œโ”€โ”€ channels/                  # Chat platform integrations
โ”‚   โ”œโ”€โ”€ providers/                 # LLM providers
โ”‚   โ”œโ”€โ”€ config/                    # Configuration schema
โ”‚   โ””โ”€โ”€ cli/                       # Main CLI entry point
โ”œโ”€โ”€ tests/                         # 123 tests across 8 files
โ”‚   โ”œโ”€โ”€ test_geneclaw_recorder.py
โ”‚   โ”œโ”€โ”€ test_geneclaw_evolver.py
โ”‚   โ”œโ”€โ”€ test_geneclaw_gatekeeper.py
โ”‚   โ”œโ”€โ”€ test_geneclaw_doctor.py
โ”‚   โ”œโ”€โ”€ test_geneclaw_events.py
โ”‚   โ”œโ”€โ”€ test_geneclaw_autopilot.py
โ”‚   โ””โ”€โ”€ test_geneclaw_dashboard.py
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ specs/GEP-v0.md            # Protocol specification
โ”‚   โ”œโ”€โ”€ quickstart/Geneclaw-Runbook.md
โ”‚   โ”œโ”€โ”€ ops/
โ”‚   โ”‚   โ”œโ”€โ”€ github-governance.md   # Branch protection & PR checklist
โ”‚   โ”‚   โ”œโ”€โ”€ release-runbook.md     # Tagging & release process
โ”‚   โ”‚   โ”œโ”€โ”€ llm-provider-setup.md  # Secure LLM provider configuration
โ”‚   โ”‚   โ”œโ”€โ”€ first-real-proposal.md # Guide: first non-no-op proposal
โ”‚   โ”‚   โ”œโ”€โ”€ upstream-sync.md       # Upstream merge strategy
โ”‚   โ”‚   โ”œโ”€โ”€ dashboard-runbook.md   # Dashboard operations
โ”‚   โ”‚   โ””โ”€โ”€ first-live-run-*.md    # Audit records
โ”‚   โ””โ”€โ”€ devlog/                    # Daily development logs
โ””โ”€โ”€ .github/
    โ”œโ”€โ”€ workflows/ci.yml           # CI pipeline
    โ””โ”€โ”€ pull_request_template.md

Install

From source (recommended)

git clone https://github.com/Clawland-AI/Geneclaw.git
cd Geneclaw
pip install -e ".[dev]"

With Dashboard support

pip install -e ".[dev,dashboard]"

Add upstream remote (for syncing with nanobot)

git remote add upstream https://github.com/HKUDS/nanobot.git

Quick Start

1. Initialize

nanobot onboard

2. Enable Geneclaw

Add or merge into ~/.nanobot/config.json:

{
  "geneclaw": {
    "enabled": true,
    "redactEnabled": true,
    "allowApplyDefault": false,
    "allowlistPaths": ["geneclaw/", "docs/"],
    "denylistPaths": [".env", "secrets/", ".git/", "config.json"],
    "maxPatchLines": 500
  }
}

3. Verify

nanobot geneclaw doctor

4. Chat (generates run events)

nanobot agent -m "Hello, what tools do you have?"

5. Generate evolution proposal

nanobot geneclaw evolve --dry-run

6. View statistics

nanobot geneclaw report

7. Launch Dashboard

nanobot geneclaw dashboard
# opens http://localhost:8501

CLI Reference

All commands are under nanobot geneclaw:

CommandDescription
nanobot geneclaw doctorHealth checks โ€” config, paths, permissions
nanobot geneclaw statusCurrent state โ€” enabled, sessions, last run
nanobot geneclaw evolve --dry-runGenerate evolution proposal (dry-run default)
nanobot geneclaw evolve --applyGenerate and apply proposal (requires config)
nanobot geneclaw apply <file.json>Apply a saved proposal file
nanobot geneclaw reportPipeline statistics (table)
nanobot geneclaw report --format jsonPipeline statistics (JSON)
nanobot geneclaw autopilotMulti-cycle evolution loop
nanobot geneclaw benchmarkPipeline performance benchmarks
nanobot geneclaw benchmark --saveRun benchmarks and persist results to JSONL
nanobot geneclaw dashboardLaunch Streamlit dashboard (read-only)

Autopilot Options

nanobot geneclaw autopilot \
  --max-cycles 5 \
  --cooldown 10 \
  --auto-approve low \
  --dry-run \
  --format table
OptionDefaultDescription
--max-cycles3Maximum evolution cycles
--cooldown5.0Seconds between cycles
--auto-approvelowRisk threshold for auto-approve (none, low)
--dry-run/--applydry-runApply mode requires allow_apply_default=true
--stop-on-failure/--continuestopHalt on first apply failure
--formattableOutput format (table, json)

Benchmark Options

nanobot geneclaw benchmark \
  --event-counts 100,500,1000 \
  --gate-iterations 100 \
  --save \
  --format table

Dashboard Options

nanobot geneclaw dashboard \
  --port 8501 \
  --events /path/to/events.jsonl \
  --benchmarks /path/to/benchmarks.jsonl

The dashboard provides four read-only views: Overview (KPIs, risk distribution), Event Timeline (charts with time filters), Proposal Audit (per-proposal metadata inspection), and Benchmarks (performance trends).

Configuration

The geneclaw section in ~/.nanobot/config.json:

FieldTypeDefaultDescription
enabledboolfalseEnable geneclaw observability + evolution
logMaxCharsint500Max chars per event preview
redactEnabledbooltrueRedact secrets in all logs
allowApplyDefaultboolfalseMust be true to allow --apply
allowlistPathslist["geneclaw/", "nanobot/", "tests/", "docs/"]Paths proposals may modify
denylistPathslist[".env", "secrets/", ".git/", "config.json"]Paths that are always blocked
maxPatchLinesint500Maximum diff lines allowed

Safety Model

Geneclaw enforces multiple layers of protection:

1. Dry-Run Default

All commands default to --dry-run. Proposals are generated and validated but never applied without explicit --apply flag AND allowApplyDefault=true in config.

2. Gatekeeper (5 Checks)

Every proposal must pass all five checks before application:

CheckWhat it does
Path AllowlistAll files_touched must start with an allowed prefix
Path DenylistNo file may match a denied path (.env, secrets/, etc.)
Diff Size LimitLine count must not exceed maxPatchLines
Secret ScanDiff is scanned for API keys, tokens, PEM keys
Code Pattern ScanDetects eval(), exec(), os.system(), subprocess.call()

3. Git Safety

  • Creates a dedicated evo/<timestamp>-<slug> branch
  • Runs git apply --check before actual application
  • Executes pytest -q after patching
  • Automatic rollback on test failure (branch deleted, previous state restored)

4. Secret Redaction

All event logs (run events + evolution events) pass through regex-based redaction before being written to disk. Patterns include API keys, tokens, passwords, PEM blocks, and Bearer tokens. The dashboard re-applies redaction at the display layer.

5. Recommended Allowlist Strategy

Start minimal and expand only after successful, reviewed evolution cycles:

PhaseAllowlistWhen
Bootstrapgeneclaw/, docs/Day 1
Expanded+ tests/After 5+ reviewed proposals
Full+ nanobot/After 20+ reviewed proposals

See docs/specs/GEP-v0.md Section 10 for the complete strategy.

Slash Command

When chatting with the agent, use /evolve to trigger an in-conversation evolution analysis:

You: /evolve
Bot: Evolution analysis started in background. Results will be posted shortly.
Bot: [Evolution Proposal: ...] (always dry-run, never auto-applies)

Data Layout

All runtime data lives under the nanobot workspace (~/.nanobot/workspace/):

~/.nanobot/workspace/geneclaw/
โ”œโ”€โ”€ runs/                      # Run event logs (per session, per day)
โ”‚   โ””โ”€โ”€ <session_key>/
โ”‚       โ””โ”€โ”€ YYYYMMDD.jsonl
โ”œโ”€โ”€ events/                    # Evolution lifecycle events
โ”‚   โ””โ”€โ”€ events.jsonl
โ”œโ”€โ”€ proposals/                 # Generated proposals
โ”‚   โ””โ”€โ”€ proposal_YYYYMMDD_HHMMSS.json
โ””โ”€โ”€ benchmarks/                # Performance benchmark results
    โ””โ”€โ”€ benchmarks.jsonl

Testing

# Run all geneclaw tests
pytest tests/test_geneclaw_*.py -q

# Run full test suite
pytest -q

Current test coverage: 123 tests across 8 test files.

Development

Upstream Sync

git fetch upstream
git merge upstream/main --no-edit
# resolve conflicts if any

See docs/ops/upstream-sync.md for the complete strategy.

Branch Naming

PrefixPurpose
feat/<topic>New features
fix/<topic>Bug fixes
chore/<topic>Maintenance
evo/<timestamp>-<slug>Auto-generated by evolution engine

Commit Convention

feat(geneclaw): add autopilot controller

Evo-Event-ID: abc123
Risk-Level: low
Tests: pytest tests/test_geneclaw_autopilot.py -q

Documentation

DocumentDescription
GEP v0 Protocol SpecificationCore protocol design
Operator RunbookDay-to-day operations guide
Dashboard RunbookDashboard setup & usage
GitHub GovernanceBranch protection & PR review
Release RunbookTagging, releases, rollback
LLM Provider SetupSecure API key configuration
First Real ProposalGenerating your first proposal
Upstream SyncMerge strategy for HKUDS/nanobot
First Live Run AuditAudit trail
ChangelogRelease history
Development LogDaily engineering notes

Repository

Websitegeneclaw.ai
OriginClawland-AI/Geneclaw
UpstreamHKUDS/nanobot
OrganizationClawland-AI

License

MIT โ€” see LICENSE.

Built by Clawland-AI ยท Powered by HKUDS/nanobot ยท geneclaw.ai

Collected info

  • โ˜… 40 stars
  • โއ 8 forks
  • Language: Python
  • Source updated: 7/10/2026