AgentStack
SKILL verified MIT Self-run

Python Patterns

skill-omnigentx-jarvis-python-patterns · by omnigentx

>

No reviews yet
0 installs
11 views
0.0% view→install

Install

$ agentstack add skill-omnigentx-jarvis-python-patterns

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access Used
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Python Patterns? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

PYTHON PATTERNS FOR JARVIS

Async / await

# ✅ Correct: use async for I/O operations
async def fetch_data(url: str) -> dict:
    async with httpx.AsyncClient() as client:
        response = await client.get(url)
        return response.json()

# ❌ Wrong: blocking I/O inside an async context
def fetch_data(url: str) -> dict:
    return requests.get(url).json()  # BLOCKS the event loop!

Type hints

# ✅ Always use type hints
from typing import Optional
from pydantic import BaseModel

class AgentConfig(BaseModel):
    name: str
    instruction: str
    skills: list[str] = []
    model: Optional[str] = None

FastAPI Patterns

# Router pattern
from fastapi import APIRouter, HTTPException

router = APIRouter(prefix="/api/v1/agents", tags=["agents"])

@router.get("/{agent_id}")
async def get_agent(agent_id: str) -> AgentResponse:
    agent = await agent_service.get(agent_id)
    if not agent:
        raise HTTPException(404, f"Agent {agent_id} not found")
    return agent

Pytest

# ✅ Fixture-based, descriptive names
import pytest

@pytest.fixture
def sample_skill():
    return {"name": "test", "description": "Test skill"}

def test_skill_loads_correct_description(sample_skill):
    assert sample_skill["description"] == "Test skill"

# ✅ Parametrize for multiple cases
@pytest.mark.parametrize("input,expected", [
    ("hello", "HELLO"),
    ("", ""),
])
def test_uppercase(input, expected):
    assert input.upper() == expected

Error Handling

# ✅ Specific exceptions, logging
import logging
logger = logging.getLogger(__name__)

try:
    result = await risky_operation()
except SpecificError as e:
    logger.error(f"Operation failed: {e}")
    raise HTTPException(500, str(e))

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.