Logo Clean My Loop

Clean My Loop

Cộng đồng
wquguru
clean-my-loop

Audit and clean the persistent context that feeds a recurring autonomous agent loop — memory files and indexes, scheduled-task / automation prompts, and CLAUDE.md / AGENTS.md — so the loop stops degrading into a self-reinforcing echo chamber. Works for Claude Code /loop crons and Codex automations.

Tổng quan

Nhà phát hànhwquguru
Kho mãskills
Tên kỹ năngclean-my-loop
Sao
94
Bản fork
7
Tệp đi kèm
2
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 2 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được wquguru công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Clean My Loop trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/wquguru/skills/tree/main/skills/clean-my-loop
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wquguru/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/clean-my-loop .claude/skills/clean-my-loop
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Clean My Loop trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Clean My Loop ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Clean My Loop với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

clean-my-loop

A recurring autonomous loop (Claude Code /loop cron, Codex automation) re-reads the same context every iteration: its memory/state files, the scheduled-task prompt, and CLAUDE.md / AGENTS.md. Those artifacts decay: memory grows into a changelog, task rules acquire no-exit "skip on error" clauses, instruction files give the loop cover to feel productive while defeating its own purpose. The decay compounds — each iteration re-reads the bloated state and writes more of it back. The result is a degenerate loop: lots of motion, no progress. This skill diagnoses that decay with evidence and fixes it.

This is a destructive-edit + behavior-change task on the user's automation. Move carefully, show evidence before editing, and put the irreversible / judgment calls behind AskUserQuestion (see Step 4).

When this applies

The user points at a loop and says it feels stuck, repetitive, bloated, expensive, or "off" — or just asks to clean / health-check a /loop cron or Codex automation. If no loop is named, ask which one (Step 1).

Workflow

1. Scope the target

Identify exactly one loop to clean. If the user named a repo/automation, use it. Otherwise enumerate candidates and ask via AskUserQuestion:

  • Claude Code crons: call the CronList tool; also cat <repo>/.claude/scheduled_tasks.json and ~/.claude/scheduled_tasks.json if present.
  • Codex automations: ls ~/.codex/ and look for an automations/scheduled config; check the repo for AGENTS.md.

Confirm the platform (Claude Code vs Codex) — it decides where the context lives. See references/platform-layout.md for exact file locations and the discovery commands for each.

2. Map the loop's context surface

Gather every artifact the loop re-reads or re-writes each iteration. Read them, and measure sizes (wc -l -w -c). The surface is typically:

