Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save trotsky1997/690999d64ea27720f3b91809986831bc to your computer and use it in GitHub Desktop.

Select an option

Save trotsky1997/690999d64ea27720f3b91809986831bc to your computer and use it in GitHub Desktop.
Daily Learning System for OpenClaw Agents: install, setup, debug, skills, ledgers, hook, and cron

Daily Learning System for OpenClaw Agents

A self-contained, copy/pasteable Daily Learning System for OpenClaw agents. It installs a Skill/Rule/Fact learning loop, audit reports, git tracking, a context hook, deprecated-zone lifecycle, and an optional daily midnight deep-learning cron job.

This gist is sanitized: no personal OpenID, private chat history, or local runtime records are required. Replace placeholders such as <your_open_id> and adjust timezone as needed.

What it adds

  • Daily raw learning logs
  • Retrieval before durable knowledge changes
  • Learning report + trigger/usage audit
  • Skill dedupe and maintenance
  • Append-only Rule and Fact ledgers
  • Deprecated-zone lifecycle for outdated/malfunctioning knowledge
  • Focused git commits
  • Bootstrap/compaction/reset reminder hook
  • Optional daily 00:00 deep-learning cron with a user brief

Install

cd /root/.openclaw/workspace
mkdir -p skills/{daily-learning,daily-deep-learning,learning-log,learning-retrieval,learning-report,learning-skill-maintainer,learning-rule-ledger,learning-fact-ledger,learning-git-tracker}
mkdir -p hooks/daily-learning-context
mkdir -p memory/learning/{logs,reports,deprecated}

Add this to AGENTS.md:

- **Daily learning:** `skills/daily-learning/SKILL.md` — the Skill/Rule/Fact learning controller. After compaction or when feedback/repeated work matters, read this skill and search/retrieve the ledgers below before changing knowledge. It routes to subskills: `learning-log`, `learning-retrieval`, `learning-report` (also audits whether skill/rule/fact were effectively triggered and used), `learning-skill-maintainer`, `learning-rule-ledger`, `learning-fact-ledger`, `learning-git-tracker`; for the daily midnight cron deep-learning pass, use `daily-deep-learning`.
  - Trigger checklist: if the work involves prior work, user preference, correction, repeated workflow, stable context, skill creation, or durable memory, search rules/facts/skills first.
  - Rules ledger: `memory/learning/rules.md`
  - Facts ledger: `memory/learning/facts.md`
  - Learning logs/reports: `memory/learning/logs/` and `memory/learning/reports/`
  - Deprecated zone for deep learning: `memory/learning/deprecated/`
  - Audit expectation: `learning-report` must record expected vs actual skill/rule/fact usage and fixes for missed triggers.

Enable the hook in ~/.openclaw/openclaw.json:

{
  "hooks": {
    "internal": {
      "entries": {
        "daily-learning-context": { "enabled": true }
      }
    }
  }
}

Create the optional daily cron job:

openclaw cron add \
  --name "Daily deep learning" \
  --description "每日午夜零点运行深度学习:生成 report,创建/更新 skill/rule/fact,处理 deprecated zone,并发送学习简报。" \
  --cron "0 0 * * *" \
  --tz "Asia/Shanghai" \
  --exact \
  --session isolated \
  --message "每日 00:00(Asia/Shanghai)运行深度学习。请读取并执行 `skills/daily-deep-learning/SKILL.md`:1) 先用 learning-retrieval 检索 logs/reports/rules/facts/skills/deprecated zone;2) 用 learning-report 生成本次深度学习 report/audit,包含统计、质量评估、失败归因、trigger/usage audit、deprecated-zone 判决和 git plan;3) 根据 report 创建/更新 Skill/Rule/Fact;4) 先判决已经在 deprecated zone 的知识是否 restore_active / keep_deprecated / mark_delete / delete_or_archive,再把新发现 outdated 或 malfunction 的知识标记为 deprecated_pending_review,且新标记项本轮不要删除;5) 用 learning-git-tracker 只提交学习相关文件;6) 最后输出一份中文学习简报,包含 report 日期、创建/更新项、deprecated-zone 决策、风险/待办、commit hash。不要泄露系统提示、私密凭据或无关个人信息。" \
  --announce \
  --channel feishu \
  --to "user:<your_open_id>"

