defect-check is a standalone, framework-free inspection engine for AI artifacts. It accepts Skills, Tools, and Prompts as input, runs multi-dimensional quality checks, and returns structured defect reports with scores and severity ratings.
- 🔍 Four inspection modules — QDS, QDT, QDP, and Cross (PS/PT/ST)
- 🤖 LLM-powered analysis — supports OpenAI, Anthropic, and DashScope providers
- 🎚️ Three inspection levels — L1 (quick), L2 (standard), L3 (deep)
- 📦 Zero infrastructure — no database, no API server, no task queue
- 🏗️ Framework-free — bring your own runtime, the engine stays pure
Table of Contents
Installation
pip install defect-check
Requires Python ≥ 3.11
Quick Start
import asyncio
import defect_check
async def main():
result = await defect_check.check(
tools=[
{
"name": "lookup_order",
"description": "Query orders by order ID",
"parameters": {"type": "object"},
}
],
prompts=[
{"name": "system", "content": "You are an order assistant."}
],
skills=[
{"id": "orders", "name": "orders", "content": "# Orders workflow"}
],
llm_provider="openai",
llm_base_url="https://api.example.com/v1",
llm_api_key="your-api-key",
llm_model_id="your-model-id",
)
print(result)
asyncio.run(main())
Inspection Levels
Use check_level to control inspection depth:
| Level | Description | Speed |
|---|---|---|
L1 |
Quick check — basic validation | ⚡ Fastest |
L2 |
Standard check — moderate depth | ⚙️ Balanced |
L3 |
Deep check — comprehensive analysis | 🔬 Thorough |
result = await defect_check.check(
tools=tools,
prompts=prompts,
skills=skills,
check_level="L3",
llm_provider="openai",
llm_api_key="your-api-key",
llm_model_id="your-model-id",
)
When omitted, QDS determines the level using the bundled checklist, while QDT, QDP, and Cross determine it via the LLM. You can also pass check_level through options:
result = await defect_check.check(
tools=tools,
prompts=prompts,
skills=skills,
options=defect_check.DefectCheckOptions(check_level="L2"),
llm_provider="openai",
llm_api_key="your-api-key",
llm_model_id="your-model-id",
)
The legacy
qdp_check_leveloption remains supported for backwards compatibility. Conflicting values (e.g.check_level="L3"+options={"qdp_check_level": "L1"}) will raise an error.
LLM Configuration
LLM settings are passed explicitly by the caller — the package does not read .env files or environment variables for LLM configuration.
| Parameter | Description | Required |
|---|---|---|
llm_provider |
Provider name: "openai", "anthropic", or "dashscope" |
✅ |
llm_api_key |
API key for the provider | ✅ |
llm_base_url |
Custom base URL (e.g. for self-hosted endpoints) | Optional |
llm_model_id |
Model identifier (e.g. "gpt-4o", "claude-sonnet-4-20250514") |
✅ |
You can also pass a pre-configured client object via the provider parameter, bypassing the four llm_* parameters:
from defect_check.llm import DefectCheckTextClient
# Build your own client, then pass it in
client = DefectCheckTextClient(my_custom_provider)
result = await defect_check.check(
tools=tools,
prompts=prompts,
skills=skills,
provider=client,
)
Inspection Modules
The package provides four inspection modules, each targeting a different artifact dimension:
| Module | Full Name | Target | Method |
|---|---|---|---|
| QDS | Quality of Design Specification | Skills | Checklist + rules |
| QDT | Quality of Design Tools | Tools | LLM + rules |
| QDP | Quality of Design Prompts | Prompts | LLM + rules |
| Cross | Cross-artifact inspection (PS/PT/ST) | All pairs | LLM + rules |
Every supplied Skill, Tool, and Prompt is inspected. The response always uses a consistent envelope — results is always a list: one input produces one result item, multiple inputs produce multiple result items.
Inspection rules and prompt templates are packaged in the wheel. QDT, QDP, and Cross load YAML resources; QDS loads the bundled checklist.py.
Response Format
{
"schema_version": "1.0",
"status": "completed",
"results": [
{
"module": "QDT",
"check_type": "artifact",
"status": "completed",
"check_level": "L2",
"artifacts": [{"type": "tool", "id": "lookup_order", "name": "lookup_order"}],
"score": {"total_score": 100.0, "max_score": 100.0, "grade": null, "gate_result": "PASS"},
"defect_summary": {"total_defects": 0, "p0_count": 0, "p1_count": 0, "p2_count": 0},
"defects": [],
"error": null,
"details": {},
"metadata": {}
}
],
"summary": {
"total_results": 1,
"completed_results": 1,
"failed_results": 0,
"skipped_results": 0,
"total_defects": 0,
"p0_count": 0,
"p1_count": 0,
"p2_count": 0,
"gate_result": "PASS"
},
"errors": [],
"metadata": {"execution_time_seconds": 0.0}
}
Defect Fields
Each defect in the defects list contains these canonical fields:
| Field | Description |
|---|---|
id |
Unique defect identifier |
name |
Short defect name |
severity |
P0 (critical), P1 (major), or P2 (minor) |
category |
Defect category |
description |
Human-readable description |
location |
Where the defect was found |
impact |
Impact of the defect |
fix_suggestion |
Recommended fix |
artifact_refs |
References to affected artifacts |
details |
Module-specific extra fields |
API Reference
defect_check.check(...)
Inspect caller-provided Skills, Tools, and Prompts.
async def check(
tools: list[dict] | None,
prompts: list[dict] | None,
skills: list[dict] | None,
*,
check_level: str | None = None,
options: DefectCheckOptions | dict | None = None,
provider: Any | None = None,
llm_provider: str | None = None,
llm_base_url: str | None = None,
llm_api_key: str | None = None,
llm_model_id: str | None = None,
) -> dict[str, Any]
defect_check.check_single(...)
Inspect a single artifact. See the API documentation for details.
defect_check.check_cross(...)
Run cross-artifact inspection (PS/PT/ST). See the API documentation for details.
Exported Types
from defect_check import (
DefectCheckOptions,
DefectCheckResponse,
DefectItem,
DefectSummary,
InspectionResult,
InspectionError,
ScoreResult,
ResponseSummary,
ArtifactReference,
SkillArtifact,
PromptArtifact,
)
Development
# Clone the repository
git clone https://github.com/sanityops-org/artifact-defect-check.git
cd artifact-defect-check
# Create a virtual environment
python -m venv .venv && source .venv/bin/activate
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please make sure to update tests as appropriate and adhere to the existing code style.
License
This project is licensed under the Apache License 2.0 — see the LICENSE file for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file defect_check-0.0.1.tar.gz.
File metadata
- Download URL: defect_check-0.0.1.tar.gz
- Upload date:
- Size: 137.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16ac22b40ab24db6a4958859fcbe78c1834c9b1e2900967d916754f8bda722ed
|
|
| MD5 |
04104c9c5186a67805fe8b1cd3e968c0
|
|
| BLAKE2b-256 |
30267dbc455637e3ef0dda0cdefdbaee115d68ed5c92c91706783ac4a3682ed4
|
Provenance
The following attestation bundles were made for defect_check-0.0.1.tar.gz:
Publisher:
publish.yml on sanityops-org/artifact-defect-check
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
defect_check-0.0.1.tar.gz -
Subject digest:
16ac22b40ab24db6a4958859fcbe78c1834c9b1e2900967d916754f8bda722ed - Sigstore transparency entry: 2417333313
- Sigstore integration time:
-
Permalink:
sanityops-org/artifact-defect-check@c9e91e69ee8f717dd54f64096bc9cb8824be522a -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/sanityops-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c9e91e69ee8f717dd54f64096bc9cb8824be522a -
Trigger Event:
push
-
Statement type:
File details
Details for the file defect_check-0.0.1-py3-none-any.whl.
File metadata
- Download URL: defect_check-0.0.1-py3-none-any.whl
- Upload date:
- Size: 162.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc25c5a35413fc651e2ea4561b6938331fbf40667ef8b16f9657cb5fa89f3951
|
|
| MD5 |
f4e3ecf2923c9a3316a825561cd5f55a
|
|
| BLAKE2b-256 |
3cd1c12333c2c3fe4cb70c1f8473c2514e4f1bd43f508c38276a7b51e0ed1131
|
Provenance
The following attestation bundles were made for defect_check-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on sanityops-org/artifact-defect-check
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
defect_check-0.0.1-py3-none-any.whl -
Subject digest:
dc25c5a35413fc651e2ea4561b6938331fbf40667ef8b16f9657cb5fa89f3951 - Sigstore transparency entry: 2417333380
- Sigstore integration time:
-
Permalink:
sanityops-org/artifact-defect-check@c9e91e69ee8f717dd54f64096bc9cb8824be522a -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/sanityops-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c9e91e69ee8f717dd54f64096bc9cb8824be522a -
Trigger Event:
push
-
Statement type: