P&ID to Knowledge Graph: a Claude skill that turns P&ID PDFs (digital or scanned) into a process knowledge graph of flow, instruments and control loops.
# Add to your Claude Code skills
git clone https://github.com/ScottDuncanAI/PID-to-Knowledge-GraphGuides for using ai agents skills like PID-to-Knowledge-Graph.
Last scanned: 11/29/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-11-29T14:17:10.561Z",
"npmAuditRan": true,
"pipAuditRan": true,
"promptInjectionRan": true
}PID-to-Knowledge-Graph is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by ScottDuncanAI. P&ID to Knowledge Graph: a Claude skill that turns P&ID PDFs (digital or scanned) into a process knowledge graph of flow, instruments and control loops. It has 478 GitHub stars.
Yes. PID-to-Knowledge-Graph passed AgentsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.
Clone the repository with "git clone https://github.com/ScottDuncanAI/PID-to-Knowledge-Graph" and add it to your Claude Code skills directory (see the Installation section above).
PID-to-Knowledge-Graph is primarily written in Python. It is open-source under ScottDuncanAI on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh PID-to-Knowledge-Graph against similar tools.
No comments yet. Be the first to share your thoughts!
By Scott Duncan. Reach me on LinkedIn or at scottduncanai.com.
Turn P&ID drawings into a process knowledge graph that an LLM can reason over.
pid-to-kg is a Claude skill that reads piping and instrumentation diagrams (P&IDs) and PFDs from PDF and builds a knowledge graph of the process. The PDFs can be digital (exported from CAD) or scanned. The graph captures:
The output is meant to be one layer of a chemical-manufacturing context layer. An LLM application can query it to answer questions such as "what feeds this clarifier?", "which transmitters sit downstream of P-101?" or "what does FIC-0502 manipulate?" from the drawings themselves.
No programming is needed. You need Claude Code (the desktop app or the terminal version) and Python 3.10 or newer. Python 3.12 is the best choice: on 3.13 and later the skill still works, but without the text-recognition (OCR) cross-check and automatic page orientation.
1. Download the skill. On this page, click the green Code button, then Download ZIP. Unzip the file.
2. Install it. In the unzipped folder, open skills and copy the pid-to-kg folder into your personal Claude skills folder:
| System | Skills folder |
|---|---|
| Windows | C:\Users\<your user name>\.claude\skills\ |
| macOS | /Users/<your user name>/.claude/skills/ |
If the skills folder doesn't exist yet, create it. The .claude folder is hidden by default: in Windows File Explorer use View → Show → Hidden items, and in macOS Finder press Cmd + Shift + . to show it.
3. Add your P&IDs. Make a new folder for the project and put your P&ID PDF in it. Open that folder in Claude Code: in the desktop app, start a new Code session and choose the folder.
No P&IDs at hand? My public chemical manufacturing datasets repo lists public P&ID sets from real permitted facilities, with the page numbers where the drawings are. Both digital and scanned sets are included.
4. Ask Claude to convert them. For example:
Convert
haile.pdfinto a knowledge graph. The P&IDs are on pages 47–60.
The skill loads by itself; there is no need to name it. The first time, Claude installs the Python packages it needs, and it asks your permission before running commands. It then reads every sheet in detail, so a large drawing set takes a while. Claude may ask a question along the way, such as which revision to use when a PDF holds two versions of the same drawing. When it is done, it reports what it found and what remains uncertain.
5. Check the graph by asking questions. The best test is to ask about things you can verify on the drawings:
Name all the equipment upstream of the clarifier.
What sensor measures the flow into TK-101, and where exactly is it?
What does FIC-0502 control, and what valve does it move?
The results are saved in work/<plant name>/kg/ inside your project folder. summary.md is a readable overview of the whole plant, and qa_report.md lists anything Claude could not confirm.
Claude reads the drawings; Python scripts do everything else. Recognising symbols and tracing lines needs visual judgement, so that part is Claude's. Preparing pages, building the graph and checking it are routine, so tested scripts do them the same way every time.
A script first looks at every page and works out what kind of drawing it is. Digital and scanned P&IDs need different handling:
| Page type | How to recognise it | What the skill does |
|---|---|---|
| Digital, searchable text | Exported from CAD; you can select the text in a PDF viewer | Renders the page straight from the vector data, so lines stay sharp at any zoom. The exact text in the PDF is used to cross-check the tags Claude reads. |
| Digital, outlined text | Looks digital, but the text can't be selected: every letter was drawn as shapes. Common in CAD exports. | Renders from the vector data at high resolution. Since there is no text to pull out, OCR (text recognition) reads the tags for the cross-check. |
| Scanned | Each page is a picture of a paper drawing | Takes the scanned image at its original resolution, enlarges it up to 2.5×, and boosts the contrast so faded lines and small text stand out. OCR reads the tags for the cross-check. Low-resolution scans are flagged, because small text may be lost. |
| Scanned with OCR text | A scan with a searchable text layer added | Handled like a scan. The added text layer is only used as a hint, since it often contains errors. |
Then, for every page:
The scripts turn Claude's readings into one connected knowledge graph:
A QA report then lists anything doubtful: a sensor with no location, an off-page connector with no partner, a tag OCR saw that Claude didn't record. Claude re-checks each one on the drawing and rebuilds until the report is clean.
summary.md is a readable overview to give an LLM as context.graph.json holds the full graph for any tool to read.graph.duckdb is a small database file for precise queries. Nothing needs a server.| File | What it is |
|---|---|
summary.md |
A readable overview of the plant: equipment-level flow, equipment, instruments with their locations, control loops and off-page links. This is the file to give an LLM as context. |
qa_report.md |
Errors, warnings and notes, each pointing to the part of the drawing to re-check |
graph.json |
The complete graph (schema: graph.schema.json) |
graph.duckdb |
The same graph as a DuckDB database file, for SQL queries, including recursive upstream and downstream searches |
graph.dexpi.xml |
The plant in DEXPI 2.0.1 native XML, the industry standard for exchanging P&ID data. It is checked against the official schema and the DEXPI model, and written only if it passes |
dexpi_export_report.md |
The DEXPI validation result, and every item DEXPI could not represent or that had to be added to fit its model |
All six files are produced by every conversion; there is nothing extra to ask for.
About the DEXPI file. It carries equipment, piping connectivity, valves, instruments, signals and control loops. It has no drawing graphics, so CAD tools will not redraw it as a P&ID. DEXPI connects pipes to nozzles, and drawings rarely number nozzles, so the exporter adds nozzles (and tees where lines join) and lists each one in the report. Facts DEXPI has no place for, such as interlock meaning, cascade roles, drawing sheets and confidence scores, stay in graph.json and are listed in the report. If the file ever fails validation, no graph.dexpi.xml is left in the folder, so an outdated copy cannot be mistaken for the current build.
For larger projects, the graph can also be exported to Neo4j or to GraphML (for yEd, Gephi or NetworkX). Ask Claude to do it.
The node and edge types are described in references/ontology.md. Equipment and instruments also carry the closest DEXPI class in dexpi_class, unchanged from earlier versions.
skills/pid-to-kg/
SKILL.md workflow Claude follows
references/ extraction procedure, ISA-5.1 guide, symbol guide, ontology, JSON schemas
references/dexpi/2.0.1/ official DEXPI schema and model files, used offline for validation
scripts/ probe, render, hints, build, query, export, eval, crop
scripts/pidkg/ library: models, ISA parsing, builder, loops, QA, storage, summary
scripts/pidkg/dexpi/ DEXPI mapping, XML writer, validator and export report
docs/ README diagram
tests/ pytest suite with a synthetic two-sheet plant and synthetic PDFs