/document-chunker:document-chunkerfrom document-chunker
Use this skill when the task involves processing large files or document sets with Codex as the AI coworker: document ingestion, file inventory, parsing, chunking, structured extraction, embeddings preparation, retrieval QA, SEC/Form D processing, HypeStake knowledge ingestion, or auditing .chunks.jsonl outputs. All AI interpretation must be performed by Codex, not by bundled scripts.
Ships in document-chunker. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill turns Codex into an advanced document-processing coworker.
The key rule: all AI processing happens inside Codex. Helper scripts are deterministic utilities for reading files, creating inventories, converting simple formats to text, slicing large text into stable packets, merging Codex-produced JSON, auditing artifacts, and running lexical retrieval canaries. They must not call LLM, embedding, rerank, OCR, or search APIs unless the user explicitly asks and the host repo already provides an approved path.
ai-knowledge, reference documents, Company Analysis, Portfolio Analysis, market intel, deal/finance/valuation, creator genome, and RAG artifacts..chunks.jsonl, embedding-input, vector payload, or retrieval output audits.Do not use this skill for ordinary code edits that do not touch document processing or RAG.
embedding_inputs.jsonl; it does not require embeddings to decide primary chunking boundaries for structured documents.display_text for citations, retrieval_text for search, and structured_facts for exact queries.When the user gives files/folders, execute this sequence unless the repo already has a stronger process.
Create a run brief before scripts:
Run goal:
Input paths:
Output path:
Document classes expected:
High-trust domains involved:
Schemas to produce:
AI work will be done by Codex:
Scripts may do only deterministic processing:
Approval gates:
Done means:
Use Python to inspect the filesystem without loading everything into context:
python scripts/python/doc_cowork.py inventory --input <input> --out <out>/00_inventory
Read the resulting inventory.md, file_inventory.csv, and file_inventory.json. Classify files by size, type, likely parser, risk, and processing order.
python scripts/python/doc_cowork.py to-text --input <input> --out <out>/01_text
This handles text-like files, JSON/JSONL, CSV, XML, HTML cleanup, and DOCX text extraction using Python stdlib. For PDFs and image-heavy files, use project-approved tools if available, or ask the user for converted text/Markdown when the environment cannot convert safely.
python scripts/python/doc_cowork.py slice --input <out>/01_text --out <out>/02_slices --target-chars 12000 --overlap-chars 600
python scripts/python/doc_cowork.py packets --slices <out>/02_slices/slices.jsonl --out <out>/03_packets --packet-size 4 --profile general_rag
Packet files are Markdown work orders for Codex. Each packet includes source paths, ranges, hashes, and strict output schema.
Codex reads packet Markdown files and writes JSON results to <out>/04_ai_results/.
For small jobs, the main Codex agent can process packets sequentially.
For large jobs, ask Codex to spawn subagents or use CSV fan-out if available. Use the project-scoped agent templates in templates/project-codex/.codex/agents/ when you want dedicated document agents.
Each packet result must be valid JSON matching the schema in references/output-schemas.md.
python scripts/python/doc_cowork.py merge-ai --input <out>/04_ai_results --out <out>/05_merged
This script validates that JSON can be parsed, deduplicates stable IDs, emits structured_facts.jsonl, parent_chunks.jsonl, atomic_chunks.jsonl, embedding_inputs.jsonl, and a merge report. If JSON is malformed, Codex fixes the exact offending packet result.
python scripts/python/doc_cowork.py audit-jsonl --input <out>/05_merged --out <out>/06_audit
python scripts/python/doc_cowork.py canary --chunks <out>/05_merged --queries <queries.json> --out <out>/07_canary
Canaries should include known exact questions and known semantic questions. A run is not healthy until the right parent and child chunks are retrieved.
The final handoff must include:
All paths below are relative to the installed skill folder.
# Inspect files and produce inventory JSON/CSV/Markdown.
python scripts/python/doc_cowork.py inventory --input ./incoming --out ./out/00_inventory
# Convert supported text-like files to normalized .txt records.
python scripts/python/doc_cowork.py to-text --input ./incoming --out ./out/01_text
# Slice converted text into stable windows.
python scripts/python/doc_cowork.py slice --input ./out/01_text --out ./out/02_slices --target-chars 12000 --overlap-chars 600
# Generate Markdown packet work orders for Codex.
python scripts/python/doc_cowork.py packets --slices ./out/02_slices/slices.jsonl --out ./out/03_packets --packet-size 4 --profile sec_form_d
# Merge Codex-produced packet JSON files.
python scripts/python/doc_cowork.py merge-ai --input ./out/04_ai_results --out ./out/05_merged
# Audit chunks and JSONL artifacts.
python scripts/python/doc_cowork.py audit-jsonl --input ./out/05_merged --out ./out/06_audit
# Run lexical canary retrieval.
python scripts/python/doc_cowork.py canary --chunks ./out/05_merged --queries ./examples/form-d-canaries.json --out ./out/07_canary
# Redact obvious secrets/PII before packetization when needed.
python scripts/python/doc_cowork.py redact --input ./incoming --out ./out/redacted
Do not ask Codex to read the full file at once. Use this loop:
Use hash/range locators to keep source traceability:
{
"source_path": "...",
"char_start": 12000,
"char_end": 24000,
"sha256_16": "a1b2c3d4e5f6...",
"source_locator": "file#char=12000-24000"
}
Produce these artifacts where possible:
manifest.json
run_report.md
documents.jsonl
structured_facts.jsonl
parent_chunks.jsonl
atomic_chunks.jsonl
embedding_inputs.jsonl
quality_report.json
retrieval_canary_report.json
human_review_queue.jsonl
{
"document_id": "doc_...",
"source_path": "...",
"source_uri": "...",
"source_type": "sec_form_d_xml|pdf_text|docx_text|markdown|csv|json|html|unknown",
"title": "...",
"document_date": "YYYY-MM-DD|null",
"source_hash": "sha256...",
"canonical_metadata": {},
"debug_metadata": {}
}
{
"fact_id": "fact_...",
"document_id": "doc_...",
"fact_type": "sec_form_d.sales_amount|company_metric|legal_term|route_inventory|custom",
"name": "amount_sold",
"raw_value": "$230,958",
"normalized_value": 230958,
"unit": "USD",
"source_locator": {
"source_path": "...",
"section": "Offering sales amounts",
"char_start": 123,
"char_end": 456
},
"confidence": "high|medium|low",
"needs_review": false
}
{
"chunk_id": "chunk_parent_...",
"document_id": "doc_...",
"chunk_type": "parent_summary",
"display_text": "...",
"retrieval_text": "...",
"child_chunk_ids": [],
"canonical_metadata": {},
"quality_flags": []
}
{
"chunk_id": "chunk_atomic_...",
"document_id": "doc_...",
"parent_chunk_id": "chunk_parent_...",
"chunk_type": "atomic_section|atomic_table|atomic_text",
"section": "...",
"sections": ["..."] ,
"heading_path": ["..."],
"display_text": "...",
"retrieval_text": "...",
"source_locator": {},
"canonical_metadata": {},
"quality_flags": []
}
{
"embedding_input_id": "embin_...",
"chunk_id": "chunk_...",
"document_id": "doc_...",
"embedding_text": "Document: ...\nSection: ...\nFacts: ...",
"embedding_text_hash": "sha256...",
"embedding_profile": {
"intended_model": "cohere.embed-v4:0|local-bge|repo-default",
"dimensions": null,
"created_by": "codex-document-chunker"
},
"metadata_minimal": {}
}
For SEC Form D / Form D/A:
06b to Rule 506(b) and 3C.1 to Section 3(c)(1) while preserving raw source values.Use of proceeds and Signature unless the source truly binds them together. If combined, use sections: ["USE_OF_PROCEEDS", "SIGNATURE"].has_non_accredited_investors = Yes with count 0.Activate this mode when the repo/files are HypeStake-related.
/creator/*; Brand Hub uses /company/*; older /finance, /influencer/*, and /startup/* paths are often legacy/compatibility unless live code proves otherwise.ai-knowledge, reference_documents, ai_outputs, ai_output_chunks, or the host repo's existing ingestion path only after schema verification.Block or quarantine artifacts with:
document_id, chunk_id, source_path, or source_locator.retrieval_text identical to contextless display tables.Warn on:
For a completed run, respond with:
Done: [what was produced]
Inputs processed: [counts]
Artifacts: [paths]
Quality result: [pass/warn/fail]
Important warnings: [top issues]
Commands run: [exact commands]
Next best step: [one concrete step]
If the run cannot complete, say exactly what failed, what evidence was collected, and the next command/prompt to continue.
assets/schemas/chunk-record.schema.json (opens in a new tab)assets/schemas/packet-result.schema.json (opens in a new tab)assets/schemas/structured-fact.schema.json (opens in a new tab)references/codex-prompts.md (opens in a new tab)references/cowork-operating-manual.md (opens in a new tab)references/embedding-and-retrieval.md (opens in a new tab)references/hypestake-integration.md (opens in a new tab)references/large-file-protocol.md (opens in a new tab)references/output-schemas.md (opens in a new tab)references/quality-gates.md (opens in a new tab)references/sec-form-d-playbook.md (opens in a new tab)scripts/python/doc_cowork.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub andrewr303/claude-codex-plugin-lab --plugin document-chunker