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.
Available after the catalog security scan passes.
⚠️ Third-Party Software Notice
This skill is third-party open-source software developed and hosted independently on GitHub. SkillsLLM is an informational directory and does not control or maintain the underlying repository.
Any security checks, ratings, or warnings displayed by SkillsLLM are automated and limited in scope. They do not constitute a security certification or guarantee that the software is safe, error-free, or free from malicious code, vulnerabilities, compromised dependencies, or prompt-injection risks.
Review the source code, permissions, dependencies, and configuration before installing or running any third-party skill. Use is at your own risk. To the maximum extent permitted by applicable law, SkillsLLM is not liable for losses arising from third-party software.
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
# 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.
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 |
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, the industry standard for exchanging P&ID data.
skills/pid-to-kg/
SKILL.md workflow Claude follows
references/ extraction procedure, ISA-5.1 guide, symbol guide, ontology, JSON schemas
scripts/ probe, render, hints, build, query, export, eval, crop
scripts/pidkg/ library: models, ISA parsing, builder, loops, QA, storage, summary
docs/ README diagram
tests/ pytest suite with a synthetic two-sheet plant and synthetic PDFs
flow_direction: inferred.pip install -e ".[dev]"
pytest
python skills/pid-to-kg/scripts/build_kg.py --write-schemas # after changing pidkg/models.py
The graph is machine-extracted from drawings. It must be reviewed by a qualified engineer before it is used for design, operations, management of change, or safety studies such as HAZOP or LOPA.
MIT. See LICENSE.
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 100 GitHub stars.
PID-to-Knowledge-Graph's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
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. SkillsLLM 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!