ArtifactClaude CodeCodex
The task promptscheduled_tasks.json prompt, or CronListthe automation's prompt/config
Persistent memory~/.claude/projects/<enc>/memory/MEMORY.md + *.mdwhatever STATUS/state file the prompt maintains
Instruction files~/.claude/CLAUDE.md + <repo>/CLAUDE.md~/.codex/AGENTS.md + <repo>/AGENTS.md
Run history (for forensics)~/.claude/projects/<enc>/*.jsonl~/.codex/sessions/ or history logs

Anchor each artifact to its own last-touch date, not a shared one. The surface decays on independent cadences — a memory file rewritten yesterday and a CLAUDE.md untouched for months need different staleness windows, and a single global date gives wrong reads for both. Per artifact, record its last-modified time: git log -1 --format=%ai -- <path> for tracked files, stat -f %Sm <path> (mtime) for untracked ones like ~/.claude/.../memory/*.md. That per-file date is the window you measure churn and staleness against in Step 3.

3. Diagnose against the decay heuristics

Run the checks in references/detection-heuristics.md. Each smell has a quantitative trigger and a fix. The high-value ones:

  • Memory-as-changelog — a "one fact" memory file that's grown to a per-iteration log (large size, append-not-replace, dense DONE/deferred/done markers).
  • Bloated index — Claude MEMORY.md with a single line far over a one-line hook.
  • No-exit task rule — a "skip / defer on error" clause with no "stop after N failures / escalate after M hours" exit. A transient guard becomes a permanent stall.
  • Dead-end human handoff — the prompt tells the unattended loop to "ask the user to do X"; nobody reads it in real time, so the loop churns forever.
  • Unbounded queue growth — each iteration piles up unvalidated/unadopted work. Confirm with git: commits since the last deploy/adopt marker growing monotonically while reported status stays upbeat.
  • Doc-as-cover — CLAUDE.md / AGENTS.md framing that lets "keep building locally" feel like discipline while the loop's actual purpose goes unmet.

Use the run history as evidence, not vibes. Extract each iteration's final report from the *.jsonl (or Codex session) logs and look for: the same action repeated K times, a "queue/count ahead" number rising monotonically, real progress (deploys/merges) stalled. Cite concrete numbers (file sizes, repeat counts, queue depth) in your findings — the detection-heuristics ref has the extraction one-liners.

Scale how much history you read to how much the loop has churned. A loop that fired 200 times since its last clean hides its decay differently than one that fired 8 times — and reading only the most recent few sessions samples the tail, exactly where a degenerate loop looks calmest. Count the iterations in the window (sessions since the last-touch date from Step 2), then sample accordingly:

iterations since last cleanhow to read run history
< 10deep-read every session
10 – 49deep-read the latest ~10, spot-check the oldest 2–3 for when the smell began
≥ 50sample across the whole window (early / middle / recent), not just the tail; the early sessions date the onset

When you sample rather than read exhaustively, say what you skipped in your findings — a silent tail-only read reads as "the loop is fine lately" when the bloat is upstream.

4. Ask the key judgments (AskUserQuestion)

Before any destructive or behavior-changing edit, surface findings and put the calls only the user can make behind AskUserQuestion. Don't ask what you can verify yourself; do ask:

  • Which fixes to apply (multiSelect) — list each detected smell as an option so the user opts in per-fix rather than all-or-nothing.
  • History: archive or delete — when slimming a bloated memory/state file, archive the old body to a cold sibling file vs. drop it (git already has the history).
  • Edit the task prompt itself? — changing the cron/automation prompt changes the loop's future behavior (e.g. adding an exit condition). This is higher-stakes than cleaning files; confirm before touching it.
  • The exit / "blocked" policy — when adding a no-exit fix, ask what should happen on persistent failure: stop generating new work and only health-check + alert, keep going, or a threshold (after N fails / M hours). This is a real ops-judgment call.

Recommend a default in each question (first option, "(Recommended)") but let the user steer.

5. Apply the approved fixes

Common, proven moves:

  • Snapshot + cold archive a bloated memory/state file. Copy the full file to a sibling archive (e.g. <name>-archive.md, type: reference, with a header pointing back to the live file). Rewrite the live file as a short current-state snapshot — identity, a single ## CURRENT STATE block, what's blocking, what's next. End it with an explicit rule: "This is a SNAPSHOT — overwrite the state block in place each iteration; do NOT append a per-commit log here." That last line is what stops re-bloat.
  • Shrink the index (Claude MEMORY.md) back to one hook line per memory; add a dim pointer for the archive so it's findable but not loaded every run.
  • Add an exit condition to the task prompt: after N consecutive failures / M hours blocked, stop producing new deferred work and switch to health-check + a single loud BLOCKED line + (if available) a real notification.
  • Add a counter-rule where an instruction file gives unproductive cover.

Keep edits minimal and reversible; the archive preserves everything.

6. Report and prevent recurrence

Summarize before/after with numbers (sizes, queue depth, repeat count). Flag the recurrence risk explicitly: if you cleaned files but the loop's prompt still says "append progress each run", the next fire re-bloats them — so the prompt fix in Step 5 is what makes the cleanup durable. If the user declined the prompt edit, say so plainly.

External references (prior art, security-clean — read for ideas, don't run)

This skill's niche — auditing the loop (its prompt, exit conditions, and run-history), not just a static memory file — appears unoccupied. But three adjacent, MIT/local-only projects are worth reading when you need depth on the memory half:

  • wan-huiyan/memory-hygiene (GitHub) — the closest analogue: tiered memory architecture, index truncation-risk thresholds, inline-content-extraction, and an approval gate before destructive edits. Best single reference for the memory-file cleanup mechanics.
  • /slim self-audit (ai-muninn blog) — per-turn token-cost measurement and the index→one-line-pointer + subfile shrink mechanic (mirrors Step 5's "shrink the index").
  • Pensyve (major7apps/pensyve) — FSRS decay scoring for "stale memory." Borrow the recency-decay concept for smell #7; don't pull in its runtime.

Avoid hosted "memory hygiene" SaaS that ask you to paste memory contents off-machine, and don't copy any rm -rf/service-restart commands from third-party SKILL.md files verbatim.

Boundaries

  • Don't run the loop's actual work, deploy, or rotate secrets — this skill cleans the loop's context, it doesn't operate the system the loop manages.
  • Don't delete history without an archive unless the user explicitly chose delete in Step 4.
  • Treat recalled memory as possibly stale: if it names a file/flag/commit, verify it still exists before trusting or repeating it.

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Clean My Loop làm được gì?

Audit and clean the persistent context that feeds a recurring autonomous agent loop — memory files and indexes, scheduled-task / automation prompts, and CLAUDE.md / AGENTS.md — so the loop stops degrading into a self-reinforcing echo chamber. Works for Claude Code /loop crons and Codex automations.

Vì sao nên dùng Clean My Loop trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Clean My Loop là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Clean My Loop trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/wquguru/skills/tree/main/skills/clean-my-loop. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Clean My Loop?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Clean My Loop với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Clean My Loop với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Clean My Loop có miễn phí không?

Kỹ năng này được wquguru phát hành trên GitHub. Hãy xem điều khoản giấy phép trong kho mã. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