agentleFS
LeoLin990405LeoLin990405/grimoire-skill/SKILL.md

grimoire

Skill8 starsChanged 8 months agoMITView on GitHub

Grimoire — turn a PDF/document/raw text into reading notes + a reusable skill pack in one parse. Auto-classifies book/paper/document, scaffolds type-specific notes for an Obsidian vault, and mines per-source skills merged per book/course. Built on the MinerU parsing API (OCR, formula/table, batch). Scripts never call an LLM and never write the vault; skill install is OPT-IN (--install / scripts/skill-install.sh) and deliberately crosses the candidate-only boundary by explicit user request, recorded in the manifest. Raw text → skill via --from-text; cross-agent install + management via the grimoire-manage companion skill.

  • Installs packages
  • Sends data out

3 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions3 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 3

    1. cwinvestments/memstack★ 425same name
    2. GhostPawJS/grimoire★ 2same name
    3. vbrevik/claude_code_skills★ 0same name

    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 repository5 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 4 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Opt-in → the grimoire: Only when the user actually wants reading notes and/or a packaged skill, continue from that Markdown with …

    line 54
  2. Distinctive:

    Use this when the user uploads a book, course, paper, manual, article collection, or other long-form text and wants the agent to learn …

    line 244
  3. Distinctive:

    Keep broad concepts and background theory as reference-only material unless the source gives a concrete procedure.

    line 326
  4. Very specific:

    Use --type auto by default.

    line 340
  5. Distinctive:

    Use this when the user gives a PDF/document and wants the agent to read it and write notes (not extract agent skills).

    line 349
  6. Distinctive:

    Use this when the user gives text or source metadata and wants Codex, Claude Code, or another agent to first identify the object type, …

    line 431
  7. Very specific:

    After type confirmation and typed notes, the agent runs source-skill-pack.sh over captured-markdown/ and fills segment skills, …

    line 457

“Common” is measured: kept by at least 6 in 10 of the 3 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Grimoire · 魔典 — Document → Notes + Skill Pack

One source, parsed once, woven into typed reading notes (→ Obsidian) and a per-source skill pack. Primary entry point: scripts/grimoire.sh. Full product overview and bilingual docs: see README.md.

The sections below are the underlying MinerU parsing API reference that the grimoire toolchain is built on.

Flow: Markdown first, the grimoire is opt-in · 先转 MD,魔典是可选续跑

The pipeline is gated, not automatic:

  1. Always first → Markdown. A source becomes Markdown via pdf2md / mineru-local (or any MinerU parse). For many requests this is the whole job — stop here. Do not auto-run notes/skill mining.
  2. Opt-in → the grimoire. Only when the user actually wants reading notes and/or a packaged skill, continue from that Markdown with grimoire.sh --from-markdown <md>. Nothing is re-uploaded; the parse is skipped. --only notes|skills|both is the second opt-in: notes only, the skill (engineering-prompt) packaging only, or both.
  3. --only both is two-stage, not parallel. Stage 1 writes the type-specific notes from the source. Stage 2 is a deliberate re-learning pass (重复学习): the agent re-reads the notes it just wrote and mines the skill pack from those notes' knowledge points, not the raw source (source-markdown/ is then only for evidence anchors). --only skills (no notes) keeps mining from the source.

默认只到 MD;笔记 / 把内容封装成 skill 工程提示属于用户主动选择的下游, 用 --from-markdown 从已有 MD 续跑,不重新上传、不重复解析。 --only both 是两段式:先写笔记,再「重复学习」从笔记里挖技能包, 不是同段并行。

This keeps the live pdf2md / mineru-local path unchanged — Grimoire does not steal its triggers; it is the deliberate next step after Markdown.

Overview

MinerU converts PDF, DOC, DOCX, PPT, PPTX, PNG, JPG, JPEG, HTML into machine-readable Markdown/JSON. Supports OCR (109 languages), formula/table recognition, cross-page table merging, and batch processing.

This skill can also stage a parsed long-form source as a source skill pack: a workspace that a large language model can read to extract candidate agent skills, grouped by source first and then by chapter, lesson, section, or note. The workflow does not call an LLM and does not install generated skills automatically.

It can additionally run a source-to-notes pipeline: parse a document, auto-classify it as book / paper / document (hybrid heuristic + AI confirmation), scaffold the matching note discipline, and stage the final note for the Obsidian Knowledge-Hub vault. The agent does the reading and writing; the scripts never call an LLM and never write into the vault directly.

Two modes:

  • Cloud API — https://mineru.net/api/v4 (no GPU required, token-based)
  • Local API — mineru-api --port 8000 (self-hosted, requires GPU or CPU backend)