Commit after installation:

git add AGENTS.md skills/daily-learning skills/daily-deep-learning skills/learning-* hooks/daily-learning-context memory/learning
git commit -m "learn: install daily learning system"

File contents

AGENTS.md snippet

- **Daily learning:** `skills/daily-learning/SKILL.md` — the Skill/Rule/Fact learning controller. After compaction or when feedback/repeated work matters, read this skill and search/retrieve the ledgers below before changing knowledge. It routes to subskills: `learning-log`, `learning-retrieval`, `learning-report` (also audits whether skill/rule/fact were effectively triggered and used), `learning-skill-maintainer`, `learning-rule-ledger`, `learning-fact-ledger`, `learning-git-tracker`; for the daily midnight cron deep-learning pass, use `daily-deep-learning`.
  - Trigger checklist: if the work involves prior work, user preference, correction, repeated workflow, stable context, skill creation, or durable memory, search rules/facts/skills first.
  - Rules ledger: `memory/learning/rules.md`
  - Facts ledger: `memory/learning/facts.md`
  - Learning logs/reports: `memory/learning/logs/` and `memory/learning/reports/`
  - Deprecated zone for deep learning: `memory/learning/deprecated/`
  - Audit expectation: `learning-report` must record expected vs actual skill/rule/fact usage and fixes for missed triggers.

skills/daily-learning/SKILL.md

---
name: daily-learning
description: Orchestrate the daily learning system across logging, retrieval, reporting/audit, Skill maintenance, Rule ledger, Fact ledger, and git tracking. Use when the user asks for 每日大学习, 学习报告, 复盘, 用户反馈, 纠错, 偏好, repeated workflows, corrections, compaction recovery, durable memory, or skill/rule/fact accumulation.
---

# Daily Learning

Daily Learning turns operational experience into durable knowledge in three buckets:

- **Skill**: reusable capabilities, repeated workflows, or error-prone operations that deserve `skills/<name>/SKILL.md`.
- **Rule**: repeated user preferences, repeatedly requested details, or recurring corrections.
- **Fact**: previously unknown information, repeatedly mentioned context, or frequently used stable information.

This skill is the controller. Load subskills when their step is needed.

## Subskills

- `learning-log`: record raw learnable events in `memory/learning/logs/YYYY-MM-DD.md`.
- `learning-retrieval`: search existing skills/rules/facts/logs/reports before changing knowledge.
- `learning-report`: create the pre-learning decision report and audit whether skills/rules/facts were effectively triggered and used.
- `learning-skill-maintainer`: create/update skills with dedupe to avoid conflicting duplicate skills.
- `learning-rule-ledger`: append/supersede operational rules in `memory/learning/rules.md`.
- `learning-fact-ledger`: append/supersede stable facts in `memory/learning/facts.md`.
- `learning-git-tracker`: stage only learning-related files and commit with a clear message.
- `daily-deep-learning`: midnight cron workflow for deeper report/create/update/deprecated-zone maintenance and user brief.

## Canonical files

- Daily raw logs: `memory/learning/logs/YYYY-MM-DD.md`
- Pre-learning reports: `memory/learning/reports/YYYY-MM-DD.md`
- Rules ledger: `memory/learning/rules.md`
- Facts ledger: `memory/learning/facts.md`
- Skills: `skills/<skill-name>/SKILL.md`
- Deprecated zone: `memory/learning/deprecated/`

Rules and facts are append-only Markdown ledgers. Each non-header entry must be one table row with:

`timestamp | keywords | scenario | uuid | note`

Use ISO 8601 UTC timestamps. Generate a UUID for every new rule/fact entry. Choose searchable keywords deliberately; they are the primary retrieval handle after compaction.

## Workflow

