Skip to content
Back to skills

2229 Commands 362222f2

ASecurity

Write AI functions with `@command` in ~7 minutes. Requires Python 3.10+ and `pip install alloy-ai`. ---

  • 11 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 11, 2026
toolspython

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 2229-commands_362222f2 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 2229 Commands 362222f2?

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

Security grade badge for 2229 Commands 362222f2
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-2229-commands-362222f2/badge)](https://www.skillsdirectory.com/skills/tools-only-2229-commands-362222f2)

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

SKILL.md
# Commands

Write AI functions with `@command` in ~7 minutes. Requires Python 3.10+ and `pip install alloy-ai`.

---

## Declaration and return discipline

- The decorated function returns a prompt `str`.
- The decorator’s `output` parameter controls the command’s actual return type.

```python
from alloy import command

@command                  # returns str
def text_gen(topic: str) -> str:
    return f"Write a one-liner about: {topic}"

@command(output=int)      # returns int
def number() -> str:
    return "Return 6*7 as a number."
```

Why this shape: predictable typing in Python, explicit control of the model result type, and clear error surfaces when the provider cannot produce the requested type.

## Sync, async, and streaming

Use sync or async functions. Both expose `.async_()` and `.stream()` helpers.

```python
from alloy import command

@command(output=str)
def gen() -> str:
    return "Write a haiku about alloy."

print(gen())                  # sync
print(await gen.async_())     # async invocation of sync command

@command(output=str)
async def agen() -> str:
    return "Write a haiku about alloy."

print(await agen())

for chunk in gen.stream():
    print(chunk, end="")

async for chunk in agen.stream():
    print(chunk, end="")
```

Streaming policy (canonical): see Guide → Streaming.

## Error surfaces and retries

- `CommandError`: model didn’t produce a final output or failed to parse into the requested type.
- `ConfigurationError`: invalid `output` shape or unsupported strict schema.
- Retries: `configure(retry=...)` or per‑call override.

```python
from alloy import command, configure, CommandError

configure(retry=2)

@command(output=int)
def maybe() -> str:
    return "Return an integer between 1 and 10."

try:
    print(maybe())
except CommandError as e:
    print("Model error:", e)
```

## Tools and contracts

Attach tools to a command to use your local capabilities. See Guide → Tools & Workflows and Guide → Contracts.

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.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.