# Coarse Extract

> Coarse pipeline steps 1-2 — extract a paper file to markdown and parse its section structure. Writes _extracted.md and _sections.json to .coarse_cache/.

- **Type:** Skill
- **Install:** `agentstack add skill-felipe-so-coarse-ink-claude-code-coarse-extract`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [Felipe-SO](https://agentstack.voostack.com/s/felipe-so)
- **Installs:** 0
- **Category:** [Content & Media](https://agentstack.voostack.com/c/content-and-media)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [Felipe-SO](https://github.com/Felipe-SO)
- **Source:** https://github.com/Felipe-SO/coarse-ink-claude-code/tree/main/.claude/skills/coarse-extract

## Install

```sh
agentstack add skill-felipe-so-coarse-ink-claude-code-coarse-extract
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# /coarse-extract — Extract and Parse Structure

**Usage**: `/coarse-extract papers/paper.pdf`

Argument (`$ARGUMENTS`) is the path to the paper. All paths are relative to the
workspace root `d:/Dropbox/Research/Coarse Reviewer/`.

## Path setup

Derive a **slug** from the filename: lowercase, spaces→hyphens, no extension.
e.g. `papers/my-paper.pdf` → slug = `my-paper`

- `PAPER_PATH` = `$ARGUMENTS`
- `EXTRACTED` = `.coarse_cache/_extracted.md`
- `SECTIONS_JSON` = `.coarse_cache/_sections.json`

Create `.coarse_cache/` if it doesn't exist.

---

## Step 1 — Extract (Python)

Run:
```bash
python scripts/coarse_extract.py PAPER_PATH EXTRACTED
```

This writes the full paper as markdown to `EXTRACTED`. Uses Mistral OCR via
OpenRouter if `OPENROUTER_API_KEY` is set; otherwise falls back to pymupdf.

If extraction fails, try the pymupdf fallback directly:
```bash
python -c "
import fitz, sys
doc = fitz.open(sys.argv[1])
text = '\n\n'.join(page.get_text() for page in doc)
open(sys.argv[2], 'w', encoding='utf-8').write(text)
" PAPER_PATH EXTRACTED
```

Then read `EXTRACTED` into your context with the Read tool.

**Garble check**: After reading `EXTRACTED`, scan the first 3000 characters for
OCR artifacts — spaced-out characters (e.g. `T h e o r e m`), garbled symbols
(`ˆ b`, `∈ˆ`, HTML entities like `&lt;`), or lines that are clearly noise.
If you find more than a few isolated artifacts, warn the user: the PDF may have
been scanned or image-only. The downstream review steps include an OCR-artifact
notice to the reviewer, but severe garbling will hurt review quality. Advise
the user to check whether a text-native PDF is available.

---

## Step 2 — Parse Structure (Python)

Run:
```bash
python scripts/coarse_structure.py EXTRACTED SECTIONS_JSON
```

This writes a JSON array of section objects to `SECTIONS_JSON`. Each section has:
- `number`, `title`, `text`, `section_type` (abstract/introduction/related_work/
  methodology/results/discussion/conclusion/appendix/references/other)
- `math_content` (bool — set to `false` by this script; will be set in classify step)
- `claims` (list of theorem/lemma/proposition statements found by regex)
- `definitions` (list of definition statements found by regex)

Read `SECTIONS_JSON` and confirm the section list looks correct.

---

Done. Next: `/coarse-classify `

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [Felipe-SO](https://github.com/Felipe-SO)
- **Source:** [Felipe-SO/coarse-ink-claude-code](https://github.com/Felipe-SO/coarse-ink-claude-code)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** yes
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-felipe-so-coarse-ink-claude-code-coarse-extract
- Seller: https://agentstack.voostack.com/s/felipe-so
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