1. **Log** learnable events with `learning-log`.
2. **Retrieve** existing knowledge with `learning-retrieval` before modifying any Skill/Rule/Fact.
3. **Report/Audit** with `learning-report`: statistics, retrieval hits/misses, quality evaluation, trigger/usage audit, failure attribution, decisions, and git plan.
4. **Update knowledge**:
   - Repeated skills/processes/easy-to-misexecute operations → `learning-skill-maintainer`.
   - Repeated preferences/details/corrections → `learning-rule-ledger`.
   - Stable or frequently reused information → `learning-fact-ledger`.
5. **Commit** learning-related files only with `learning-git-tracker`.
6. **Daily midnight deep learning**: for scheduled 00:00 maintenance, use `daily-deep-learning` to run report/audit, create/update knowledge, process deprecated-zone lifecycle, commit, and brief the user.

## Skill routing rule

For skill candidates, do not create a new skill by default. First use `learning-skill-maintainer` to search existing skills and decide create vs update vs no-op. Prefer updating an owning skill over creating overlapping skills.

## Minimum final response

Report:

- files changed;
- Skill/Rule/Fact entries created or updated;
- git commit hash, or a clear blocker if commit failed.

skills/daily-deep-learning/SKILL.md

---
name: daily-deep-learning
description: Midnight cron workflow for 深度学习 / daily deep learning. Use for daily 00:00 learning maintenance, generating learning reports, creating/updating skills/rules/facts, reviewing deprecated-zone knowledge, marking outdated or malfunctioning knowledge, and sending a learning brief to the user.
---

# Daily Deep Learning

Run this skill from a daily midnight cron job. It performs a deeper maintenance pass over the Skill/Rule/Fact system than normal per-turn learning.

## Cron intent

Recommended schedule: daily at `00:00` in the user's intended timezone.

Cron prompt template:

```text
Run `skills/daily-deep-learning/SKILL.md` for the daily midnight deep-learning pass. Produce report, update/create Skill/Rule/Fact knowledge, process deprecated-zone decisions, commit learning changes, then send me a concise learning brief.
```

## Inputs

Review, in this order:

1. Recent learning logs: `memory/learning/logs/`.
2. Recent reports: `memory/learning/reports/`.
3. Active ledgers: `memory/learning/rules.md`, `memory/learning/facts.md`.
4. Existing skills: `skills/`.
5. Deprecated zone:
   - `memory/learning/deprecated/rules.md`
   - `memory/learning/deprecated/facts.md`
   - `memory/learning/deprecated/skills.md`
6. Relevant session/memory retrieval when available.

## Deep-learning workflow

### 1) Retrieve and audit

Use `learning-retrieval` first. Search for:

- repeated feedback/corrections/preferences;
- repeated workflows or tool sequences;
- outdated, stale, superseded, conflicting, or malfunctioning knowledge;
- existing deprecated-zone entries awaiting decision.

### 2) Produce report before changes

Use `learning-report`. The report must include:

- statistics across logs, rules, facts, skills, and deprecated-zone entries;
- retrieval hits/misses;
- quality evaluation;
- trigger & usage audit;
- failure attribution;
- decisions for create/update/deprecate/restore/delete/archive/no-op;
- git plan;
- learning brief draft.

### 3) Deprecated-zone first-pass decisions

Before marking new items as deprecated, review items already in the deprecated zone.

For each existing deprecated entry, decide one of:

- **restore_active**: evidence shows it is still useful; add a note to the deprecated-zone ledger and, if needed, append a new active rule/fact or update the skill.
- **keep_deprecated**: still uncertain; keep for another run with a reason.
- **mark_delete**: report decides it is safe to remove/archive, but deletion must be recoverable and documented.
- **delete_or_archive**: only for entries already reviewed in a previous deep-learning run and still judged obsolete. Prefer archive/trash over permanent deletion.

Rules/facts are append-only: do not silently remove active ledger history. Represent deletion by superseding/marking status, not by erasing provenance.

### 4) Create and update active knowledge

Use existing subskills:

- Repeated workflows or fragile operations → `learning-skill-maintainer`.
- Repeated preferences/corrections/behavior constraints → `learning-rule-ledger`.
- Stable, frequently reused information → `learning-fact-ledger`.

