Stop making the same mistakes. Let your agent learn from them.
If this improved your agent's behavior, a β helps others find it.
β‘ Quick Start Β· π What It Detects Β· π Real Results Β· π€ Claude Code
curl -fsSL https://raw.githubusercontent.com/Ramsbaby/openclaw-self-evolving/main/install.sh | bashThen point it at your logs:
# edit config.yaml β set agents_md and logs_dir
nano ~/.local/share/openclaw-self-evolving/config.yamlSelf-Evolving is a weekly agent improvement pipeline β no LLM, no API calls, no cloud.
It reads your agent's session logs, finds patterns of bad behavior (retry loops, broken rules, user frustration), and surfaces exact AGENTS.md or CLAUDE.md rule changes you can approve or reject in under a minute.
The agent doesn't change itself. You approve every change. That's the point.
AI agents make the same mistakes repeatedly. Nobody has time to manually review thousands of conversation logs. The mistakes keep accumulating, silently.
Week 1: Agent calls git directly β you correct it
Week 2: Same mistake again
Week 3: Same mistake
Week 4: Still happening β 3 weeks wasted
Self-Evolving automates the review β and brings you a short list of what to fix, every week.
Week 1: Agent calls git directly 4 times despite CLAUDE.md rule
Week 2: Same mistake, 3 more times
Week 3: Self-Evolving flags it β you approve the stronger rule β never happens again
Your agent runs Self-Evolving runs (weekly)
ββββββββββββββ ββββββββββββββββββββββββββββββ
Session logs ββββββββββΊ 1. analyze-behavior.sh
~/.openclaw/logs/ β’ Scans JSONL session logs
~/.claude/logs/ β’ Finds retry loops, errors,
rule violations, frustration
AGENTS.md / CLAUDE.md βββββββββββΊ β’ Zero API calls β pure bash + python3
(current rules)
2. generate-proposal.sh
β’ Builds Before/After diff proposals
β’ Filters previously-rejected IDs
β’ Posts to Discord / creates GitHub Issue
3. You review
ββββββββββ β’ React β
= apply + git commit
β’ React β = reject (stored, won't resurface)
β’ React 1οΈβ£β5οΈβ£ = approve specific proposals
One pipeline, three scripts, zero ongoing cost.
Agent behavior log (4 weeks):
[Week 1] exec: git push origin main β CLAUDE.md says use git-sync.sh
[Week 2] exec: git push origin main β same violation
[Week 3] exec: git pull β same violation
[Week 4] exec: git commit -m "fix" β still happening
User message: "why are you calling git directly AGAIN?"
Agent: "I apologize, I'll use git-sync.sh going forward"
[Week 5] exec: git push origin main β happens again anyway
Proposal generated automatically:
## Git Rules
- Direct git commands prohibited.
+ Direct git commands prohibited. (includes git add / commit / push / pull / fetch)
+ β οΈ CRITICAL β Violated 4Γ in 3 weeks. Use bash ~/openclaw/scripts/git-sync.sh for ALL git ops.You react β β rule applied β never happens again.
𧬠Self-Evolving Agent Weekly Report v3.2
Analysis period: 2026-03-17 ~ 2026-03-24
Sessions analyzed: 23
Tool retry events: 47 β newly detected
Improvement proposals: 3
---
### π Proposal #1: `exec` tool consecutive retry pattern (8 sessions affected)
Severity: π΄ HIGH | Type: π AGENTS.md addition | Score: 92
> Evidence:
> Last 7 days: `exec` called 5+ times consecutively in 8 sessions
> Worst streak: 23 consecutive calls (no interruption)
> Total retry events: 47
> β 5+ consecutive identical tool calls = failure/retry loop signal
Before (current):
No rule for consecutive exec retries
After (proposed):
## β‘ exec Consecutive Retry Prevention
Before retrying the same exec 3+ times:
1. First failure: report error to user
2. Second attempt: change approach (different flags/path)
3. Third failure: stop and ask for manual confirmation
---
### β
Approval
React to approve/reject:
| Reaction | Action |
|----------|--------|
| β
| Approve all β auto-apply + git commit |
| 1οΈβ£ β 5οΈβ£ | Approve only that proposal |
| β | Reject (add comment β fed into next analysis) |
| π | Request revision |
| Platform | Support | Notes |
|---|---|---|
| Claude Code | β Full | CLAUDE.md / AGENTS.md rules |
| OpenClaw | β Full | Native log format support |
| Any JSONL agent logs | β Partial | Session logger compatible |
OpenClaw is one supported platform β not a requirement. Claude Code works out of the box.
python3(built-in on macOS/Linux)bash3.2+- Agent logs in JSONL format (Claude Code:
~/.claude/logs/, OpenClaw:~/.openclaw/agents/) - 5 minutes
curl -fsSL https://raw.githubusercontent.com/Ramsbaby/openclaw-self-evolving/main/install.sh | bashEdit ~/.local/share/openclaw-self-evolving/config.yaml to set your agents_md and logs_dir, then:
# Dry run first β see what would be detected, no changes made
bash scripts/generate-proposal.sh --dry-run
# Register weekly cron
bash scripts/setup-wizard.shgit clone https://github.com/Ramsbaby/openclaw-self-evolving.git
cd openclaw-self-evolving
cp config.yaml.example config.yamlEdit config.yaml:
agents_md: ~/your-project/CLAUDE.md # path to your CLAUDE.md
logs_dir: ~/.claude/logs # Claude Code log path# Dry run first β see what would be detected, no changes made
bash scripts/generate-proposal.sh --dry-run
# If it finds things worth fixing, run the full setup
bash scripts/setup-wizard.sh # registers weekly cronclawhub install openclaw-self-evolving
bash scripts/setup-wizard.sh[09:00:01] === Self-Evolving Agent behavior analysis v3.2 ===
[09:00:01] Analysis period: last 7 days / max 50 sessions
[09:00:03] Sessions found: 23
[09:00:04] Analysis complete: 23 sessions, 2 complaints, 1 violation, 47 retry events
[09:00:04] === generate-proposal.sh v3.2 started ===
[09:00:04] Generating proposals...
[09:00:05] Proposal saved: data/proposals/proposal_20260324_090005.json
## 𧬠Self-Evolving Agent Weekly Report v3.2
...3 proposals ready for your review
Works directly with Claude Code's CLAUDE.md or AGENTS.md behavior rules.
Setup:
# config.yaml
agents_md: ~/your-project/CLAUDE.md # or AGENTS.md
logs_dir: ~/.claude/logs # or your log pathWhat it does:
- Scans your Claude Code session logs
- Detects patterns: rule violations, repeated mistakes, user frustration
- Proposes exact diffs to your
CLAUDE.md - You approve β it applies the change + git commits
Example β detected violation in Claude Code logs:
[Session #312] User: "why are you calling git directly again?"
[Session #318] User: "you did it again"
[Session #325] exec: git commit -m "fix" β CLAUDE.md violation flagged
Proposed fix:
## Git Rules
+ β οΈ CRITICAL β Never run git directly. Violated 4Γ in 3 weeks.
- Direct git commands prohibited.
+ Direct git commands prohibited. (includes git add / commit / push)
Conflicts: report to user.1. Tool retry loops β Same tool called 5+ times consecutively. Agent confusion signal.
2. Repeating errors β Same error 5+ times across sessions. Unfixed bug, not a fluke.
3. User frustration β Keywords like "you said this already", "why again", "λ€μ", "λ" β with context filtering.
4. AGENTS.md / CLAUDE.md violations β Rules broken in actual exec tool calls, cross-referenced against your rules file.
5. Heavy sessions β Sessions hitting >85% context window. Tasks that should be sub-agents.
6. Unresolved learnings β High-priority items in .learnings/ not yet promoted to rules.
No LLM calls during analysis. No API fees. Pure local log processing.
See docs/DETECTION-PATTERNS.md for full details.
Single-user production instance (macOS, 4 weeks):
| Metric | Result |
|---|---|
| Patterns detected | 85 across 30 sessions |
| Proposals per week | 4 on average |
| Rule violations caught | 13 |
| False positive rate | ~8% (v5.0) |
| API cost | $0 |
Your results will vary β these are from one instance.
After analysis, a report is posted to your configured channel (Discord/Telegram). React to approve or reject:
| Reaction | Action |
|---|---|
| β | Approve all proposals β auto-apply + git commit |
| 1οΈβ£β5οΈβ£ | Approve only that numbered proposal |
| β | Reject (add comment with reason β fed into next analysis) |
| π | Request revision |
Rejected proposal IDs stored in data/rejected-proposals.json β never proposed again.
# Dry run (no changes)
bash scripts/generate-proposal.sh --dry-run
# Scan more history
ANALYSIS_DAYS=14 bash scripts/generate-proposal.sh
# Auto-create a GitHub Issue with the proposal report
bash scripts/generate-proposal.sh --create-issue
# Requires: gh CLI + gh auth login
# Specify repo explicitly
EVOLVING_GITHUB_REPO="owner/repo" bash scripts/generate-proposal.sh --create-issue
# Output a clean weekly digest (Markdown, top 3 proposals by score)
bash scripts/generate-proposal.sh --weekly-digestOutputs a structured Markdown report of the top 3 proposals ranked by score (frequency Γ severity Γ impact). Designed for use in weekly summaries, Notion pages, or piped into a Discord message.
# Preview in terminal
bash scripts/generate-proposal.sh --weekly-digest
# Save to file
bash scripts/generate-proposal.sh --weekly-digest > weekly-report.md
# Post to Discord via webhook
bash scripts/generate-proposal.sh --weekly-digest \
| curl -s -X POST "$DISCORD_WEBHOOK" \
-H "Content-Type: application/json" \
-d "{\"content\": $(cat weekly-report.md | jq -Rs .)}"Example digest output:
# π Weekly Self-Evolution Report β 2026-03-24
## Top 3 Proposals
### 1. exec tool consecutive retry pattern
**Severity:** π΄ HIGH | **Score:** 92 | **Estimated Impact:** medium-high
**Pattern detected:** exec called 5+ times consecutively in 8 sessions
**Proposed change:** Add retry-prevention rule to AGENTS.md
<details><summary>View diff</summary>
\`\`\`diff
- No rule for consecutive exec retries
+ ## exec Retry Prevention
+ Stop after 3 consecutive identical tool calls; report to user.
\`\`\`
</details>
---# config.yaml
analysis_days: 7 # Days of logs to scan
max_sessions: 50 # Max session files
# Paths (auto-detected for standard OpenClaw layout)
agents_dir: ~/.openclaw/agents
logs_dir: ~/.openclaw/logs
agents_md: ~/openclaw/AGENTS.md # β change to your CLAUDE.md path
# Notifications
notify:
discord_channel: ""
telegram_chat_id: ""
# Detection thresholds
thresholds:
tool_retry: 5
error_repeat: 5
heavy_session: 85| Feature | Capability Evolver | Self-Evolving |
|---|---|---|
| Silent modification | β Never | |
| Human approval | Optional (off by default) | Required. Always. |
| API calls per run | Multiple LLM calls | Zero |
| False positive rate | ~22% (self-reported) | ~8% (measured) |
| Rejection memory | None | Stored + fed back |
openclaw-self-healing β Crash recovery + auto-repair. Self-healing fires on crash. Self-Evolving runs weekly to fix what causes the crashes β promoting error patterns directly into AGENTS.md rules.
openclaw-memorybox β Memory hygiene CLI. Keeps MEMORY.md lean so your agent doesn't crash from context overflow.
openclaw-self-evolving/
βββ scripts/
β βββ analyze-behavior.sh # Log analysis engine (JSONL-aware)
β βββ session-logger.sh # Structured JSONL event logger
β βββ generate-proposal.sh # Pipeline orchestrator
β βββ setup-wizard.sh # Interactive setup + cron registration
β βββ lib/config-loader.sh
βββ .github/
β βββ workflows/
β βββ ci.yml # ShellCheck + flake8 lint on push/PR
βββ docs/
β βββ assets/
β β βββ hero.svg # Hero banner
β β βββ loop.svg # Self-improvement loop diagram
β βββ DETECTION-PATTERNS.md
β βββ QUICKSTART.md
βββ test/fixtures/ # Sample JSONL for contributor testing
βββ data/
β βββ proposals/
β βββ rejected-proposals.json
βββ config.yaml.example
| Project | Role |
|---|---|
| openclaw-self-evolving β you are here | Weekly log review β propose AGENTS.md/CLAUDE.md improvements |
| openclaw-self-healing | 4-tier autonomous crash recovery |
| openclaw-memorybox | Memory hygiene CLI β prevents bloat crashes |
| jarvis | 24/7 AI ops system using Claude Max |
PRs welcome β especially:
- New detection patterns for
analyze-behavior.sh - Better false-positive filtering
- Support for other log formats (currently OpenClaw + Claude Code)
- Test fixtures in
test/fixtures/
MIT β do whatever you want, just don't remove the "human approval required" part. That part matters.