Authentication (Cloud API)

mkdir -p ~/.config/mineru
echo "YOUR_TOKEN" > ~/.config/mineru/token
chmod 600 ~/.config/mineru/token

Limits (Cloud API)

ItemLimit
Single file size200MB max
Single file pages600 pages max
Daily priority pages2000 pages/account
Batch upload200 files/request
Token validity90 days

Model Versions

ModelUse CaseSpeedNotes
vlmDefault. MinerU2.5, complex layouts, highest accuracySlowerCloud-recommended; needs GPU locally
pipelineGeneral documents, CPU-friendlyFastPure CPU support, lower accuracy
MinerU-HTMLHTML output, preserves formattingMediumFor web content
hybridDefault pre-2026-04—RETIRED on the cloud API — returns code -10002 "version field invalid". Do not use against mineru.net.

API Endpoints (Cloud)

Base URL: https://mineru.net/api/v4

1. Create Extraction Task (Single File)

POST /extract/task
ParamTypeRequiredDefaultDescription
urlstringyes-File URL (no direct upload)
model_versionstringnovlmvlm / pipeline / MinerU-HTML (hybrid retired, returns -10002)
is_ocrboolnofalseEnable OCR
enable_formulaboolnotrueFormula recognition
enable_tableboolnotrueTable recognition
languagestringnochDocument language
data_idstringno-Custom identifier
page_rangesstringno-e.g. "2,4-6"
callbackstringno-Callback URL for async results
extra_formatsarrayno-["docx"], ["html"], ["latex"]

Response:

{"code": 0, "data": {"task_id": "xxx"}, "msg": "ok"}

2. Get Task Results

GET /extract/task/{task_id}

States: pending → running → done / failed / converting

Done response: includes full_zip_url (download link)

3. Batch Upload Local Files

POST /file-urls/batch

Returns presigned upload URLs (valid 24h). System auto-submits extraction after upload.

4. Batch URL Extraction

POST /extract/task/batch

Submit multiple URLs at once, returns batch_id.

5. Batch Results

GET /extract-results/batch/{batch_id}

Local API (Self-Hosted)

Start Server

# FastAPI server
mineru-api --host 0.0.0.0 --port 8000

# Gradio WebUI
mineru-gradio --server-name 0.0.0.0 --server-port 7860

# OpenAI-compatible server (for remote VLM inference)
mineru-openai-server --port 30000

Environment Variables

VariableDescriptionDefault
MINERU_MODEL_SOURCEModel source: modelscope / huggingfacehuggingface
MINERU_API_MAX_CONCURRENT_REQUESTSMax concurrent API requestsUnlimited
MINERU_API_ENABLE_FASTAPI_DOCSEnable /docs pagetrue

Local API Docs

Access at http://127.0.0.1:8000/docs after starting.

Use CLI with Remote Server

mineru -p input.pdf -o output/ -b hybrid-http-client -u http://server:30000

Error Codes

CodeIssueFix
A0202Token invalidCheck Bearer prefix and token
A0211Token expiredRecreate at mineru.net
-60002Unrecognized formatCheck file extension
-60005File too largeMax 200MB
-60006Too many pagesMax 600, split document
-60008URL timeoutCheck URL accessibility
-60012Task not foundVerify task_id

Helper Script

~/.claude/skills/mineru/scripts/mineru-parse.sh — full-featured CLI wrapper.

# URL mode
mineru-parse.sh https://example.com/doc.pdf

# Local file with options
mineru-parse.sh /path/to/file.pdf --model vlm --ocr --output /tmp/result

# Extra formats
mineru-parse.sh doc.pdf --format docx --format latex

# Page ranges
mineru-parse.sh doc.pdf --pages "1-5,8" --output ./results

# Auto-extract markdown from zip
mineru-parse.sh doc.pdf --output ./results --extract

# Extract without printing book-sized markdown and write a local manifest
mineru-parse.sh book.pdf --output ./results --extract --no-print-md --manifest ./results/parse_manifest.json

Source-to-Skill Workflow

Use this when the user uploads a book, course, paper, manual, article collection, or other long-form text and wants the agent to learn which reusable skills can be extracted from it.

Commands

# Local files are uploaded to the MinerU cloud API; --cloud-ok is required.
~/.claude/skills/mineru/scripts/mineru-source-to-skill.sh /path/to/book.pdf \
  --title "Book Title" \
  --type auto \
  --output ./source-workspaces \
  --cloud-ok