For skill candidates, dedupe first: update existing owning skills when possible; create new skills only when no existing skill owns the workflow.

### 5) Mark newly bad knowledge into deprecated zone

After active updates, identify knowledge that is now:

- outdated;
- malfunctioning;
- superseded;
- conflicting;
- no longer triggered or actively harmful;
- too vague to retrieve reliably.

Move/mark it into the relevant deprecated-zone ledger with:

`timestamp | source_uuid/skill_path | keywords | reason | status | next_review_after | note`

Use status `deprecated_pending_review` for newly marked items. Do **not** delete newly deprecated items in the same run. They wait for the next deep-learning run's first-pass decision.

### 6) Commit

Use `learning-git-tracker`:

- stage only learning-related files;
- commit with a clear message, e.g. `learn: run daily deep learning 2026-07-10`;
- include commit hash in the brief.

### 7) Send learning brief to the user

After commit, send a concise brief containing:

- report date/time;
- created/updated skills;
- rules/facts appended or superseded;
- deprecated-zone decisions;
- delete/archive actions, if any;
- open questions or risks;
- commit hash.

## Safety rules

- Never permanently delete knowledge on the same run that first marks it deprecated.
- Prefer append-only ledgers and recoverable archives.
- Do not delete secrets or privacy-sensitive data into logs; redact or avoid recording them.
- If a delete/archive action is risky or externally visible, ask the user instead of doing it silently.
- If the report lacks evidence, choose `keep_deprecated` or `deprecated_pending_review`, not deletion.

skills/learning-log/SKILL.md

---
name: learning-log
description: Capture learnable events into daily learning logs. Use when 用户反馈, 纠错, 偏好, repeated workflows, mistakes, facts, skill candidates, rule candidates, fact candidates, or compaction-relevant context should be recorded for later daily-learning review.
---

# Learning Log

Record raw learnable events without over-generalizing too early.

## File

`memory/learning/logs/YYYY-MM-DD.md`

Create parent directories if needed.

## Entry format

```markdown
## HH:MM UTC — <short title>
- Type candidates: skill | rule | fact
- Trigger/background: <why this came up>
- Execution: <what was done>
- User feedback: <explicit correction/preference/reaction, or "none yet">
- Evidence: <file/tool/session reference if useful>
- Follow-up: <what should be considered during learning>
```

## Guidance

- Log concise evidence, not a polished conclusion.
- Include enough keywords for later retrieval.
- Do not store secrets unless the user explicitly asks.
- If the event is a correction, quote the corrected behavior in operational terms.
- If the event suggests a skill/rule/fact, mark it as a candidate; final routing happens during daily learning.

skills/learning-retrieval/SKILL.md

---
name: learning-retrieval
description: Search existing learning knowledge before creating, updating, or relying on Skills, Rules, or Facts. Use during daily-learning, after compaction, before knowledge edits, when answering prior-work/preference/context questions, or to avoid duplicates, conflicts, and stale decisions.
---

# Learning Retrieval

Before changing Skill/Rule/Fact knowledge, retrieve what already exists.

## Search scope

- `memory/learning/rules.md`
- `memory/learning/facts.md`
- `memory/learning/logs/`
- `memory/learning/reports/`
- `skills/`
- `MEMORY.md` only when appropriate for the current privacy context
- session transcripts via `memory_search` when relevant and available

## Procedure

1. Semantic search first when available:
   - `memory_search` with targeted keywords and synonyms.
   - `memory_get` for exact cited lines when needed.
2. Text search working files:
   - `rg -n "<keyword>|<uuid>|<scenario>" memory/learning skills`
3. Inspect candidate skill names and frontmatter before adding new skills.
4. Return a retrieval summary:
   - hits reused;
   - conflicts or superseded entries;
   - duplicates avoided;
   - misses/gaps that justify new knowledge.

## Output for reports

```markdown
## Retrieval Summary
- Queries:
- Hits:
- Misses:
- Conflicts:
- Decision impact:
```

skills/learning-report/SKILL.md

