loop-engineering
Skill1.3k starsChanged 4 months agoMITView on GitHub
Shared loop-engineering reference for COG skills - the agent loop, deterministic verifiers, termination conditions, in-loop context management, and named patterns. Invoke when designing or debugging a skill that iterates (search-verify-retry, scan-until-dry, fetch-retry-gate).
19 other projects use a version of this.
Trending
More talk lately.thin dataabout the whole repository
Most recently taken up by
- akitaonrails/my-skillstheir own version, first seen Sep 17, 2026
- j99way99/claude-skillstheir own version, first seen Sep 16, 2026
- Gaurav890/everything-agentic-engineeringtheir own version, first seen Sep 13, 2026
- Hakkadaikon/hymmetheir own version, first seen Sep 9, 2026
- jggomez/expert-ai-developer-skillstheir own version, first seen Sep 7, 2026
- vpeetla-ai/vpeetla-ai-skillstheir own version, first seen Aug 2, 2026
Who's talking about huytieu/COG-second-brain
- sudosubin/agents.nix“agent-plugins.github.huytieu.cog-second-brain: init at 3.15.0”GitHub · Oct 4, 2026
- sudosubin/agents.nix“agent-skills.github.huytieu.cog-second-brain: 3.10.0 → 3.15.0”GitHub · Oct 3, 2026
- sudosubin/agents.nix“agent-skills.github.huytieu.cog-second-brain: init at 3.10.0”GitHub · Sep 28, 2026
- frsvffcy/llm-wiki-km“[L3][Evaluation][Agent Workflow][Second Brain] 評估 COG closed-loop、self-evolution 與 multi-agent knowledge …”GitHub · Sep 18, 2026
The biggest 4 of 4 mentions linking to the repository that our crawl found. Each line is their own headline.
Used with
Projects with it also use agentic-engineering.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
InfopibeSkillagentic-engineering
Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing.
Also in 3 projects that use this
Other versions19 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 19
- telagod/code-abyss★ 242same name
- akitaonrails/my-skills★ 205same name
- Mark393295827/third-brain-v7-skills★ 141same name
- jggomez/expert-ai-developer-skills★ 28same name
- yoyothesheep/claude-skills★ 16same name
- sxivansx/loop-engineering★ 10same name
- haidrrrry/loop-engineering-skills★ 4same name
- Connected-Mate/fable-mindset★ 3same name
- parkavenue9639/loop-engineering★ 2same name
- vpeetla-ai/reflection-agent-pattern★ 2same name
9 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository109 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- auto-researchSkill
- braindumpSkill
- closed-loopSkill
- comprehensive-analysisSkill
- content-factorySkill
- create-user-storySkill
- daily-briefSkill
- daily-journalSkill
- data-formsSkill
- editorial-illustrationsSkill
- export-open-issuesSkill
- generate-prdSkill
- generate-release-notesSkill
- harvestSkill
- knowledge-consolidationSkill
- loop-engineeringSkill
- meeting-transcriptSkill
- memory-hygieneSkill
- museum-artSkill
- no-ai-slopSkill
- onboardingSkill
- product-ui-tasteSkill
- publish-to-confluenceSkill
- release-videoSkill
- retroSkill
- review-cockpitSkill
- scoutSkill
- slop-gateSkill
- taste-skillSkill
- team-briefSkill
- ultragoalSkill
- update-cogSkill
- update-knowledge-baseSkill
- url-dumpSkill
- voice-baselineSkill
- weekly-checkinSkill
- auto-researchSkill
- braindumpSkill
- closed-loopSkill
- comprehensive-analysisSkill
- content-factorySkill
- create-user-storySkill
- daily-briefSkill
- daily-journalSkill
- data-formsSkill
- editorial-illustrationsSkill
- export-open-issuesSkill
- generate-prdSkill
- generate-release-notesSkill
- harvestSkill
- knowledge-consolidationSkill
- meeting-transcriptSkill
- memory-hygieneSkill
- museum-artSkill
- no-ai-slopSkill
- onboardingSkill
- product-ui-tasteSkill
- publish-to-confluenceSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.
0
Common
Most of the 13 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 60
Externalize state to the vault: Write progress to the output file as you go.
“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
COG Loop Engineering
TL;DR: Some COG skills are not one-shot prompts. They are loops: act, observe, verify, decide whether to continue. This skill is the shared vocabulary those skills use. The iron rule: trust deterministic checks, never the agent's own "looks done" self-report. Every loop must declare its verifier, its stopping conditions, and which pattern it follows.
This is a reference and design aid, not a content-generating workflow. Skills that loop (daily-brief, knowledge-consolidation, url-dump, weekly-checkin, and research/triage skills like auto-research and scout) link here instead of restating the rules. Invoke it directly when you are building or fixing an iterative skill.
Why loops
A chain runs fixed steps: A then B then C. A loop is dynamic: the agent takes an action, reads real feedback (a fetched page, a date stamp, a file count), reasons about it, and repeats until a goal is met or a stop condition fires. Most knowledge-work that "keeps going until good enough" is a loop, and COG benefits from naming the loop explicitly rather than hoping a single prompt nails it.
The COG loop
┌──────────────────────────────────────────────┐
│ 1. Gather pull context (vault + sources) │
│ 2. Act one step: search / fetch / scan │
│ 3. Observe read the real result │
│ 4. Verify run the deterministic check │
│ 5. Update write progress to a vault file │
│ 6. Decide continue? → loop │
│ stop? → finish + report │
└──────────────────────────────────────────────┘Step 4 is the load-bearing one. A loop without a verifier is just a chain that repeats.
Termination conditions (use layers, never one)
A robust loop needs several exits so it always halts:
| Exit | What it is | Example |
| Deterministic verifier | A mechanical pass/fail that confirms the goal | "Publication date is within 7 days" |
| Hard iteration cap | Max passes, no matter what | "Stop after 5 searches per topic" |
| Budget guard | Max time / tool calls / tokens | "Stop after 20 fetches total" |
| No-progress detection | Recent passes changed nothing | "2 searches in a row found nothing new" |
| Human escalation | Hand a stuck loop back to the user | "Asked twice, still unclear: ask the user" |
Pick the verifier plus at least one safety exit (cap or budget) for every loop. No-progress detection is what stops the quiet infinite loops that a cap alone misses.
Verification first (COG's rule, applied to loops)
COG is verification-first: no hallucinations, sources required. Inside a loop that means:
- Prefer mechanical checks. A date comparison, a source count, a "required field is non-empty", a "file marked consolidated" check cannot be gamed and cannot be hallucinated.
- Reserve judgment-based checks for the genuinely unquantifiable (is this theme actually new? is this summary faithful?). When you must use judgment, state confidence and link evidence.
- Never accept the agent's own "I think this is complete." That is the single most common way loops produce confident garbage.
In-loop context management
Long loops fill the window with old tool output and start to drift ("context rot"). Counter it:
- Externalize state to the vault. Write progress to the output file as you go. The vault file is the memory; the conversation is scratch.
- Compact and prune. Summarize finished passes into a line or two. Drop raw page text once you have extracted what you need.
- Isolate sub-agents. In
agent_mode: team, give each worker only the slice it needs and take back only its conclusion, so one subtask runs in a clean window. Never paste one worker's raw output into the next worker's prompt.
Named patterns
| Pattern | Shape | Where COG uses it |
| Act-observe (ReAct) | reason → act → observe → repeat | base of every COG loop |
| Reflect-retry (Reflexion) | on failure, write the lesson, retry differently | url-dump / scout fetch retries, daily-brief re-search |
| Plan-execute-verify | plan steps, run them, verify each | knowledge-consolidation passes |
| Evaluator-optimizer | generate, score against criteria, repeat until it passes | daily-brief item verify, url-dump quality gate |
| Orchestrator-workers | split into subtasks, run in fresh windows, synthesize | team-mode scans, auto-research threads, team-brief |
| Loop-until-dry | keep going until K passes in a row surface nothing new | knowledge-consolidation theme extraction |
| Human-in-the-loop | escalate or ask when the loop is stuck or the call is the user's | weekly-checkin reflection, onboarding |
Failure modes and fixes
| Failure | Fix |
| Context overflow / drift | compact, prune, externalize to vault, isolate sub-agents |
| Silent infinite loop | no-progress detection plus a hard cap |
| Hallucinated success | trust the deterministic verifier, never self-report |
| Compounding errors | verify early and every pass, not only at the end |
| Cost blowup | budget guard, and stop at "good enough", not "perfect" |
| Goal drift | keep the goal and stop conditions written at the top of the loop's state |
How skills use this
A skill's ## Loop Engineering section should be short and concrete. It names:
- The loop in one or two lines (what repeats).
- The verifier (the mechanical pass/fail).
- The termination conditions (verifier plus safety exits).
- The pattern(s) from the table above.
It does not restate this skill. It points here.
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
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.