# If the source is already parsed to Markdown, stage a pack directly.
~/.claude/skills/mineru/scripts/source-skill-pack.sh ./mineru-extracted/book \
  --title "Book Title" \
  --type auto \
  --output ./source-skill-packs

Compatibility wrappers are still available for older automation: mineru-book-to-skill.sh, book-skill-pack.sh, and vivo-agent-workspace.sh.

Output Contract

The wrapper creates a source-scoped workspace:

source-workspaces/
└── sources/
    └── <source-slug>/
        ├── README.md
        ├── source/
        ├── mineru/
        │   ├── parse_manifest.json
        │   ├── *_result.zip
        │   └── <extracted markdown files>
        └── analysis/
            └── source-skill-pack/
                ├── README.md
                ├── manifest.json
                ├── LLM_EXTRACTION_PROMPT.md
                ├── BOOK_SKILL_INDEX.md
                ├── MANAGE_SKILLS.md
                ├── MINDMAP.md
                ├── source-markdown/
                ├── segments/
                │   ├── manifest.json
                │   └── 001-<chapter-or-section>.md
                ├── chapter-skills/
                │   └── 001-<chapter-or-section>/
                │       ├── CHAPTER_SKILL_INDEX.md
                │       └── skills/
                ├── whole-book/
                │   └── WHOLE_BOOK_SUMMARY.md
                └── skills/