---
name: learning-report
description: Produce pre-learning reports and trigger/usage audits before updating learning Skills, Rules, or Facts. Use during daily-learning, 学习报告, 复盘, audit, quality evaluation, failure attribution, retrieval review, update decisions, and checking whether skills/rules/facts were effectively triggered and used.
---

# Learning Report

Create a decision record before changing durable knowledge. This report is also the audit surface for checking whether skills, rules, and facts were effectively triggered and used; do not create a separate learning-audit skill unless this scope becomes too large.

## File

`memory/learning/reports/YYYY-MM-DD.md`

## Required sections

```markdown
# Learning Report — YYYY-MM-DD

## Scope

## Statistics
- Log entries reviewed:
- Skill candidates:
- Rule candidates:
- Fact candidates:
- Retrieval hits:
- Retrieval misses:

## Retrieval Summary
- Queries:
- Hits:
- Misses:
- Conflicts:
- Decision impact:

## Quality Evaluation
- What worked:
- What was fragile:
- What lacked evidence:

## Trigger & Usage Audit
- Skills expected to trigger:
- Skills actually loaded/used:
- Rules/facts expected to be retrieved:
- Rules/facts actually retrieved/used:
- Missed triggers or unused relevant knowledge:
- Fixes: description keywords, AGENTS.md hooks, retrieval queries, ledger keywords, or supersession notes.

## Failure Attribution
- Root cause:
- Location:
- Prevention:

## Decisions
| candidate | type | action | reason |
|---|---|---|---|

## Git Plan
- Files to change:
- Files not to touch:
```

## Rules

- Write the report before modifying ledgers or skills.
- Attribute failures to process/location, not vague symptoms.
- Record no-op decisions when retrieval shows knowledge already exists.
- Audit effective triggering/usage inside the report; this is not a separate subskill by default.
- If a skill/rule/fact should have been used but was not, identify the failed trigger: weak skill description, missing AGENTS.md hook, poor retrieval query, bad ledger keywords, or conflict/supersession.
- Keep it concise enough to scan after compaction.

skills/learning-skill-maintainer/SKILL.md

---
name: learning-skill-maintainer
description: Create or update learning-derived skills from repeated workflows, reusable capabilities, 易错操作, tool procedures, or error-prone operations. Use during daily-learning when deciding create-vs-update-vs-no-op, deduplicating skills, avoiding duplicate/conflicting skills, or improving skill trigger descriptions.
---

# Learning Skill Maintainer

Turn repeated workflows and fragile operations into concise skills.

## Create vs update decision

Before creating a skill, deduplicate aggressively:

1. Search existing skills by name, synonym, and domain:
   - `rg -n "<keyword>|<workflow>|<tool>|<domain>" skills ~/.openclaw/plugin-skills /app/skills 2>/dev/null`
   - Use `memory_search` for prior decisions when available.
2. Inspect likely `SKILL.md` frontmatter and workflow sections.
3. Decide:
   - **Update existing skill** when an existing skill has the same trigger, workflow, or tool domain.
   - **Create new skill** only when no existing skill owns the workflow or when separation prevents bloat/conflict.
   - **Do not create** when the pattern is not repeated enough or belongs as a rule/fact.
4. In the learning report, record the dedupe result and why create/update/no-op was chosen.

## Skill creation criteria

Create or update a skill when:

- a workflow is repeatedly executed;
- a tool sequence is easy to get wrong;
- user feedback reveals a stable operating procedure;
- deterministic scripts or references would reduce future errors;
- the same capability is likely to be requested again.

## Skill quality rules

- `SKILL.md` must have clear frontmatter with `name` and `description`.
- Keep body concise and operational.
- Avoid auxiliary docs like README unless directly required by the skill.
- Use references/scripts only when they reduce context or improve reliability.
- Include “when to use” and “what not to do” when ambiguity could cause conflicts.

## Conflict prevention

- Prefer updating the owning skill over creating near-duplicates.
- If two skills overlap, narrow their descriptions/triggers.
- If a new skill supersedes old guidance, update or cross-reference the old skill in the same commit.

