Notes OCR Skill
Converts handwritten scanned notes, PDFs, or images into three clean professional outputs:
Markdown (with faithful Mermaid diagrams), Excel (structured data), and PDF (print-ready).
Overview
When a user uploads handwritten content, follow these phases in order:
- Read & Extract — parse every piece of content from the image/PDF
- Reconstruct Diagrams — convert hand-drawn diagrams to Mermaid syntax exactly as drawn
- Structure Content — organize all text into logical sections
- Generate Outputs — produce MD + XLSX + PDF in parallel
Phase 1: Read & Extract
Supported Input Types
- Scanned PDFs (single or multi-page)
- Photos of handwritten notes
- Images (PNG, JPG, WEBP)
- Mixed content (text + diagrams on same page)
What to Extract (miss nothing)
- All text, titles, headings, bullet points, numbered lists
- Every table (rows, columns, headers, sample data)
- Every diagram: flowcharts, entity maps, ERDs, org charts, mind maps, architecture sketches, arrow relationships
- Field labels and their types (e.g. "str: username", "Bool: KYC")
- Annotations, formulas, legends, footnotes
- Dates, authors, version numbers in headers/footers
Extraction Pass
Read the input carefully top-to-bottom, left-to-right. For multi-page inputs, process each page fully before moving on. Keep a running structured outline:
## Page N
### Section (heading or inferred)
- bullet / text content
- [DIAGRAM] description of what was drawn
- [TABLE] header1 | header2 | ...
Phase 2: Reconstruct Diagrams as Mermaid
This is the most critical phase. Every hand-drawn diagram must become a Mermaid block.
Diagram Type Detection
| What you see in notes |
Mermaid type to use |
| Boxes with arrows between them |
graph TD or graph LR |
| Entity boxes with field lists |
graph TD with subgraphs, or erDiagram |
| Hierarchy / tree structure |
graph TD |
| Sequential steps / flow |
flowchart TD |
| Database tables with relationships |
erDiagram |
| Timeline or process phases |
graph LR |
| Referral / network chains |
graph LR or graph TD |
| CRUD labels on arrows |
graph TD with edge labels |
| Nested groups / subgraphs |
graph TD with subgraph blocks |
Faithfulness Rules
- Preserve the exact topology — if A→B→C in the notes, write exactly that
- Preserve labels verbatim — field names, type annotations (str/bool/float/int), entity names, arrow labels must match the handwriting exactly (correct obvious misspellings but keep meaning)
- Preserve hierarchy — parent→child relationships, nesting, grouping as drawn
- Do not add nodes or arrows not in the notes
- Do not simplify — if there are 4 wallet types drawn, show all 4
Mermaid Syntax Reminders
- Node labels with special chars:
A["str: wallet_id"]
- Subgraphs:
subgraph Name \n ... \n end
- Edge labels:
A -->|has a| B
- ER entities:
ENTITY { type field_name }
- Dotted arrows:
A -.->|optional| B
One Mermaid block per diagram
Each distinct diagram in the notes gets its own fenced ```mermaid block placed inline where that diagram appeared in the notes.
Phase 3: Structure Content
Organize extracted content into document sections. Infer logical groupings from context:
- Use headings from the notes as section headers
- Group related bullet points under the nearest heading
- Place tables close to their surrounding text
- Insert Mermaid blocks exactly where the diagram appeared (not at the end)
- Add a Table of Contents at the top
Markdown Template
# [Document Title]
**Author:** [if visible] | **Date:** [if visible]
---
## Table of Contents
1. [Section 1]
2. [Section 2]
...
---
## [Section 1]
[content, tables, mermaid blocks inline]
## [Section 2]
...
Phase 4: Generate All Three Outputs
Run all three output scripts. See scripts/ for reusable helpers.
Output 1 — Markdown ([title].md)
- Full document with all sections
- Mermaid diagram blocks inline, faithfully reconstructed
- Tables as GFM markdown tables
- Saved to
/mnt/user-data/outputs/
Output 2 — Excel ([title].xlsx)
Use openpyxl. Follow scripts/build_excel.py pattern:
- One sheet per major section of the document
- Sheet 1 always: "Overview" — title, date, author, section list
- Subsequent sheets: structured tables from each section
- If a section has no tabular data, create a two-column sheet: Field | Value, listing all key info
- Diagrams sheet: text description of each diagram and which Mermaid block it corresponds to
- Professional formatting: Arial font,
#366092 header fill, white header text, thin borders, alternating row fill #F0F0F0
- Run
scripts/recalc.py after saving (copied from xlsx skill)
Output 3 — PDF ([title].pdf)
Use reportlab. Follow scripts/build_pdf.py pattern:
- Title page: document name, author, date, short abstract
- Table of contents page
- One section per page-break where content is long
- Tables via
reportlab.platypus.Table with TableStyle
- For each diagram: a clearly titled box stating "Diagram: [name] — see Mermaid block in Markdown file" plus a text-art approximation if the diagram is simple enough, otherwise a clean prose description
- Header color:
#366092, white text; body: Arial 10pt; headings: Arial Bold 12-14pt
- Footer with page numbers and document title
Naming Convention
Derive [title] from the document's heading or content (snake_case, no spaces).
Calling the Scripts
# After extracting content, build outputs:
import subprocess
# 1. Generate Excel
subprocess.run(['python', '/home/claude/notes-ocr/scripts/build_excel.py',
'--data', data_json_path, '--out', output_xlsx_path])
# 2. Generate PDF
subprocess.run(['python', '/home/claude/notes-ocr/scripts/build_pdf.py',
'--data', data_json_path, '--out', output_pdf_path])
Or write the scripts inline for the specific document — the script files are reference templates.
Output Checklist
Before presenting files, verify:
Reference Scripts
See scripts/ directory:
build_excel.py — reusable Excel builder (openpyxl, professional style)
build_pdf.py — reusable PDF builder (reportlab, professional style)
excel_styles.py — shared style constants for Excel
pdf_styles.py — shared style constants for PDF
These are templates — copy and adapt them for each document's specific sections and tables.
Error Handling
- If handwriting is illegible in a region: insert
[illegible] placeholder and note it
- If a diagram is ambiguous: reconstruct the most faithful interpretation and add a comment
<!-- Note: diagram reconstructed from ambiguous sketch -->
- If a page is blank or nearly blank: skip it silently
- If input has no diagrams: still produce all three outputs, just omit the Diagrams sheet from Excel
Example Trigger Phrases
- "turn my handwritten notes into a doc"
- "digitize this PDF scan"
- "convert this image of notes to markdown and excel"
- "OCR this and make it clean"
- "my notes have diagrams, convert them"
- "make a professional document from my scan"
- (user uploads image/PDF with no explanation — check if it contains handwriting and ask)
1---2name: notes-ocr3description: Digitizes handwritten scanned notes, PDFs, or images into structured professional documents. Use this skill whenever a user uploads a photo, scan, PDF, or image containing handwritten content — notes, diagrams, architecture sketches, plans, tables, flowcharts, lists — and wants it transcribed, organized, or converted into clean digital output. Triggers include: "digitize my notes", "convert this scan", "transcribe my handwriting", "turn this into a doc", "OCR this", "clean up my notes", "my handwritten PDF", "my photo of notes", or when the user uploads any image/PDF and asks for markdown, Excel, or PDF output. Always produce ALL THREE outputs (Markdown with Mermaid diagrams, Excel, and PDF) unless the user explicitly asks for fewer. The Mermaid diagrams must faithfully reconstruct any hand-drawn diagrams, entity maps, flowcharts, or relationship sketches exactly as drawn — not as a generic interpretation.4---56# Notes OCR Skill78Converts handwritten scanned notes, PDFs, or images into three clean professional outputs:9**Markdown** (with faithful Mermaid diagrams), **Excel** (structured data), and **PDF** (print-ready).1011---1213## Overview1415When a user uploads handwritten content, follow these phases in order:16171. **Read & Extract** — parse every piece of content from the image/PDF182. **Reconstruct Diagrams** — convert hand-drawn diagrams to Mermaid syntax exactly as drawn193. **Structure Content** — organize all text into logical sections204. **Generate Outputs** — produce MD + XLSX + PDF in parallel2122---2324## Phase 1: Read & Extract2526### Supported Input Types27- Scanned PDFs (single or multi-page)28- Photos of handwritten notes29- Images (PNG, JPG, WEBP)30- Mixed content (text + diagrams on same page)3132### What to Extract (miss nothing)33- All text, titles, headings, bullet points, numbered lists34- Every table (rows, columns, headers, sample data)35- Every diagram: flowcharts, entity maps, ERDs, org charts, mind maps, architecture sketches, arrow relationships36- Field labels and their types (e.g. "str: username", "Bool: KYC")37- Annotations, formulas, legends, footnotes38- Dates, authors, version numbers in headers/footers3940### Extraction Pass41Read the input carefully top-to-bottom, left-to-right. For multi-page inputs, process each page fully before moving on. Keep a running structured outline:4243```44## Page N45### Section (heading or inferred)46- bullet / text content47- [DIAGRAM] description of what was drawn48- [TABLE] header1 | header2 | ...49```5051---5253## Phase 2: Reconstruct Diagrams as Mermaid5455This is the most critical phase. Every hand-drawn diagram must become a Mermaid block.5657### Diagram Type Detection5859| What you see in notes | Mermaid type to use |60|---|---|61| Boxes with arrows between them | `graph TD` or `graph LR` |62| Entity boxes with field lists | `graph TD` with subgraphs, or `erDiagram` |63| Hierarchy / tree structure | `graph TD` |64| Sequential steps / flow | `flowchart TD` |65| Database tables with relationships | `erDiagram` |66| Timeline or process phases | `graph LR` |67| Referral / network chains | `graph LR` or `graph TD` |68| CRUD labels on arrows | `graph TD` with edge labels |69| Nested groups / subgraphs | `graph TD` with `subgraph` blocks |7071### Faithfulness Rules7273- **Preserve the exact topology** — if A→B→C in the notes, write exactly that74- **Preserve labels verbatim** — field names, type annotations (str/bool/float/int), entity names, arrow labels must match the handwriting exactly (correct obvious misspellings but keep meaning)75- **Preserve hierarchy** — parent→child relationships, nesting, grouping as drawn76- **Do not add nodes or arrows not in the notes**77- **Do not simplify** — if there are 4 wallet types drawn, show all 47879### Mermaid Syntax Reminders80- Node labels with special chars: `A["str: wallet_id"]`81- Subgraphs: `subgraph Name \n ... \n end`82- Edge labels: `A -->|has a| B`83- ER entities: `ENTITY { type field_name }`84- Dotted arrows: `A -.->|optional| B`8586### One Mermaid block per diagram87Each distinct diagram in the notes gets its own fenced ` ```mermaid ` block placed inline where that diagram appeared in the notes.8889---9091## Phase 3: Structure Content9293Organize extracted content into document sections. Infer logical groupings from context:9495- Use headings from the notes as section headers96- Group related bullet points under the nearest heading97- Place tables close to their surrounding text98- Insert Mermaid blocks exactly where the diagram appeared (not at the end)99- Add a Table of Contents at the top100101### Markdown Template102103```markdown104# [Document Title]105106**Author:** [if visible] | **Date:** [if visible]107108---109110## Table of Contents1111. [Section 1]1122. [Section 2]113...114115---116117## [Section 1]118[content, tables, mermaid blocks inline]119120## [Section 2]121...122```123124---125126## Phase 4: Generate All Three Outputs127128Run all three output scripts. See `scripts/` for reusable helpers.129130### Output 1 — Markdown (`[title].md`)131132- Full document with all sections133- Mermaid diagram blocks inline, faithfully reconstructed134- Tables as GFM markdown tables135- Saved to `/mnt/user-data/outputs/`136137### Output 2 — Excel (`[title].xlsx`)138139Use `openpyxl`. Follow `scripts/build_excel.py` pattern:140141- **One sheet per major section** of the document142- Sheet 1 always: "Overview" — title, date, author, section list143- Subsequent sheets: structured tables from each section144- If a section has no tabular data, create a two-column sheet: Field | Value, listing all key info145- Diagrams sheet: text description of each diagram and which Mermaid block it corresponds to146- Professional formatting: Arial font, `#366092` header fill, white header text, thin borders, alternating row fill `#F0F0F0`147- Run `scripts/recalc.py` after saving (copied from xlsx skill)148149### Output 3 — PDF (`[title].pdf`)150151Use `reportlab`. Follow `scripts/build_pdf.py` pattern:152153- Title page: document name, author, date, short abstract154- Table of contents page155- One section per page-break where content is long156- Tables via `reportlab.platypus.Table` with `TableStyle`157- For each diagram: a clearly titled box stating "Diagram: [name] — see Mermaid block in Markdown file" plus a text-art approximation if the diagram is simple enough, otherwise a clean prose description158- Header color: `#366092`, white text; body: Arial 10pt; headings: Arial Bold 12-14pt159- Footer with page numbers and document title160161### Naming Convention162Derive `[title]` from the document's heading or content (snake_case, no spaces).163164---165166## Calling the Scripts167168```python169# After extracting content, build outputs:170import subprocess171172# 1. Generate Excel173subprocess.run(['python', '/home/claude/notes-ocr/scripts/build_excel.py',174 '--data', data_json_path, '--out', output_xlsx_path])175176# 2. Generate PDF177subprocess.run(['python', '/home/claude/notes-ocr/scripts/build_pdf.py',178 '--data', data_json_path, '--out', output_pdf_path])179```180181Or write the scripts inline for the specific document — the script files are reference templates.182183---184185## Output Checklist186187Before presenting files, verify:188189- [ ] Markdown has a ToC190- [ ] Every hand-drawn diagram has a Mermaid block191- [ ] Mermaid topology matches the notes exactly (same nodes, same arrows)192- [ ] All tables from the notes are present in Markdown193- [ ] Excel has one sheet per section, professional formatting194- [ ] PDF has title page, ToC, all sections, proper headers/footers195- [ ] All three files are in `/mnt/user-data/outputs/`196- [ ] `present_files` called with all three paths197198---199200## Reference Scripts201202See `scripts/` directory:203204- `build_excel.py` — reusable Excel builder (openpyxl, professional style)205- `build_pdf.py` — reusable PDF builder (reportlab, professional style)206- `excel_styles.py` — shared style constants for Excel207- `pdf_styles.py` — shared style constants for PDF208209These are **templates** — copy and adapt them for each document's specific sections and tables.210211---212213## Error Handling214215- If handwriting is illegible in a region: insert `[illegible]` placeholder and note it216- If a diagram is ambiguous: reconstruct the most faithful interpretation and add a comment `<!-- Note: diagram reconstructed from ambiguous sketch -->`217- If a page is blank or nearly blank: skip it silently218- If input has no diagrams: still produce all three outputs, just omit the Diagrams sheet from Excel219220---221222## Example Trigger Phrases223224- "turn my handwritten notes into a doc"225- "digitize this PDF scan"226- "convert this image of notes to markdown and excel"227- "OCR this and make it clean"228- "my notes have diagrams, convert them"229- "make a professional document from my scan"230- *(user uploads image/PDF with no explanation — check if it contains handwriting and ask)*