Skip to content
Back to skills

2607 Type System 0495349d

ASecurity

How Python types map to provider schemas and back (~4 minutes). --- - Inputs: Python annotations on tools/commands guide type checking and schema. - Outputs: `output=T` → JSON Schema → provider structured output → Python `T`. - Supported: primitives, dataclasses, lists of supported types; strict mode forbids open‑ended dicts. - Errors: configuration errors for unsupported shapes; command errors for provider parse failures.

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 11, 2026
documentationpython

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 2607-type-system_0495349d --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 2607 Type System 0495349d?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 2607 Type System 0495349d
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-2607-type-system-0495349d/badge)](https://www.skillsdirectory.com/skills/tools-only-2607-type-system-0495349d)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# Type System

How Python types map to provider schemas and back (~4 minutes).

---

- Inputs: Python annotations on tools/commands guide type checking and schema.
- Outputs: `output=T` → JSON Schema → provider structured output → Python `T`.
- Supported: primitives, dataclasses, lists of supported types; strict mode forbids open‑ended dicts.
- Errors: configuration errors for unsupported shapes; command errors for provider parse failures.

## Mapping Rules

- Primitives: providers require an object root; Alloy wraps primitives as `{ "value": <primitive> }` and unwraps on parse.
- Objects: dataclasses/TypedDicts become JSON Schema objects with `required` fields and `additionalProperties: false`.
- Arrays: supported when element type maps to a concrete schema.
- Unions/Optionals: not supported in strict mode.

## Example

```python
from dataclasses import dataclass
from alloy import command

@dataclass
class Person:
    name: str
    email: str

@command(output=Person)
def extract_person(text: str) -> str:
    return f"Extract name and email from: {text}"
```

Resulting schema (conceptual)

```json
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "name": {"type": "string"},
    "email": {"type": "string"}
  },
  "required": ["name", "email"]
}
```

## Runtime Parsing

- Providers return the structured payload; Alloy validates against the schema and instantiates `T`.
- On parse failure, `CommandError` includes expected type and a snippet of the model output.

## Strict vs non‑strict schemas

- Structured outputs (for `@command(output=T)`) use strict schemas: all fields are required and `additionalProperties: false`. Open‑ended dicts are rejected.
- Tool parameter schemas use non‑strict schemas: only parameters/fields without defaults are required. Open‑ended dicts are allowed for tool inputs.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…