Give LLM_EXTRACTION_PROMPT.md, segments/, and chapter-skills/ to the active agent. The agent should fill:

  • chapter-skills/*/CHAPTER_SKILL_INDEX.md: what each segment contributes before whole-source synthesis.
  • chapter-skills/*/skills/*.md: one narrow candidate skill per segment-level capability.
  • whole-book/WHOLE_BOOK_SUMMARY.md: source-level capability summary after segment extraction.
  • MINDMAP.md: topic classification and skill-family map.
  • BOOK_SKILL_INDEX.md: what this source can help the agent do, when to reference it, and a table of skill candidates.
  • skills/*.md: reviewed cross-segment candidates only, using the generated _skill-template.md.

Extraction Criteria

Extract only content that can become an operational skill:

  • procedures and workflows
  • checklists
  • diagnostics
  • decision rules
  • reusable prompt patterns
  • coding or analysis patterns
  • frameworks with clear trigger situations

Keep broad concepts and background theory as reference-only material unless the source gives a concrete procedure.

Manage Skills Boundary

Long-form skill packs are candidates. Do not automatically install, enable, or sync generated skills. After human review, promote only stable skills into the managed skills repository, then run the local skills manager separately, for example:

skills enable <promoted-skill-name>

The generated pack must not store API tokens, authorization headers, remote result URLs, or private account data.

Source Type Classification

Use --type auto by default. The packer records detected type metadata for books, courses, papers, manuals, article collections, videos, web sources, mixed source sets, and project notes. Override with --type book, --type course, --type paper, --type manual, --type article-collection, --type video, --type audio, --type web, --type mixed, or --type project-notes when the automatic classifier is wrong.

Source-to-Notes Workflow

Use this when the user gives a PDF/document and wants the agent to read it and write notes (not extract agent skills). The pipeline auto-decides the note discipline from the document itself.

Commands

# One shot: parse + classify + scaffold notes workspace.
# Local files are uploaded to the MinerU cloud API; --cloud-ok is required.
~/.claude/skills/mineru/scripts/mineru-to-notes.sh /path/to/source.pdf \
  --title "Source Title" \
  --type auto \
  --cloud-ok

# Already have MinerU Markdown? Stage the notes pack directly:
~/.claude/skills/mineru/scripts/reading-notes-pack.sh ./mineru-extracted/doc \
  --title "Source Title" --type auto

# RECOMMENDED MD-first continuation: pdf2md already produced Markdown, the
# user now opts in to the grimoire. No re-upload, no re-parse.
~/.claude/skills/mineru/scripts/grimoire.sh \
  --from-markdown ./mineru-extracted/doc \
  --title "Source Title" \
  --only both          # or: notes | skills

Classification (hybrid, autonomous)

scripts/lib/reading-types.sh scores filename + parsed-Markdown structure into three buckets and a confidence band:

TypeTrigger signalsNote discipline
bookmany 第N章/Chapter N, TOC, ISBN, long page countchapter-by-chapter complete notes
paperabstract, DOI/arXiv, references, related work, venuedetailed structured reading / excerpt notes
documentAPI ref / install / config / report / spec / slides, shortcontent-adaptive structured notes
  • High/medium confidence → the scaffold proceeds for that type.
  • Low confidence → AI fallback: the pack writes AI_CLASSIFY.md with a text sample and a strict book/paper/document decision contract. The agent confirms the type (Step 0) before reading; if it disagrees with the heuristic it re-runs the packer with the correct --type.

Manual override is always available with --type book|paper|document.

Output Contract

reading-workspaces/sources/<slug>/
  README.md
  source/
  mineru/parse_manifest.json + extracted Markdown
  notes/reading-notes-pack/
    classification.json        detected type / confidence / signals
    AI_CLASSIFY.md             only when confidence is low
    AI_READING_TASK.md         the reading contract (entry point)
    OBSIDIAN_PLAN.md           exact vault target + house-style rules
    manifest.json
    source-markdown/
    segments/                  chapter/section split (book & document)
    notes/<slug>.md            scaffold from the matching template

Give the agent AI_READING_TASK.md. It reads source-markdown/ (and segments/ for books/documents), fills notes/<slug>.md using the type-specific template, passes a quality self-check (> 2KB real synthesis, evidence anchors, [[wikilinks]], no placeholders), then writes the final note into the Obsidian vault path from OBSIDIAN_PLAN.md and appends a log.md line.

Obsidian Knowledge-Hub Boundary

The vault target folder is book → Books/, paper → Papers/, document → Documents/. Vault root defaults to $MINERU_OBSIDIAN_VAULT or ~/Documents/Obsidian-Vaults/Knowledge-Hub and is overridable with --vault. The scripts never create or modify a vault file — the agent writes the note after the quality self-check, matching the house style of an existing sibling note. Generated packs store no API tokens, auth headers, or remote result URLs.

Vivo Agent Workflow

Use this when the user gives text or source metadata and wants Codex, Claude Code, or another agent to first identify the object type, write the matching notes, then distill candidate skills from books, papers, courses, web pages, videos, audio transcripts, PDFs, or existing notes.

~/.claude/skills/mineru/scripts/vivo-workspace.sh \
  --title "Knowledge Source" \
  --type mixed \
  --agent "Claude Code" \
  --output ./vivo-workspaces

Vivo creates AGENT_TASK.md, SOURCES.md, notes/live-notes.md, notes/source-type-confirmation.md, notes/topic-classification.md, notes/skill-discovery-coverage.md, captured-markdown/, and packs/. The script does not call OpenAI, Claude, or any model. The active agent performs capture and reasoning with its available tools:

  • web pages: browser, fetch, web search, or OpenAI-backed web capability
  • videos: subtitles or transcript tools
  • audio: transcript or speech-to-text tools when available
  • PDFs: MinerU parsing or another local converter
  • courses: lesson/module/topic classification
  • notes: first source-type confirmation, then typed notes while capture happens

After type confirmation and typed notes, the agent runs source-skill-pack.sh over captured-markdown/ and fills segment skills, whole-book/WHOLE_BOOK_SUMMARY.md, MINDMAP.md, SKILL_DISCOVERY_COVERAGE.md, and BOOK_SKILL_INDEX.md before promoting reviewed candidates. Stop only when a full pass over every source unit finds no new supported operational skills.

Quick Parse (Python)

import requests, time

TOKEN = open("~/.config/mineru/token").read().strip()
BASE = "https://mineru.net/api/v4"
HEADERS = {"Authorization": f"Bearer {TOKEN}"}

def parse_document(url, model="vlm", ocr=False, extra_formats=None):
    """Parse a document from URL, return download link."""
    body = {
        "url": url, "model_version": model,
        "is_ocr": ocr, "enable_formula": True, "enable_table": True,
    }
    if extra_formats:
        body["extra_formats"] = extra_formats

    resp = requests.post(f"{BASE}/extract/task", headers=HEADERS, json=body)
    task_id = resp.json()["data"]["task_id"]

    while True:
        result = requests.get(f"{BASE}/extract/task/{task_id}", headers=HEADERS).json()
        state = result["data"]["state"]
        if state == "done":
            return result["data"]["full_zip_url"]
        elif state == "failed":
            raise Exception(f"Task failed: {result}")
        time.sleep(5)

Quick Parse (curl)

TOKEN=$(cat ~/.config/mineru/token)

# Submit
curl -s -X POST "https://mineru.net/api/v4/extract/task" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/doc.pdf","model_version":"vlm"}'

# Check result
curl -s "https://mineru.net/api/v4/extract/task/{task_id}" \
  -H "Authorization: Bearer $TOKEN"

Installation (Local Mode)

pip install uv
uv pip install -U "mineru[all]"

Requirements: Python 3.10-3.13, 16GB+ RAM, 20GB+ SSD. GPU optional (Volta+ or Apple Silicon).

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.