All skills
psiace avatar

/piglet

@aafd21d
by Chojan Shangpsiace/skills172 stars
7

Practical Python craftsmanship guidance based on One Python Craftsman. Use when writing, refactoring, or reviewing Python code for naming, branching, data structures, functions, exceptions, loops, decorators, imports, file I/O, edge cases, and modern syntax choices. If the skills set includes friendly-python, suggest invoking it for better Python outcomes.

Use this Skill: https://skilld.dev/gh/psiace/skills/piglet

This session only. Nothing lands on disk.

referencesexceptions-handling.md

≈387 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Exception Handling

Guidance

  • Catch only the exceptions you can handle.
  • Keep try blocks narrow to avoid hiding unrelated bugs.
  • Preserve context with specific exception types and messages.

Bad Example

def save_website_title(url, filename):
    try:
        resp = requests.get(url)
        obj = re.search(r"<title>(.*)</title>", resp.text)
        if not obj:
            print("save failed: title tag not found in page content")
            return False

        title = obj.grop(1)
        with open(filename, "w") as fp:
            fp.write(title)
            return True
    except Exception:
        print(f"save failed: unable to save title of {url} to {filename}")
        return False

Good Example

from requests.exceptions import RequestException


def save_website_title(url, filename):
    try:
        resp = requests.get(url)
    except RequestException as exc:
        print(f"save failed: unable to get page content: {exc}")
        return False

    obj = re.search(r"<title>(.*)</title>", resp.text)
    if not obj:
        print("save failed: title tag not found in page content")
        return False
    title = obj.group(1)

    try:
        with open(filename, "w") as fp:
            fp.write(title)
    except IOError as exc:
        print(f"save failed: unable to write to file {filename}: {exc}")
        return False
    else:
        return True

Source: SKILL.md on GitHub

No alerts8d4 checks · Risk SAFE
  • Gen Agent Trust Hub8d

    The 'piglet' skill provides Python craftsmanship guidance and code examples based on the 'One Python Craftsman' repository. It contains no malicious patterns, unauthorized network operations, or security vulnerabilities.

  • Socket8d

    No alerts

  • Snyk8d

    Risk: LOW · No issues

  • Runlayer7mo

    1/14 files flagged

Signed by skilld at aafd21d. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated 8 months ago

README badge

README badge for psiace/skills/piglet