Delphi uses-graph skill
This skill builds a directed graph of uses dependencies between Delphi /
Object Pascal units, computes coupling metrics, and detects circular
dependencies.
OpenAI Responses container note
This OpenAI-adapted bundle is intended to be registered through the OpenAI
Skills API and attached to a Responses shell/container tool as a
skill_reference. The analysis logic is vendor-neutral; the OpenAI-specific
requirement is that the container can run Python and can read the uploaded
Delphi project files.
When to use this skill
- The user uploads an archive (
.zip, .tar, .tar.gz) containing a Delphi
project, or a folder of .pas / .dpr / .dpk sources, and asks for an
architecture map or a dependency graph.
- The user asks "which unit depends on what?", "are there cycles?",
"what's the fan-in / fan-out?" against a Delphi codebase.
- The user wants a visual artifact (Mermaid, SVG, DOT) summarizing unit-level
coupling.
Do not use this skill for non-Pascal codebases.
Inputs
The skill expects exactly one of:
- A
.zip / .tar / .tar.gz archive of a Delphi project.
- A directory already containing
.pas, .dpr, or .dpk files.
If the user pastes raw Pascal source instead, persist it to one or more
temporary .pas files first, then point --input at their parent directory.
Workflow
- Locate the input archive or directory in the working area.
- Run
scripts/tool.py with --input pointing at it and --output pointing
at a fresh output folder.
- Read the generated
report.md and summarize parsed units, fan-in/fan-out,
cycles, and orphan units.
- Attach or surface the generated artifacts: Mermaid, DOT, SVG when present,
JSON, and report. Embed
uses-graph.mmd inline when the conversation
surface supports Mermaid rendering.
Quick start
python scripts/tool.py \
--input /path/to/project.zip \
--output /path/to/out
If the container exposes python3 instead of python, use python3 with the
same arguments.
Useful flags, with full details in reference.md:
--scope {all,interface,implementation} - which uses sections to
consider. Default all.
--ignore-prefix LIST - drop edges whose target starts with one of these
comma-separated prefixes, case-insensitive. Default:
System,Winapi,Vcl,FMX,Data,Web,REST,IdGlobal. Pass "" to keep RTL/VCL.
--max-label N - truncate node labels in the Mermaid output. Default 40.
--include-orphans - keep units that have no inbound and no outbound edges
in the graph.
Outputs
Files written in --output:
| File |
Purpose |
dependencies.json |
Raw graph: { unit: { defined_in, interface_uses, implementation_uses } } |
uses-graph.mmd |
Mermaid graph LR ready to embed in markdown |
uses-graph.dot |
Graphviz DOT source |
uses-graph.svg |
SVG rendering, only when the dot binary is available on PATH |
report.md |
Human-readable summary: counts, hotspots, cycles, orphans |
Notes
- RTL / VCL / FMX targets are filtered by default to keep the diagram readable.
The user's own units are never filtered.
- Cycle detection uses Tarjan's strongly connected components on the directed
graph. Edge
A -> B means A uses B. Self-loops are reported separately.
- Pascal
uses syntax has several edge cases: dotted names, in '<path>'
aliases, conditional defines, and three comment styles. Read reference.md
before changing the parser.
1---2name: delphi-uses-graph3description: Analyzes a Delphi / Object Pascal codebase to extract unit-level `uses` dependencies. Use when the user uploads a zip / archive of a Delphi project, or a folder of .pas / .dpr / .dpk files, and asks for a dependency graph, architecture map, cycle detection, fan-in / fan-out coupling analysis, or wants to know how units relate. Produces a Mermaid diagram, Graphviz DOT, optional SVG, JSON dependency dump, and markdown report.4---56# Delphi uses-graph skill78This skill builds a directed graph of `uses` dependencies between Delphi /9Object Pascal units, computes coupling metrics, and detects circular10dependencies.1112## OpenAI Responses container note1314This OpenAI-adapted bundle is intended to be registered through the OpenAI15Skills API and attached to a Responses shell/container tool as a16`skill_reference`. The analysis logic is vendor-neutral; the OpenAI-specific17requirement is that the container can run Python and can read the uploaded18Delphi project files.1920## When to use this skill2122- The user uploads an archive (`.zip`, `.tar`, `.tar.gz`) containing a Delphi23 project, or a folder of `.pas` / `.dpr` / `.dpk` sources, and asks for an24 architecture map or a dependency graph.25- The user asks "which unit depends on what?", "are there cycles?",26 "what's the fan-in / fan-out?" against a Delphi codebase.27- The user wants a visual artifact (Mermaid, SVG, DOT) summarizing unit-level28 coupling.2930Do not use this skill for non-Pascal codebases.3132## Inputs3334The skill expects exactly one of:35361. A `.zip` / `.tar` / `.tar.gz` archive of a Delphi project.372. A directory already containing `.pas`, `.dpr`, or `.dpk` files.3839If the user pastes raw Pascal source instead, persist it to one or more40temporary `.pas` files first, then point `--input` at their parent directory.4142## Workflow43441. Locate the input archive or directory in the working area.452. Run `scripts/tool.py` with `--input` pointing at it and `--output` pointing46 at a fresh output folder.473. Read the generated `report.md` and summarize parsed units, fan-in/fan-out,48 cycles, and orphan units.494. Attach or surface the generated artifacts: Mermaid, DOT, SVG when present,50 JSON, and report. Embed `uses-graph.mmd` inline when the conversation51 surface supports Mermaid rendering.5253## Quick start5455```bash56python scripts/tool.py \57 --input /path/to/project.zip \58 --output /path/to/out59```6061If the container exposes `python3` instead of `python`, use `python3` with the62same arguments.6364Useful flags, with full details in `reference.md`:6566- `--scope {all,interface,implementation}` - which `uses` sections to67 consider. Default `all`.68- `--ignore-prefix LIST` - drop edges whose target starts with one of these69 comma-separated prefixes, case-insensitive. Default:70 `System,Winapi,Vcl,FMX,Data,Web,REST,IdGlobal`. Pass `""` to keep RTL/VCL.71- `--max-label N` - truncate node labels in the Mermaid output. Default `40`.72- `--include-orphans` - keep units that have no inbound and no outbound edges73 in the graph.7475## Outputs7677Files written in `--output`:7879| File | Purpose |80| --- | --- |81| `dependencies.json` | Raw graph: `{ unit: { defined_in, interface_uses, implementation_uses } }` |82| `uses-graph.mmd` | Mermaid `graph LR` ready to embed in markdown |83| `uses-graph.dot` | Graphviz DOT source |84| `uses-graph.svg` | SVG rendering, only when the `dot` binary is available on `PATH` |85| `report.md` | Human-readable summary: counts, hotspots, cycles, orphans |8687## Notes8889- RTL / VCL / FMX targets are filtered by default to keep the diagram readable.90 The user's own units are never filtered.91- Cycle detection uses Tarjan's strongly connected components on the directed92 graph. Edge `A -> B` means `A uses B`. Self-loops are reported separately.93- Pascal `uses` syntax has several edge cases: dotted names, `in '<path>'`94 aliases, conditional defines, and three comment styles. Read `reference.md`95 before changing the parser.