research-loop
Run a self-expanding research loop. Each cycle sends parallel researcher agents after open questions, each writes one linked Markdown note, and their follow-up questions refill the queue. Use to start
Files13
View on GitHubSKILL.mdskills/research-loop/SKILL.md
GitHubHamsterrädli (research-loop)
Usage: research-loop <new|cycle|run|status> [loop-name] [seed...] (Claude Code:
/research-loop ...; Codex: $research-loop ...). With no op, run status.
Converted from BitWonka's loop-engine commands
(/research-new, /research-cycle, /run-loop, /research-status, commit 8c133a7, MIT;
see LICENSE) and adapted to a local setup with Claude Code and Codex.
Where loops live
A loop is one folder, and optionally its own Obsidian vault:
- A loop that serves a campaign lives in that campaign's knowledge repo, at
<repo>/loops/<loop-name>, so its notes are committed with the lane's journal. - Any other loop lives under
LOOPS="${RESEARCH_LOOPS_ROOT:-$HOME/research-loops}".
<loop>/
├── Engine/Config.md # seed, caps, status (frontmatter); the Research method section
├── Engine/Queue.md # `- [ ] [d=N] question (parent:: [[Note]])` items
├── Engine/Log.md # one table row per researched topic
├── Engine/Map.md # `- [[Title]] · d<n> · <date>` index of notes
├── Findings.md # the digest: the one file a human reads
└── Research/ # one note per researched question
Below, <loop> is that folder: for a loop name, <repo>/loops/<name> in the campaign repo you
are working in when it exists, else $LOOPS/<name>. <scratch> is
${TMPDIR:-/tmp}/research-loop/<loop-name> (create it with mkdir -p; it is disposable), the
only place for downloads and other working files. Take timestamps from
date "+%Y-%m-%d %H:%M" (set TZ once per machine); dates are +%Y-%m-%d. Obsidian
is optional; read and write the files directly. Each loop gets its own vault, so a personal
vault stays untouched.
Research methods available here
The Research method section of Engine/Config.md names one method; follow it, with any
instructions the user gives for this run taking precedence. These are the tools a
method can use:
| Method | Tool |
|---|---|
| Web pages | Find pages with web search (Claude Code: WebSearch, loaded via ToolSearch select:WebSearch when deferred; Codex: its built-in search). Read them with defuddle parse <url> --md (kepano's defuddle CLI, MIT). Use WebFetch or curl -sL for .md, raw, JSON and PDF URLs, and the built-in browser for signed-in pages |
| GitHub repos | gh api repos/<owner>/<repo>/contents/<path> or a shallow clone into <scratch>; gh is authenticated, the anonymous API is rate-limited |
| Papers | the elicit-research skill: python3 <elicit-research>/scripts/elicit.py POST /search/papers --body req.json --out resp.json. It reads ~/.config/elicit/api-key. Check GET /usage before a large job |
| Local code or a knowledge repo | read-only reads of the named folder; git log/git show for history |
| First principles | reason with no external sources, then self-question to deepen |
| Typed triage | the jev-second-perspective skill (TypeSafe Jev) to rank a long queue or citation-check the digest against the notes |
Keys stay where they already live (~/.config/<service>/, mode 600) or in the loop's own
.env inside the loop folder. Notes, logs, digests and reports carry no keys or tokens.
new: scaffold a loop
- Pick
<loop>per "Where loops live". If it exists, say so, point atcycle, and stop. With no name, ask for one (kebab-case; it is also the vault name). - Copy the template from this skill's base directory:
mkdir -p "$(dirname "<loop>")" && cp -R "<skill-dir>/assets/template" "<loop>". - When a seed was given, set it in
Engine/Config.mdfrontmatter as a double-quoted string (escape"and\) and add it toEngine/Queue.mdunder## Queueas- [ ] [d=0] <seed> (parent:: seed). - When the user described how to research, replace the body of the Research method section with their description; otherwise keep the default web method.
- Only when the user wants Obsidian:
open -a Obsidian "<loop>". - Report the path, seed and method, and how to run it: one cycle with
research-loop cycle <loop-name>; continuously with/loop /research-loop cycle <loop-name>in Claude Code. Codex has no/loop: each invocation runs one cycle.
cycle: one queue-expanding cycle
Do exactly one cycle, then stop; under /loop it is re-invoked.
Load config. Read
Engine/Config.md:seed,notes_per_run(default 1),max_depth(default 3),max_breadth(default 3),continuous(default false),digest(defaultFindings.md),status, and the Research method section (the section only; the "Method examples" section after it is editing help).status: paused→ print⏸ pausedand stop. A seed passed in the arguments replaces the configured one: write it to the frontmatter and queue it as innewstep 3.Build the worklist of up to
notes_per_runitems, taken top-down from the lines under## QueueinEngine/Queue.mdthat start with- [ ]:- Mark pending items deeper than
max_depthas skipped:- [-]. - When the queue holds no items at all, add the seed as
- [ ] [d=0] <seed> (parent:: seed). The first cycle therefore researches the seed alone; later cycles fill up from its follow-ups. - Still short, with
continuous: true: skimMap.mdand the notes, then add fresh[d=0]directions toward the seed that existing notes do not cover. - Still empty, with
continuous: false: print✅ research complete: queue drained; stop the /loopand stop. Done when the worklist holds the items this cycle will research.
- Mark pending items deeper than
Fan out, one researcher per worklist item. In Claude Code, launch them in a single message as
general-purposeAgent subagents (so they can Write). In Codex, or anywhere without a subagent tool, research the items yourself one after another. Each researcher gets the loop path, the Research method, its one question with its depth, the other worklist questions of this cycle (to avoid overlapping them), and these instructions:- When a note in
Research/already covers the question well, write nothing and returnskipped: [[<that note>]]. - Research it per the method and cite every source. A method with no external sources
writes
1. none (first principles)under Sources. Downloads and working files go to<scratch>only, and notes never link into it. - Write exactly one note,
<loop>/Research/<title>.md, in the shape below. Choose a title without? : / \ # | [ ] ^, so the file name, thetitle:line and every[[link]]are identical. If the Write tool refuses the file, write it with a shell heredoc. Touch no other file in the loop and no external repository. - Return the note title and at most
max_breadthfollow-up questions.
--- title: "<clear, specific title; equals the file name>" created: <TZ=Europe/Zurich date "+%Y-%m-%d %H:%M"> tags: [research, depth/<n>] depth: <n> parent: "<[[Parent Note]], or seed for a d=0 question>" status: complete --- # <title> > [!summary] TL;DR > 2-4 sentences. ## Key findings - ...with inline source refs; mark each as measured, cited or inferred ## Details ## Open questions - <the follow-ups it raises> ## Sources 1. [title](url or DOI): note (abstract-only or full text) ## Related - [[Parent Note]] / siblings- When a note in
Collect and refill, as the orchestrator, serially (you alone write the Engine files and the digest, so researchers never race on them). For every returned result:
- a skip: mark its item
- [-]and move on; - mark its item
[x]inQueue.md; - append its follow-ups as
- [ ] [d=<depth+1>] <question> (parent:: [[<title>]])whendepth+1≤max_depth, deduplicated against existing notes and queue items; deeper follow-ups go to the digest's Open questions instead; - append
- [[<title>]] · d<depth> · <date>toMap.md; - append
| <n> | <timestamp now> | <depth> | <question, with | replaced by /> | [[<title>]] | <k> queued |toLog.md, numbering rows from 1. Done when every written note appears inMap.mdandLog.md.
- a skip: mark its item
Rewrite the digest (
digest, defaultFindings.md, shipped in the template): a ranked, deduplicated living summary that folds in this cycle's notes, drops stale items and links the[[notes]]. Follow the digest structure the Research method names; otherwise a ranked "Key findings" list plus "Open questions". Skimmable in about 30 seconds. When the top finding is about to drive a decision (kill a route, spend money, submit), have Claude Fable try to refute it first (Claude Code: an Agent call withmodel: fable; Codex: the send-to-claude-fable skill) and record the verdict in the digest.Report in 3-5 lines: the loop, notes written this cycle, follow-ups queued, total notes, and whether it continues on the next tick or is complete.
When a cycle runs inside a subagent, Claude Code's Write tool can refuse loop files as "report files"; update them with Edit, or write them with a shell heredoc. They are loop state, not reports.
run: one tool-assisted cycle
For loops whose Research method names a private data tool kept in the loop folder (for
example <loop>/scan.py: a leaderboard fetch and diff, an API poll). The tool supplies cheap
raw data; the analysis is yours.
- Read
Engine/Config.md;status: paused→ print⏸ pausedand stop. - Follow the Research method literally. Typically run the helper from the loop folder with
its own env, so only its compact digest enters your context:
(cd "<loop>" || exit 1; set -a; if [ -f .env ]; then . ./.env; fi; set +a; python3 scan.py). - Find the signal (the largest changes, anything new; ignore noise), research the items no
note in
Research/covers yet, and write analytical notes with[[wikilinks]]plus any thesis or index file the method names. Interpret the data; a pasted digest is not a note. - Append a heartbeat row to
Engine/Log.md. - Report in 3-5 lines: the key moves, what you researched and concluded, the notes written.
Keep it running with /loop 15m /research-loop run <loop-name> in Claude Code.
status: overview of all loops
Read from disk. Loops are the folders under $LOOPS plus any loops/* folder in the
campaign repo you are working in. For each loop read Config.md frontmatter; count the lines
under ## Queue in Queue.md that start with - [ ] (pending), - [x] (done) and - [-]
(skipped); count the .md notes in Research/; take the deepest depth: among them; and
take the When of the last Log.md row.
- No loop name: one table
| Loop | Status | Notes | Pending | Done | Skipped | Deepest/max | Last activity | Seed |, with Deepest-when there are no notes and the seed without its quotes. - With a loop name: its seed, the caps (
max_depth,max_breadth,notes_per_run,continuous), a method summary, the pending items with depths, and the last few log rows. - No loops: say so and suggest
research-loop new <name> <seed>.
Running loops
A loop occupies the session it runs in. Run each one in a background agent or its own
session so the main session stays responsive; loops are independent, so several can run at
once. Pause one with status: paused in its Config.md, or by stopping its /loop.