Standalone defect-checking engine for AI Skills, Tools, and Prompts
pip install defect-check==1.2.5 Copy PIP instructions
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.
pip install defect-check Requires Python ≥ 3.11
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()) Recommended: the DefectChecker class For repeated use, create a DefectChecker once with your LLM settings and reuse it — no need to pass base parameters on every call. All check methods are async.
import asyncio from defect_check import DefectChecker async def main(): # Configure everything up front (max_retries defaults to 3, max_concurrency to 5) checker = DefectChecker( llm_provider="openai", llm_base_url="https://api.example.com/v1", llm_api_key="your-api-key", llm_model_id="your-model-id", max_retries=3, # retries for recoverable LLM errors max_concurrency=5, # max in-flight LLM requests across all calls ) result = await checker.defect_check( tools=[{"name": "lookup_order", "description": "Query orders by order ID"}], prompts=[{"name": "system", "content": "You are an order assistant."}], skills=[{"id": "orders", "name": "orders", "content": "# Orders workflow"}], ) single = await checker.check_single(tool={"name": "lookup_order"}) cross = await checker.cross_defect_check(prompt="You are...", skills=skills, tools=tools) await checker.close() asyncio.run(main()) You can also create the checker first and configure it later via setter methods:
checker = DefectChecker() checker.set_llm_config(llm_provider="openai", llm_api_key="sk-...", llm_model_id="gpt-4o") checker.set_max_retries(5) # override the default of 3 checker.set_max_concurrency(10) # override the default of 5 result = await checker.defect_check(tools=tools) Inspection Levels Use check_level to control inspection depth:
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:
LLM settings are passed explicitly by the caller — the package does not read .env files or environment variables for LLM configuration.
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, ) The same llm_* / provider parameters are accepted by DefectChecker(...) and checker.set_llm_config(...).
The LLM client applies two protections that you can tune (defaults shown):
checker = DefectChecker(provider=my_client, max_retries=5, max_concurrency=10) Best practice: set max_concurrency before running your first check. Changing it afterwards rebuilds the underlying client's shared semaphore, which briefly releases coordination for in-flight callers.
If the LLM configuration is missing when a check runs, the response carries an LLM_CONFIGURATION_MISSING error instead of raising an exception.
You can override the built-in inspection rules and prompt templates with custom YAML files:
checker = DefectChecker( llm_provider="openai", llm_api_key="your-api-key", llm_model_id="gpt-4o", yaml_overrides={ "qds_scoring": "/path/to/custom_qds_rules.yaml", "prompt_qds": "/path/to/custom_qds_prompt.yaml", }, ) # Or switch at runtime checker.set_yaml_overrides({"qds_scoring": "/another/config.yaml"}) # Reset to built-in defaults checker.set_yaml_overrides(None) Supported override keys:
For detailed YAML schema, domain-specific extensions, and examples, see Custom YAML Configuration.
The package provides four inspection modules, each targeting a different artifact dimension:
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.
Since v2.x, QDS, QDT, and QDP share a single unified inspection framework in defect_check/core/. Each domain is a thin declarative registration (DomainRegistration) wired into a 7-stage pipeline:
LevelDeterminer → EntryGate → ViewGenerator → Checklist → CheckExecutor → Enricher → Scorer → Adapter Stage Responsibility LevelDeterminer Determine check level (L1/L2/L3) from artifact content — keyword-based (QDS) or LLM-based (QDP/QDT) EntryGate Deterministic pre-check — QDS-0 gate validates frontmatter before scoring ViewGenerator Optional intermediate view (QDS) Checklist Derive the applicable check list from the domain defect registry CheckExecutor Main inspection logic — the per-domain executor (QDPExecutor, QDS GroupedParallelExecutor, QDTExecutor) Enricher Fill missing defect metadata from the registry Scorer Compute score, grade, and gate result via the unified UnifiedScorer Adapter Convert internal findings to the public DefectItem contract All three domains feed the same InspectionPipeline (see defect_check/orchestrator.py), which is what the public check / check_single entry points call. This guarantees identical contract behavior across domains while keeping QDS-specific features (QDS-0 gate, intermediate view, grouped parallel execution) as first-class framework concepts.
To add a new domain, implement a DomainRegistration (level determiner, gate, view generator, executor, enricher, scorer) and register it in DomainRegistry — see docs/architecture.md for details.
{ "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:
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.
Run cross-artifact inspection (PS/PT/ST). See the API documentation for details.
A stateful facade that holds LLM configuration, retry, and concurrency settings — configure once, then run checks as instance methods.
from defect_check import DefectChecker checker = DefectChecker( provider: Any | None = None, # pre-configured client/provider (optional) llm_provider: str | None = None, llm_base_url: str | None = None, llm_api_key: str | None = None, llm_model_id: str | None = None, max_retries: int = 3, max_concurrency: int = 5, options: DefectCheckOptions | dict | None = None, # instance-level defaults yaml_overrides: dict[str, str] | None = None, # custom YAML config overrides ) # Configuration setters (can be called after construction) checker.set_llm_config(llm_provider=..., llm_api_key=..., llm_model_id=...) checker.set_max_retries(5) checker.set_max_concurrency(10) checker.set_options({"check_level": "L2"}) checker.set_yaml_overrides({"qds_scoring": "/path/to/custom.yaml"}) # custom rules # Inspection methods (all async; parameter signatures match the module-level functions) await checker.defect_check(tools=..., prompts=..., skills=...) # full inspection await checker.check_single(tool=..., prompt=..., skill=...) # single artifact await checker.cross_defect_check(prompt=..., skills=..., tools=...) # PS/PT/ST only await checker.close() # release the LLM connection Precedence for check settings: explicit method arguments > instance configuration (set_options / constructor options) > built-in defaults. Call-level check_level overrides the instance level without conflict errors.
Contributions are welcome! Please follow these steps:
Please make sure to update tests as appropriate and adhere to the existing code style.
This project is licensed under the Apache License 2.0 — see the LICENSE file for details.
defect-check qa quality-assurance llm ai skills tools prompts inspection static-analysis
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
The dropdown lists show the available interpreters, ABIs, and platforms.
Enable javascript to be able to filter the list of wheel files.
Copy a direct link to the current filters Copy
Details for the file defect_check-1.2.5.tar.gz.
The following attestation bundles were made for defect_check-1.2.5.tar.gz:
Publisher: publish.yml on sanityops-org/artifact-defect-check