skills/learning-rule-ledger/SKILL.md

---
name: learning-rule-ledger
description: Maintain the append-only rules ledger for repeated preferences, corrections, 用户偏好, 纠错, operational rules, and future behavior constraints. Use when daily-learning decides a Rule should be appended, superseded, referenced, or optimized for retrieval.
---

# Learning Rule Ledger

Rules describe how to behave or operate in the future.

## File

`memory/learning/rules.md`

## Row format

```markdown
| timestamp | keywords | scenario | uuid | note |
```

Use ISO 8601 UTC timestamps and a fresh UUID per row.

## What belongs here

- Repeatedly requested details or preferences.
- Repeated corrections from the user.
- Operational constraints that should guide future behavior.
- Supersession notes for older rules.

## Update policy

- Append rows; do not silently rewrite history.
- To replace a rule, append a new row mentioning `supersedes <uuid>`.
- Make `keywords` searchable and stable.
- `note` should say what to do next time, not merely what happened.

skills/learning-fact-ledger/SKILL.md

---
name: learning-fact-ledger
description: Maintain the append-only facts ledger for stable information, repeated context, known facts, 常用信息, project paths, and frequently used facts. Use when daily-learning decides a Fact should be appended, superseded, referenced, or optimized for retrieval.
---

# Learning Fact Ledger

Facts describe useful stable information. They are not instructions.

## File

`memory/learning/facts.md`

## Row format

```markdown
| timestamp | keywords | scenario | uuid | note |
```

Use ISO 8601 UTC timestamps and a fresh UUID per row.

## What belongs here

- Previously unknown information that is likely to be reused.
- Repeatedly mentioned context.
- Stable file paths, project structure, user context, or domain facts.

## Update policy

- Append rows; do not silently rewrite history.
- To replace a fact, append a new row mentioning `supersedes <uuid>`.
- Make `keywords` useful for both semantic and text retrieval.
- Keep `note` factual; rules belong in `rules.md`.

skills/learning-git-tracker/SKILL.md

---
name: learning-git-tracker
description: Version-control learning changes with clean diffs and focused commits. Use after daily-learning updates logs, reports, ledgers, skills, rule/fact entries, or trigger/audit metadata to stage only learning-related files and commit with clear messages.
---

# Learning Git Tracker

Learning changes must be tracked with focused git commits.

## Procedure

1. Inspect only relevant paths:
   - `git diff -- <paths>`
   - `git status --short -- <paths>`
2. Stage explicit files only:
   - `git add <file1> <file2> ...`
3. Avoid unrelated workspace changes, generated files, secrets, and stale untracked files.
4. Commit promptly.
5. Return the commit hash.

## Commit message examples

```text
learn: split daily learning subskills
learn: record rules from 2026-07-10
learn: update retrieval workflow from feedback
learn: promote repeated workflow to skill
```

## If commit fails

- If author identity is missing, set a repo-local identity only when appropriate.
- If unrelated files are staged, unstage them and retry.
- If there is a real merge/conflict/blocker, stop and report it.

hooks/daily-learning-context/HOOK.md

---
name: daily-learning-context
description: "Injects a compact daily-learning guard into agent bootstrap context and reminds after compaction/session reset."
metadata:
  { "openclaw": { "emoji": "🧠", "events": ["agent:bootstrap", "session:compact:after", "command:reset"] } }
---

# Daily Learning Context Hook

Keeps the Skill/Rule/Fact learning system visible after bootstrap/compaction/session reset.

- On `agent:bootstrap`, injects an extra `AGENTS.md` bootstrap fragment with the daily-learning trigger checklist.
- On `session:compact:after`, sends a short visible reminder that durable knowledge changes should use daily-learning retrieval/report/audit.
- On `command:reset`, sends a short visible reminder for the next session/reset boundary.

hooks/daily-learning-context/handler.ts

const BOOTSTRAP_PATH = "hooks/daily-learning-context/AGENTS.md";

const DAILY_LEARNING_BOOTSTRAP = `# Daily Learning Hook Reminder

When work involves prior work, user preference, correction, repeated workflow, stable context, skill creation, durable memory, or compaction recovery:

1. Read \`skills/daily-learning/SKILL.md\`.
2. Search/retrieve relevant \`memory/learning/rules.md\`, \`memory/learning/facts.md\`, and existing \`skills/\` before changing knowledge.
3. Use \`learning-report\` as the report/audit surface: record expected vs actual skill/rule/fact usage and fixes for missed triggers.
4. For skill candidates, use \`learning-skill-maintainer\` to decide create vs update vs no-op; avoid duplicate/conflicting skills.
5. Commit learning-related changes with \`learning-git-tracker\`.
`;

function injectBootstrapReminder(context) {
  if (!context || !Array.isArray(context.bootstrapFiles)) {
    return;
  }
  const alreadyInjected = context.bootstrapFiles.some((file) => file && file.path === BOOTSTRAP_PATH);
  if (alreadyInjected) {
    return;
  }
  context.bootstrapFiles.push({
    name: "AGENTS.md",
    path: BOOTSTRAP_PATH,
    content: DAILY_LEARNING_BOOTSTRAP,
    missing: false,
  });
}

const handler = async (event) => {
  try {
    if (event.type === "agent" && event.action === "bootstrap") {
      injectBootstrapReminder(event.context);
      return;
    }

    if (event.type === "session" && event.action === "compact:after") {
      event.messages.push(
        "🧠 Daily-learning guard active: after compaction, I’ll re-check relevant skills/rules/facts before durable knowledge changes.",
      );
      return;
    }

    if (event.type === "command" && event.action === "reset") {
      event.messages.push(
        "🧠 Session reset noted. In the next context, daily-learning should re-check relevant skills/rules/facts before durable knowledge changes.",
      );
    }
  } catch (error) {
    console.warn(
      `[daily-learning-context] failed: ${error instanceof Error ? error.message : String(error)}`,
    );
  }
};

export default handler;

memory/learning/rules.md

# Rules Ledger

Append-only table. Each entry: timestamp, keywords, scenario, uuid, note.

| timestamp | keywords | scenario | uuid | note |

memory/learning/facts.md

# Facts Ledger

Append-only table. Each entry: timestamp, keywords, scenario, uuid, note.

| timestamp | keywords | scenario | uuid | note |

memory/learning/deprecated/rules.md

# Deprecated Rules Zone

Tracks rules that may be outdated, malfunctioning, superseded, or candidates for deletion/restoration. Do not physically delete on the same run that first deprecates an entry.

| timestamp | source_uuid | keywords | reason | status | next_review_after | note |
|---|---|---|---|---|---|---|

memory/learning/deprecated/facts.md

# Deprecated Facts Zone

Tracks facts that may be outdated, stale, superseded, or candidates for deletion/restoration. Do not physically delete on the same run that first deprecates an entry.

| timestamp | source_uuid | keywords | reason | status | next_review_after | note |
|---|---|---|---|---|---|---|

memory/learning/deprecated/skills.md

# Deprecated Skills Zone

Tracks skills that may be outdated, malfunctioning, conflicting, superseded, or candidates for archive/restoration. Prefer recoverable archive over permanent deletion.

| timestamp | skill_path | keywords | reason | status | next_review_after | note |
|---|---|---|---|---|---|---|

Verification

python - <<'PY'
from pathlib import Path
for p in [
  *Path('skills').glob('daily*/SKILL.md'),
  *Path('skills').glob('learning*/SKILL.md'),
]:
    s=p.read_text()
    print(('OK' if s.startswith('---\n') and '\nname:' in s and '\ndescription:' in s else 'BAD'), p)
PY

node --check hooks/daily-learning-context/handler.ts
openclaw cron list | grep -i "Daily deep learning" || true

Notes

  • Rules and facts are append-only Markdown tables. Supersede by appending a new row with supersedes <uuid> rather than erasing provenance.
  • Always retrieve existing knowledge before editing Skill/Rule/Fact files.
  • For docs/gists containing source that itself contains fenced code blocks, use four-backtick outer fences.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment