# nillab-agi/skillguard architecture

> Architecture diagram of the GitHub repository nillab-agi/skillguard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nillab-agi/skillguard
- Repository: https://github.com/nillab-agi/skillguard

## Overview

SkillGuard is a static security scanner for AI-agent skills. A user submits a directory, Markdown file, ZIP, or Git reference; SkillGuard resolves it, builds a shared scan context, runs security analyzers, filters and scores findings, and renders a report. The graph follows the documented scan flow and includes optional baseline, model-review, and OSV capabilities. Some analyzer internals are unsampled, so their connections are limited to relationships documented in the README or visible in the source index.

Main entry points: [`src/skillguard/graph.py`](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/graph.py) (Scan graph), [`src/skillguard/nodes/analyzers`](https://github.com/nillab-agi/skillguard/tree/main/src/skillguard/nodes/analyzers) (Security analyzers), [`src/skillguard/nodes/analyzers/supply_chain_dependencies.py`](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/analyzers/supply_chain_dependencies.py) (Supply-chain checks), [`src/skillguard/nodes/report.py`](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/report.py) (Report assembly)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Scan entry"]
  node_cli["CLI commands<br/>[cli.py]"]
  node_pipeline["Scan pipeline<br/>[pipeline.py]"]
  node_graph["Scan graph<br/>[graph.py]"]
end

subgraph group_context["Input context"]
  node_input["Input resolver<br/>[input_handler.py]"]
  node_resolve["Resolve stage<br/>[resolve_input.py]"]
  node_context_builder["Context builder<br/>[build_context.py]"]
  node_discovery["Skill discovery<br/>[discovery.py]"]
  node_state["Shared scan state<br/>[state.py]"]
end

subgraph group_analysis["Security analysis"]
  node_analyzers["Security analyzers"]
  node_ast["Python AST checks<br/>[behavioral_ast.py]"]
  node_mcp["MCP checks"]
  node_patterns["Static pattern checks<br/>[static_runner.py]"]
  node_supply["Supply-chain checks"]
  node_dependencies["Dependency parsing<br/>[dependencies.py]"]
  node_osv["OSV vulnerability lookup<br/>[osv.py]"]
end

subgraph group_assessment["Assessment"]
  node_dedup["Finding deduplication<br/>[deduplicate.py]"]
  node_baseline["Baseline filtering<br/>[apply_baseline.py]"]
  node_baseline_data["Baseline rules<br/>[baseline.py]"]
  node_meta["Model review<br/>[meta_analyzer.py]"]
  node_provider["Model provider<br/>[openai_compat.py]"]
  node_score["Risk scoring<br/>[score.py]"]
end

subgraph group_output["Reports"]
  node_report["Report assembly<br/>[report.py]"]
  node_terminal["Terminal report<br/>[terminal.py]"]
  node_formats["JSON Markdown SARIF"]
end

node_user(("Scan user"))
node_osv_service(("osv.dev"))

node_user -->|"submits scan"| node_cli
node_cli -->|"starts scan"| node_pipeline
node_pipeline -->|"invokes graph"| node_graph
node_graph -->|"dispatches"| node_resolve
node_resolve -->|"resolves reference"| node_input
node_graph -->|"dispatches"| node_context_builder
node_context_builder -->|"discovers files"| node_discovery
node_graph -->|"runs in parallel"| node_analyzers
node_analyzers -->|"appends findings"| node_state
node_analyzers -->|"includes"| node_ast
node_analyzers -->|"includes"| node_mcp
node_analyzers -->|"includes"| node_patterns
node_analyzers -->|"includes"| node_supply
node_supply -->|"parses manifests"| node_dependencies
node_supply -->|"checks vulnerabilities"| node_osv
node_osv -.->|"queries"| node_osv_service
node_graph -->|"deduplicates"| node_dedup
node_graph -->|"filters findings"| node_baseline
node_baseline -->|"uses rules"| node_baseline_data
node_graph -->|"reviews findings"| node_meta
node_meta -->|"requests review"| node_provider
node_provider -.->|"sends evidence"| node_user
node_graph -->|"scores findings"| node_score
node_graph -->|"assembles report"| node_report
node_report -->|"renders terminal"| node_terminal
node_report -->|"renders formats"| node_formats

click node_cli "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/cli.py"
click node_pipeline "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/pipeline.py"
click node_graph "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/graph.py"
click node_input "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/input_handler.py"
click node_resolve "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/resolve_input.py"
click node_context_builder "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/build_context.py"
click node_discovery "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/discovery.py"
click node_state "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/state.py"
click node_analyzers "https://github.com/nillab-agi/skillguard/tree/main/src/skillguard/nodes/analyzers"
click node_ast "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/analyzers/behavioral_ast.py"
click node_mcp "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/analyzers/mcp_least_privilege.py"
click node_patterns "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/analyzers/static_runner.py"
click node_supply "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/analyzers/supply_chain_dependencies.py"
click node_dependencies "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/dependencies.py"
click node_osv "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/providers/osv.py"
click node_dedup "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/deduplicate.py"
click node_baseline "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/apply_baseline.py"
click node_baseline_data "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/baseline.py"
click node_meta "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/meta_analyzer.py"
click node_provider "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/providers/openai_compat.py"
click node_score "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/score.py"
click node_report "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/report.py"
click node_terminal "https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/reporters/terminal.py"
click node_formats "https://github.com/nillab-agi/skillguard/tree/main/src/skillguard/reporters"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_pipeline,node_graph,node_user toneBlue
class node_input,node_resolve,node_context_builder,node_discovery,node_state toneAmber
class node_analyzers,node_ast,node_mcp,node_patterns,node_supply,node_dependencies,node_osv toneMint
class node_dedup,node_baseline,node_baseline_data,node_meta,node_provider,node_score toneRose
class node_report,node_terminal,node_formats,node_osv_service toneIndigo
```

## Components

### Scan entry

- [CLI commands](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/cli.py): `src/skillguard/cli.py`
- [Scan pipeline](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/pipeline.py): `src/skillguard/pipeline.py`
- [Scan graph](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/graph.py): `src/skillguard/graph.py`

### Input context

- [Input resolver](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/input_handler.py): `src/skillguard/input_handler.py`
- [Resolve stage](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/resolve_input.py): `src/skillguard/nodes/resolve_input.py`
- [Context builder](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/build_context.py): `src/skillguard/nodes/build_context.py`
- [Skill discovery](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/discovery.py): `src/skillguard/discovery.py`
- [Shared scan state](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/state.py): `src/skillguard/state.py`

### Security analysis

- [Security analyzers](https://github.com/nillab-agi/skillguard/tree/main/src/skillguard/nodes/analyzers): `src/skillguard/nodes/analyzers`
- [Python AST checks](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/analyzers/behavioral_ast.py): `src/skillguard/nodes/analyzers/behavioral_ast.py`
- [MCP checks](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/analyzers/mcp_least_privilege.py): `src/skillguard/nodes/analyzers/mcp_least_privilege.py`
- [Static pattern checks](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/analyzers/static_runner.py): `src/skillguard/nodes/analyzers/static_runner.py`
- [Supply-chain checks](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/analyzers/supply_chain_dependencies.py): `src/skillguard/nodes/analyzers/supply_chain_dependencies.py`
- [Dependency parsing](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/dependencies.py): `src/skillguard/dependencies.py`
- [OSV vulnerability lookup](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/providers/osv.py): `src/skillguard/providers/osv.py`

### Assessment

- [Finding deduplication](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/deduplicate.py): `src/skillguard/nodes/deduplicate.py`
- [Baseline filtering](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/apply_baseline.py): `src/skillguard/nodes/apply_baseline.py`
- [Baseline rules](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/baseline.py): `src/skillguard/baseline.py`
- [Model review](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/meta_analyzer.py): `src/skillguard/nodes/meta_analyzer.py`
- [Model provider](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/providers/openai_compat.py): `src/skillguard/providers/openai_compat.py`
- [Risk scoring](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/score.py): `src/skillguard/nodes/score.py`

### Reports

- [Report assembly](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/nodes/report.py): `src/skillguard/nodes/report.py`
- [Terminal report](https://github.com/nillab-agi/skillguard/blob/main/src/skillguard/reporters/terminal.py): `src/skillguard/reporters/terminal.py`
- [JSON Markdown SARIF](https://github.com/nillab-agi/skillguard/tree/main/src/skillguard/reporters): `src/skillguard/reporters`

### Other components

- **Scan user**
- **osv.dev**

## Connections

- Scan user → CLI commands: submits scan (evidence: `README.md`)
- CLI commands → Scan pipeline: starts scan (evidence: `src/skillguard/cli.py`)
- Scan pipeline → Scan graph: invokes graph (evidence: `src/skillguard/pipeline.py`)
- Scan graph → Resolve stage: dispatches (evidence: `src/skillguard/graph.py`)
- Resolve stage → Input resolver: resolves reference (evidence: `src/skillguard/nodes/resolve_input.py`)
- Scan graph → Context builder: dispatches (evidence: `src/skillguard/graph.py`)
- Context builder → Skill discovery: discovers files (evidence: `src/skillguard/nodes/build_context.py`)
- Scan graph → Security analyzers: runs in parallel (evidence: `README.md`)
- Security analyzers → Shared scan state: appends findings (evidence: `README.md`)
- Security analyzers → Python AST checks: includes (evidence: `src/skillguard/nodes/analyzers/__init__.py`)
- Security analyzers → MCP checks: includes (evidence: `src/skillguard/nodes/analyzers/__init__.py`)
- Security analyzers → Static pattern checks: includes (evidence: `src/skillguard/nodes/analyzers/__init__.py`)
- Security analyzers → Supply-chain checks: includes (evidence: `src/skillguard/nodes/analyzers/__init__.py`)
- Supply-chain checks → Dependency parsing: parses manifests (evidence: `src/skillguard/nodes/analyzers/supply_chain_dependencies.py`)
- Supply-chain checks → OSV vulnerability lookup: checks vulnerabilities
- OSV vulnerability lookup → osv.dev: queries
- Scan graph → Finding deduplication: deduplicates (evidence: `README.md`)
- Scan graph → Baseline filtering: filters findings (evidence: `README.md`)
- Baseline filtering → Baseline rules: uses rules (evidence: `src/skillguard/nodes/apply_baseline.py`)
- Scan graph → Model review: reviews findings (evidence: `src/skillguard/graph.py`)
- Model review → Model provider: requests review (evidence: `src/skillguard/nodes/meta_analyzer.py`)
- Model provider → Scan user: sends evidence (evidence: `README.md`)
- Scan graph → Risk scoring: scores findings (evidence: `README.md`)
- Scan graph → Report assembly: assembles report (evidence: `src/skillguard/graph.py`)
- Report assembly → Terminal report: renders terminal (evidence: `README.md`)
- Report assembly → JSON Markdown SARIF: renders formats (evidence: `README.md`)
