[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75ME20RMTEFF51FD8MB96T8":3,"skill-same:01M75ME20RMTEFF51FD8MB96T8":72},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":13,"repositoryHtmlUrl":55,"repositoryHomepageUrl":56,"ownerHtmlUrl":57,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":58,"install":59,"resources":71},"01M75ME20RMTEFF51FD8MB96T8","document-ingest",null,"Ingest PDF, DOCX, Word, E-Mail (.eml\u002F.msg), Excel, and CSV documents into the\nbrain with text extraction, OCR fallback for scanned PDFs, auto-classification,\nand domain-specific entity extraction (deadlines, amounts, legal references).\nThe universal document pipeline for all verticals (Legal, Tax, Medical, etc.).","Sigmacodeat\u002FSigmabrain","Sigmacodeat","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F220578687?v=4","01M75M8ZBH9439AFP2NTF8K98S","01M75M8ZC680S4377SFWSKP0D1",0,"MIT","https:\u002F\u002Fgithub.com\u002FSigmacodeat\u002FSigmabrain\u002Fblob\u002Fmain\u002Fserver\u002Fskills\u002Fdocument-ingest\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: document-ingest\nversion: 1.0.0\ndescription: |\n  Ingest PDF, DOCX, Word, E-Mail (.eml\u002F.msg), Excel, and CSV documents into the\n  brain with text extraction, OCR fallback for scanned PDFs, auto-classification,\n  and domain-specific entity extraction (deadlines, amounts, legal references).\n  The universal document pipeline for all verticals (Legal, Tax, Medical, etc.).\ntriggers:\n  - \"ingest this document\"\n  - \"process this PDF\"\n  - \"process this Word document\"\n  - \"ingest this contract\"\n  - \"ingest this invoice\"\n  - \"ingest this email\"\n  - \"scanned PDF\"\n  - \"OCR this document\"\n  - \"upload and process\"\n  - \"document to brain\"\n  - \"bulk ingest documents\"\n  - \"import these files\"\ntools:\n  - search\n  - query\n  - get_page\n  - put_page\n  - add_link\n  - add_timeline_entry\n  - file_upload\nmutating: true\nwrites_pages: true\nwrites_to:\n  - documents\u002F\n  - people\u002F\n  - companies\u002F\n  - concepts\u002F\n---\n\n# document-ingest — Universal Document Pipeline\n\n> **Convention:** see [conventions\u002Fquality.md](..\u002Fconventions\u002Fquality.md) for\n> citation rules, back-link enforcement, and exact-phrasing requirements.\n>\n> **Convention:** see [_brain-filing-rules.md](..\u002F_brain-filing-rules.md) for\n> the filing decision protocol.\n\n## Iron Law\n\nEvery document ingested becomes a brain page. The **document page is the source\nof truth**; the original file is preserved for provenance but the brain page is\nwhat the graph, search, and synthesis layers operate on.\n\n- Every person, company, and entity mentioned gets back-linked.\n- Every deadline, amount, or legal reference gets extracted and typed.\n- Scanned PDFs are OCR'd; no document is left behind.\n\n## Supported Formats\n\n| Format | Extension | Extraction Method | OCR Fallback |\n|--------|-----------|-------------------|--------------|\n| **PDF (text-based)** | `.pdf` | `unpdf` text extraction | N\u002FA |\n| **PDF (scanned)** | `.pdf` | `unpdf` (sparse text detected) → `pdf2pic` → vision OCR | GPT-4o-mini |\n| **Word Document** | `.docx`, `.doc` | `mammoth` raw text extraction | N\u002FA |\n| **E-Mail** | `.eml`, `.msg` | `postal-mime` parsing + threading | N\u002FA |\n| **Excel Spreadsheet** | `.xlsx`, `.xls` | `xlsx` → CSV per sheet | N\u002FA |\n| **CSV\u002FTSV** | `.csv`, `.tsv` | Direct text import | N\u002FA |\n\n## When to invoke\n\nThe user uploads or references a document file (PDF, DOCX, E-Mail, Excel, CSV)\nand wants it ingested into the brain. This skill supersedes the generic\n`media-ingest` for document-specific ingestion, offering:\n\n- OCR for scanned PDFs\n- Auto-classification (contract, invoice, letter, court filing, etc.)\n- Domain entity extraction (deadlines, amounts, legal references, ICD codes)\n- Bulk\u002Fmulti-document processing\n\n## The Pipeline\n\n```\n1. UPLOAD       → gbrain files upload-raw \u003Cfile> --page \u003Cslug>\n                  (original preserved for provenance)\n\n2. EXTRACT      → extractDocumentText() via src\u002Fcore\u002Fextract-document.ts\n                  PDF → unpdf, DOCX → mammoth, EML → postal-mime, etc.\n\n3. OCR-FALLBACK → If PDF text layer is sparse (\u003C 32 chars\u002Fpage):\n                  pdf2pic (page-by-page rasterization) → maybeOcr() → GPT-4o-mini\n                  → extracted text merged with native text layer\n\n4. CLASSIFY     → LLM auto-classifies document type:\n                  contract | invoice | letter | court_filing | medical_record\n                  | tax_document | email_thread | report | other\n\n5. EXTRACT      → Domain-specific entity extraction based on classification:\n                  - Legal: deadlines, case_numbers, court, parties, legal_refs\n                  - Tax: invoice_number, amount, tax_id, due_date, vendor\n                  - Medical: patient_id, diagnosis_codes, medications, dates\n                  - Generic: people, companies, amounts, dates, key_terms\n\n6. WRITE        → Create brain page with extracted text + structured frontmatter\n                  + auto-classified type + extracted entities section\n\n7. CROSS-LINK   → For every extracted entity (person, company, deadline,\n                  case, concept), create\u002Fupdate brain page and add back-link\n```\n\n## Phase 1: Upload and Extract\n\n### Single Document\n\n```bash\n# 1. Upload raw file for provenance\nUPLOADED=$(gbrain files upload-raw \"$FILE\" --page \"documents\u002F$(basename \"$FILE\" .pdf)\")\n\n# 2. Extract text (handled by gbrain sync \u002F import-file.ts for synced sources)\n#    Or manually via gbrain put-page with extracted content\n```\n\n### Bulk Documents\n\n```bash\n# Process multiple documents in a directory\nfor f in ~\u002FDocuments\u002Fto-ingest\u002F*.{pdf,docx,eml,xlsx,csv}; do\n  [ -f \"$f\" ] || continue\n  SLUG=\"documents\u002F$(date +%Y-%m-%d)-$(basename \"$f\" | sed 's\u002F[^a-zA-Z0-9]\u002F-\u002Fg')\"\n  gbrain files upload-raw \"$f\" --page \"$SLUG\"\n  # Extraction happens automatically on next sync, or trigger manually:\n  gbrain sync --source documents-uploaded\ndone\n```\n\n## Phase 2: OCR Fallback for Scanned PDFs\n\nWhen `extractDocumentText()` returns `pdf_text_layer_sparse` warning:\n\n**Automatic OCR fallback is now built in.** When `extractDocumentText()` detects a\nsparse text layer (`pdf_text_layer_sparse` warning), the pipeline automatically:\n\n1. Rasterizes PDF pages to PNG images (via `pdf2pic` + `pdftoppm` from Poppler)\n2. Runs vision OCR (GPT-4o-mini) on each page\n3. Combines extracted text with `--- Page N ---` separators\n4. Returns the OCR text as the document body\n\nNo manual intervention required. The only prerequisite is `pdftoppm`:\n- **macOS:** `brew install poppler`\n- **Linux:** `apt-get install poppler-utils`\n- **Windows:** `choco install poppler` or use WSL\n\n> **Note:** The vision OCR call respects `GBRAIN_EMBEDDING_IMAGE_OCR=true`. Without\n> this env var or an available expansion model, the fallback is skipped and the\n> `pdf_text_layer_sparse` warning remains. The model is explicitly instructed NOT to\n> follow embedded instructions in images (prompt-injection mitigation).\n\n## Phase 3: Auto-Classification\n\nAfter text extraction, classify the document. This drives the extraction strategy\nin Phase 4.\n\n```\nLLM Classification Prompt (one-shot, 200 tokens max):\n\"Classify this document into ONE of: contract, invoice, letter, court_filing,\nmedical_record, tax_document, email_thread, report, other.\n\nAlso extract: language (de\u002Fen\u002Ffr), confidentiality (public\u002Finternal\u002Fconfidential),\npage_count_estimate, key_topic (2-3 words).\"\n```\n\nClassification is stored in frontmatter:\n```yaml\n---\ntitle: \"Klageerwiderung Muster GmbH\"\ntype: document\ndocument_type: court_filing\nlanguage: de\nconfidentiality: confidential\nsource_format: pdf\npages: 12\nextracted_date: 2026-06-11\n---\n```\n\n## Phase 4: Domain Entity Extraction\n\nBased on `document_type`, apply the appropriate extraction strategy.\n\n### Legal Documents (`document_type: court_filing | contract | letter`)\n\nExtract and type:\n\n| Entity | Type | Example |\n|--------|------|---------|\n| **Parties** | `LegalActor` | Kläger, Beklagte, Vertreter |\n| **Court** | `Court` | LG München I, 21 O 1234\u002F26 |\n| **Case Number** | `CaseReference` | 21 O 1234\u002F26 |\n| **Deadlines** | `LegalDeadline` | Klageerwiderungsfrist: 14 Tage ab Zustellung |\n| **Legal References** | `LegalReference` | § 433 BGB, § 335 ZPO |\n| **Amounts** | `MonetaryAmount` | Schadensersatz: 50.000 EUR |\n| **Dates** | `EventDate` | Zustelldatum, Verhandlungstermin |\n\nDeadline extraction uses jurisdiction-aware rules:\n- **Germany:** § 187 BGB (Fristbeginn), § 193 BGB (Fristende bei Sonn-\u002FFeiertag)\n- **Austria:** § 904 ABGB (Verjährung), § 1154 ABGB (Fristen)\n- Holidays: automatic exclusion from federal\u002Fstate holiday databases\n\n### Tax Documents (`document_type: tax_document | invoice`)\n\n| Entity | Type | Example |\n|--------|------|---------|\n| **Invoice Number** | `InvoiceNumber` | RE-2026-0042 |\n| **Vendor** | `Company` | Muster GmbH |\n| **Amount Net** | `MonetaryAmount` | 1.000,00 EUR |\n| **Tax Amount** | `MonetaryAmount` | 190,00 EUR |\n| **Tax Rate** | `TaxRate` | 19% MwSt |\n| **Due Date** | `TaxDeadline` | Zahlungsziel: 14 Tage |\n| **Tax ID** | `TaxIdentifier` | DE123456789 |\n\n### Medical Documents (`document_type: medical_record`)\n\n| Entity | Type | Example |\n|--------|------|---------|\n| **Patient ID** | `PatientIdentifier` | (anonymized) |\n| **ICD Codes** | `ICDCode` | ICD-10: J18.9 |\n| **Medications** | `Medication` | Amoxicillin 500mg |\n| **Diagnosis Date** | `EventDate` | 2026-06-01 |\n| **Physician** | `Person` | Dr. Müller |\n| **Facility** | `Company` | Klinikum München |\n\n### Generic Documents\n\n| Entity | Type |\n|--------|------|\n| **People** | `Person` |\n| **Companies** | `Company` |\n| **Concepts** | `Concept` |\n| **Amounts** | `MonetaryAmount` |\n| **Dates** | `EventDate` |\n| **Key Terms** | `Concept` |\n\n## Phase 5: Brain Page Format\n\n```markdown\n---\ntitle: \"{extracted title or filename}\"\ntype: document\ndocument_type: {auto-classified type}\nlanguage: {de\u002Fen\u002Ffr\u002Fetc}\nconfidentiality: {public\u002Finternal\u002Fconfidential}\nsource_format: {pdf\u002Fdocx\u002Feml\u002Fxlsx\u002Fcsv}\npages: {N}\nextracted_date: {YYYY-MM-DD}\nsource_file: {uploaded file hash or path}\n---\n\n# {Title}\n\n**Source:** {original filename or email subject}\n**Format:** {pdf\u002Fdocx\u002Feml\u002Fetc}\n**Classified as:** {document_type}\n**Extracted:** {date}\n\n## Summary\n\n{3-5 sentence summary of the document's purpose and key points}\n\n## Full Text\n\n{extracted document text — paginated or sectioned if long}\n\n## Extracted Entities\n\n### People\n- [{Name}](people\u002F{slug}.md) — {role in document}\n\n### Companies \u002F Organizations\n- [{Name}](companies\u002F{slug}.md) — {role in document}\n\n### Deadlines \u002F Dates\n- **YYYY-MM-DD** | {description} | {legal basis if applicable}\n\n### Amounts\n- {amount} {currency} — {context}\n\n### Legal References\n- {reference} — {context}\n\n### Key Terms \u002F Concepts\n- [{Term}](concepts\u002F{slug}.md)\n\n## Document Timeline\n\n- **YYYY-MM-DD** | {event}: {description}\n```\n\n## Phase 6: Entity Propagation\n\nFor every extracted entity:\n\n1. **Check brain** for existing page (`gbrain get people\u002F{slug}`)\n2. **Create\u002Fenrich** if needed (delegate to `skills\u002Fenrich\u002FSKILL.md`)\n3. **Add back-link** from entity page to this document page\n4. **Add timeline entry** on entity page referencing this document\n\nA document is NOT fully ingested until entity propagation is complete.\n\n## Filing Rules\n\nDocuments are filed under `documents\u002F` by default. Sub-directories based on classification:\n\n| Classification | Directory |\n|----------------|-----------|\n| contract | `documents\u002Fcontracts\u002F` |\n| invoice | `documents\u002Finvoices\u002F` |\n| court_filing | `documents\u002Flegal\u002Fcourt-filings\u002F` |\n| letter | `documents\u002Fcorrespondence\u002F` |\n| email_thread | `documents\u002Fcorrespondence\u002Femails\u002F` |\n| medical_record | `documents\u002Fmedical\u002F` |\n| tax_document | `documents\u002Ftax\u002F` |\n| report | `documents\u002Freports\u002F` |\n| other | `documents\u002Funcategorized\u002F` |\n\n> **Convention:** The primary directory is by document TYPE, not by date or source.\n> Date prefixes (`YYYY-MM-DD-`) are used when multiple documents of the same type\n> exist for the same entity.\n\n## Output Format\n\nReport to user:\n```\nIngested {filename}: {N} pages, {M} entities detected ({X} people, {Y} companies,\n{Z} deadlines), classified as {document_type}. Brain page: documents\u002F{slug}\n```\n\nIf OCR was required:\n```\nIngested {filename}: PDF had no text layer — OCR'd {N} pages, extracted {M} chars.\nClassified as {document_type}. Brain page: documents\u002F{slug}\n```\n\n## Anti-Patterns\n\n- ❌ Skipping scanned PDFs because OCR is \"too slow\" — every document matters\n- ❌ Filing by date instead of by type — `documents\u002F2026\u002F` is a dumping ground\n- ❌ Extracting text without classification — extraction quality depends on type context\n- ❌ Creating stub pages without full text — the brain page must contain the content\n- ❌ Missing back-links for extracted entities — an unlinked entity is a broken graph\n- ❌ Ignoring warnings from `extractDocumentText()` — sparse text layer means OCR needed\n\n## Related Skills\n\n- `skills\u002Fmedia-ingest\u002FSKILL.md` — for video, audio, books, screenshots, repos\n- `skills\u002Fvoice-note-ingest\u002FSKILL.md` — for voice memos and audio notes\n- `skills\u002Fenrich\u002FSKILL.md` — for entity page creation and enrichment\n- `skills\u002Fmeeting-ingestion\u002FSKILL.md` — for meeting transcripts\n- `skills\u002Fcapture\u002FSKILL.md` — for quick thoughts and ideas\n\n## Contract\n\nThis skill guarantees:\n- Every supported document format is extractable (PDF, DOCX, EML, XLSX, CSV, TSV)\n- Scanned PDFs are OCR'd, not silently skipped\n- Every document gets auto-classified\n- Domain-specific entities are extracted based on classification\n- Every entity mention creates a back-link\n- Raw source files are preserved via `gbrain files upload-raw`\n- Filing follows type-based directory structure\n\nThe full behavior contract is documented in the body sections above; this section\nexists for the conformance test.\n","# document-ingest — Universal Document Pipeline\n\n> **Convention:** see [conventions\u002Fquality.md](..\u002Fconventions\u002Fquality.md) for\n> citation rules, back-link enforcement, and exact-phrasing requirements.\n>\n> **Convention:** see [_brain-filing-rules.md](..\u002F_brain-filing-rules.md) for\n> the filing decision protocol.\n\n## Iron Law\n\nEvery document ingested becomes a brain page. The **document page is the source\nof truth**; the original file is preserved for provenance but the brain page is\nwhat the graph, search, and synthesis layers operate on.\n\n- Every person, company, and entity mentioned gets back-linked.\n- Every deadline, amount, or legal reference gets extracted and typed.\n- Scanned PDFs are OCR'd; no document is left behind.\n\n## Supported Formats\n\n| Format | Extension | Extraction Method | OCR Fallback |\n|--------|-----------|-------------------|--------------|\n| **PDF (text-based)** | `.pdf` | `unpdf` text extraction | N\u002FA |\n| **PDF (scanned)** | `.pdf` | `unpdf` (sparse text detected) → `pdf2pic` → vision OCR | GPT-4o-mini |\n| **Word Document** | `.docx`, `.doc` | `mammoth` raw text extraction | N\u002FA |\n| **E-Mail** | `.eml`, `.msg` | `postal-mime` parsing + threading | N\u002FA |\n| **Excel Spreadsheet** | `.xlsx`, `.xls` | `xlsx` → CSV per sheet | N\u002FA |\n| **CSV\u002FTSV** | `.csv`, `.tsv` | Direct text import | N\u002FA |\n\n## When to invoke\n\nThe user uploads or references a document file (PDF, DOCX, E-Mail, Excel, CSV)\nand wants it ingested into the brain. This skill supersedes the generic\n`media-ingest` for document-specific ingestion, offering:\n\n- OCR for scanned PDFs\n- Auto-classification (contract, invoice, letter, court filing, etc.)\n- Domain entity extraction (deadlines, amounts, legal references, ICD codes)\n- Bulk\u002Fmulti-document processing\n\n## The Pipeline\n\n```\n1. UPLOAD       → gbrain files upload-raw \u003Cfile> --page \u003Cslug>\n                  (original preserved for provenance)\n\n2. EXTRACT      → extractDocumentText() via src\u002Fcore\u002Fextract-document.ts\n                  PDF → unpdf, DOCX → mammoth, EML → postal-mime, etc.\n\n3. OCR-FALLBACK → If PDF text layer is sparse (\u003C 32 chars\u002Fpage):\n                  pdf2pic (page-by-page rasterization) → maybeOcr() → GPT-4o-mini\n                  → extracted text merged with native text layer\n\n4. CLASSIFY     → LLM auto-classifies document type:\n                  contract | invoice | letter | court_filing | medical_record\n                  | tax_document | email_thread | report | other\n\n5. EXTRACT      → Domain-specific entity extraction based on classification:\n                  - Legal: deadlines, case_numbers, court, parties, legal_refs\n                  - Tax: invoice_number, amount, tax_id, due_date, vendor\n                  - Medical: patient_id, diagnosis_codes, medications, dates\n                  - Generic: people, companies, amounts, dates, key_terms\n\n6. WRITE        → Create brain page with extracted text + structured frontmatter\n                  + auto-classified type + extracted entities section\n\n7. CROSS-LINK   → For every extracted entity (person, company, deadline,\n                  case, concept), create\u002Fupdate brain page and add back-link\n```\n\n## Phase 1: Upload and Extract\n\n### Single Document\n\n```bash\n# 1. Upload raw file for provenance\nUPLOADED=$(gbrain files upload-raw \"$FILE\" --page \"documents\u002F$(basename \"$FILE\" .pdf)\")\n\n# 2. Extract text (handled by gbrain sync \u002F import-file.ts for synced sources)\n#    Or manually via gbrain put-page with extracted content\n```\n\n### Bulk Documents\n\n```bash\n# Process multiple documents in a directory\nfor f in ~\u002FDocuments\u002Fto-ingest\u002F*.{pdf,docx,eml,xlsx,csv}; do\n  [ -f \"$f\" ] || continue\n  SLUG=\"documents\u002F$(date +%Y-%m-%d)-$(basename \"$f\" | sed 's\u002F[^a-zA-Z0-9]\u002F-\u002Fg')\"\n  gbrain files upload-raw \"$f\" --page \"$SLUG\"\n  # Extraction happens automatically on next sync, or trigger manually:\n  gbrain sync --source documents-uploaded\ndone\n```\n\n## Phase 2: OCR Fallback for Scanned PDFs\n\nWhen `extractDocumentText()` returns `pdf_text_layer_sparse` warning:\n\n**Automatic OCR fallback is now built in.** When `extractDocumentText()` detects a\nsparse text layer (`pdf_text_layer_sparse` warning), the pipeline automatically:\n\n1. Rasterizes PDF pages to PNG images (via `pdf2pic` + `pdftoppm` from Poppler)\n2. Runs vision OCR (GPT-4o-mini) on each page\n3. Combines extracted text with `--- Page N ---` separators\n4. Returns the OCR text as the document body\n\nNo manual intervention required. The only prerequisite is `pdftoppm`:\n- **macOS:** `brew install poppler`\n- **Linux:** `apt-get install poppler-utils`\n- **Windows:** `choco install poppler` or use WSL\n\n> **Note:** The vision OCR call respects `GBRAIN_EMBEDDING_IMAGE_OCR=true`. Without\n> this env var or an available expansion model, the fallback is skipped and the\n> `pdf_text_layer_sparse` warning remains. The model is explicitly instructed NOT to\n> follow embedded instructions in images (prompt-injection mitigation).\n\n## Phase 3: Auto-Classification\n\nAfter text extraction, classify the document. This drives the extraction strategy\nin Phase 4.\n\n```\nLLM Classification Prompt (one-shot, 200 tokens max):\n\"Classify this document into ONE of: contract, invoice, letter, court_filing,\nmedical_record, tax_document, email_thread, report, other.\n\nAlso extract: language (de\u002Fen\u002Ffr), confidentiality (public\u002Finternal\u002Fconfidential),\npage_count_estimate, key_topic (2-3 words).\"\n```\n\nClassification is stored in frontmatter:\n```yaml\n---\ntitle: \"Klageerwiderung Muster GmbH\"\ntype: document\ndocument_type: court_filing\nlanguage: de\nconfidentiality: confidential\nsource_format: pdf\npages: 12\nextracted_date: 2026-06-11\n---\n```\n\n## Phase 4: Domain Entity Extraction\n\nBased on `document_type`, apply the appropriate extraction strategy.\n\n### Legal Documents (`document_type: court_filing | contract | letter`)\n\nExtract and type:\n\n| Entity | Type | Example |\n|--------|------|---------|\n| **Parties** | `LegalActor` | Kläger, Beklagte, Vertreter |\n| **Court** | `Court` | LG München I, 21 O 1234\u002F26 |\n| **Case Number** | `CaseReference` | 21 O 1234\u002F26 |\n| **Deadlines** | `LegalDeadline` | Klageerwiderungsfrist: 14 Tage ab Zustellung |\n| **Legal References** | `LegalReference` | § 433 BGB, § 335 ZPO |\n| **Amounts** | `MonetaryAmount` | Schadensersatz: 50.000 EUR |\n| **Dates** | `EventDate` | Zustelldatum, Verhandlungstermin |\n\nDeadline extraction uses jurisdiction-aware rules:\n- **Germany:** § 187 BGB (Fristbeginn), § 193 BGB (Fristende bei Sonn-\u002FFeiertag)\n- **Austria:** § 904 ABGB (Verjährung), § 1154 ABGB (Fristen)\n- Holidays: automatic exclusion from federal\u002Fstate holiday databases\n\n### Tax Documents (`document_type: tax_document | invoice`)\n\n| Entity | Type | Example |\n|--------|------|---------|\n| **Invoice Number** | `InvoiceNumber` | RE-2026-0042 |\n| **Vendor** | `Company` | Muster GmbH |\n| **Amount Net** | `MonetaryAmount` | 1.000,00 EUR |\n| **Tax Amount** | `MonetaryAmount` | 190,00 EUR |\n| **Tax Rate** | `TaxRate` | 19% MwSt |\n| **Due Date** | `TaxDeadline` | Zahlungsziel: 14 Tage |\n| **Tax ID** | `TaxIdentifier` | DE123456789 |\n\n### Medical Documents (`document_type: medical_record`)\n\n| Entity | Type | Example |\n|--------|------|---------|\n| **Patient ID** | `PatientIdentifier` | (anonymized) |\n| **ICD Codes** | `ICDCode` | ICD-10: J18.9 |\n| **Medications** | `Medication` | Amoxicillin 500mg |\n| **Diagnosis Date** | `EventDate` | 2026-06-01 |\n| **Physician** | `Person` | Dr. Müller |\n| **Facility** | `Company` | Klinikum München |\n\n### Generic Documents\n\n| Entity | Type |\n|--------|------|\n| **People** | `Person` |\n| **Companies** | `Company` |\n| **Concepts** | `Concept` |\n| **Amounts** | `MonetaryAmount` |\n| **Dates** | `EventDate` |\n| **Key Terms** | `Concept` |\n\n## Phase 5: Brain Page Format\n\n```markdown\n---\ntitle: \"{extracted title or filename}\"\ntype: document\ndocument_type: {auto-classified type}\nlanguage: {de\u002Fen\u002Ffr\u002Fetc}\nconfidentiality: {public\u002Finternal\u002Fconfidential}\nsource_format: {pdf\u002Fdocx\u002Feml\u002Fxlsx\u002Fcsv}\npages: {N}\nextracted_date: {YYYY-MM-DD}\nsource_file: {uploaded file hash or path}\n---\n\n# {Title}\n\n**Source:** {original filename or email subject}\n**Format:** {pdf\u002Fdocx\u002Feml\u002Fetc}\n**Classified as:** {document_type}\n**Extracted:** {date}\n\n## Summary\n\n{3-5 sentence summary of the document's purpose and key points}\n\n## Full Text\n\n{extracted document text — paginated or sectioned if long}\n\n## Extracted Entities\n\n### People\n- [{Name}](people\u002F{slug}.md) — {role in document}\n\n### Companies \u002F Organizations\n- [{Name}](companies\u002F{slug}.md) — {role in document}\n\n### Deadlines \u002F Dates\n- **YYYY-MM-DD** | {description} | {legal basis if applicable}\n\n### Amounts\n- {amount} {currency} — {context}\n\n### Legal References\n- {reference} — {context}\n\n### Key Terms \u002F Concepts\n- [{Term}](concepts\u002F{slug}.md)\n\n## Document Timeline\n\n- **YYYY-MM-DD** | {event}: {description}\n```\n\n## Phase 6: Entity Propagation\n\nFor every extracted entity:\n\n1. **Check brain** for existing page (`gbrain get people\u002F{slug}`)\n2. **Create\u002Fenrich** if needed (delegate to `skills\u002Fenrich\u002FSKILL.md`)\n3. **Add back-link** from entity page to this document page\n4. **Add timeline entry** on entity page referencing this document\n\nA document is NOT fully ingested until entity propagation is complete.\n\n## Filing Rules\n\nDocuments are filed under `documents\u002F` by default. Sub-directories based on classification:\n\n| Classification | Directory |\n|----------------|-----------|\n| contract | `documents\u002Fcontracts\u002F` |\n| invoice | `documents\u002Finvoices\u002F` |\n| court_filing | `documents\u002Flegal\u002Fcourt-filings\u002F` |\n| letter | `documents\u002Fcorrespondence\u002F` |\n| email_thread | `documents\u002Fcorrespondence\u002Femails\u002F` |\n| medical_record | `documents\u002Fmedical\u002F` |\n| tax_document | `documents\u002Ftax\u002F` |\n| report | `documents\u002Freports\u002F` |\n| other | `documents\u002Funcategorized\u002F` |\n\n> **Convention:** The primary directory is by document TYPE, not by date or source.\n> Date prefixes (`YYYY-MM-DD-`) are used when multiple documents of the same type\n> exist for the same entity.\n\n## Output Format\n\nReport to user:\n```\nIngested {filename}: {N} pages, {M} entities detected ({X} people, {Y} companies,\n{Z} deadlines), classified as {document_type}. Brain page: documents\u002F{slug}\n```\n\nIf OCR was required:\n```\nIngested {filename}: PDF had no text layer — OCR'd {N} pages, extracted {M} chars.\nClassified as {document_type}. Brain page: documents\u002F{slug}\n```\n\n## Anti-Patterns\n\n- ❌ Skipping scanned PDFs because OCR is \"too slow\" — every document matters\n- ❌ Filing by date instead of by type — `documents\u002F2026\u002F` is a dumping ground\n- ❌ Extracting text without classification — extraction quality depends on type context\n- ❌ Creating stub pages without full text — the brain page must contain the content\n- ❌ Missing back-links for extracted entities — an unlinked entity is a broken graph\n- ❌ Ignoring warnings from `extractDocumentText()` — sparse text layer means OCR needed\n\n## Related Skills\n\n- `skills\u002Fmedia-ingest\u002FSKILL.md` — for video, audio, books, screenshots, repos\n- `skills\u002Fvoice-note-ingest\u002FSKILL.md` — for voice memos and audio notes\n- `skills\u002Fenrich\u002FSKILL.md` — for entity page creation and enrichment\n- `skills\u002Fmeeting-ingestion\u002FSKILL.md` — for meeting transcripts\n- `skills\u002Fcapture\u002FSKILL.md` — for quick thoughts and ideas\n\n## Contract\n\nThis skill guarantees:\n- Every supported document format is extractable (PDF, DOCX, EML, XLSX, CSV, TSV)\n- Scanned PDFs are OCR'd, not silently skipped\n- Every document gets auto-classified\n- Domain-specific entities are extracted based on classification\n- Every entity mention creates a back-link\n- Raw source files are preserved via `gbrain files upload-raw`\n- Filing follows type-based directory structure\n\nThe full behavior contract is documented in the body sections above; this section\nexists for the conformance test.\n",{"name":5,"tools":23,"version":31,"mutating":32,"triggers":33,"writes_to":46,"description":51,"writes_pages":32},[24,25,26,27,28,29,30],"search","query","get_page","put_page","add_link","add_timeline_entry","file_upload","1.0.0",true,[34,35,36,37,38,39,40,41,42,43,44,45],"ingest this document","process this PDF","process this Word document","ingest this contract","ingest this invoice","ingest this email","scanned PDF","OCR this document","upload and process","document to brain","bulk ingest documents","import these files",[47,48,49,50],"documents\u002F","people\u002F","companies\u002F","concepts\u002F","Ingest PDF, DOCX, Word, E-Mail (.eml\u002F.msg), Excel, and CSV documents into the\nbrain with text extraction, OCR fallback for scanned PDFs, auto-classification,\nand domain-specific entity extraction (deadlines, amounts, legal references).\nThe universal document pipeline for all verticals (Legal, Tax, Medical, etc.).\n","main","b8e699fc7cff8641b94a51ac9d4aa599fcc03ae5","server\u002Fskills\u002Fdocument-ingest","https:\u002F\u002Fgithub.com\u002FSigmacodeat\u002FSigmabrain","https:\u002F\u002Fsigmabrain.vercel.app","https:\u002F\u002Fgithub.com\u002FSigmacodeat","2026-07-09 09:21:55",{"source":8,"skillName":5,"commands":60,"prompt":70,"zipAvailable":32},[61,64,67],{"tool":62,"command":63},"npx","npx skills add Sigmacodeat\u002FSigmabrain --skill document-ingest",{"tool":65,"command":66},"bunx","bunx skills add Sigmacodeat\u002FSigmabrain --skill document-ingest",{"tool":68,"command":69},"pnpm","pnpm dlx skills add Sigmacodeat\u002FSigmabrain --skill document-ingest","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSigmacodeat\u002FSigmabrain\u002Fblob\u002Fmain\u002Fserver\u002Fskills\u002Fdocument-ingest\u002FSKILL.md",[],[73,79,85,92,99,105],{"skillNo":74,"name":75,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":18},"01M75MW3405DES0348DPKVF20G","query-helper","https:\u002F\u002Fgithub.com\u002FSigmacodeat\u002FSigmabrain\u002Fblob\u002Fmain\u002Fserver\u002Ftest\u002Ffixtures\u002Fskill-catalog\u002Fskills\u002Fquery-helper\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":18},"01M75MW29T3N856QPT2SK467A3","broken","https:\u002F\u002Fgithub.com\u002FSigmacodeat\u002FSigmabrain\u002Fblob\u002Fmain\u002Fserver\u002Ftest\u002Ffixtures\u002Fskill-catalog\u002Fskills\u002Fbroken\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":18},"01M75MVZV51CX9W3Y602M0GJR9","brain-ops","Read, enrich, and write brain pages with source attribution.","https:\u002F\u002Fgithub.com\u002FSigmacodeat\u002FSigmabrain\u002Fblob\u002Fmain\u002Fserver\u002Ftest\u002Ffixtures\u002Fskill-catalog\u002Fskills\u002Fbrain-ops\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":18},"01M75MVXQAQBVNQBZPKPEBPRHV","signal-detector","Always-on ambient signal capture for the OpenClaw reference fixture.","https:\u002F\u002Fgithub.com\u002FSigmacodeat\u002FSigmabrain\u002Fblob\u002Fmain\u002Fserver\u002Ftest\u002Ffixtures\u002Fopenclaw-reference-minimal\u002Fskills\u002Fsignal-detector\u002FSKILL.md",[],[],{"skillNo":100,"name":25,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":18},"01M75MVWJN0EV5EFW6JMMC73XC","Look up brain pages in the OpenClaw reference fixture.","https:\u002F\u002Fgithub.com\u002FSigmacodeat\u002FSigmabrain\u002Fblob\u002Fmain\u002Fserver\u002Ftest\u002Ffixtures\u002Fopenclaw-reference-minimal\u002Fskills\u002Fquery\u002FSKILL.md",[],[],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":18},"01M75MVVA7Q6PMDBTPQGT49M6M","context-now","ALWAYS-ON time-sensitivity discipline for the OpenClaw reference fixture.","https:\u002F\u002Fgithub.com\u002FSigmacodeat\u002FSigmabrain\u002Fblob\u002Fmain\u002Fserver\u002Ftest\u002Ffixtures\u002Fopenclaw-reference-minimal\u002Fskills\u002Fcontext-now\u002FSKILL.md",[],[]]