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.

referencesrules-and-file-io.md

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

Rules and File I/O

Guidance

  • Use data structures that match the operation (set for membership).
  • Prefer pathlib for file paths and file operations.

Bad Example

def find_potential_customers_v1(users_visited_phuket, users_visited_nz):
    """Find people who visited Phuket but not New Zealand."""
    for phuket_record in users_visited_phuket:
        is_potential = True
        for nz_record in users_visited_nz:
            if phuket_record["first_name"] == nz_record["first_name"] and \
                    phuket_record["last_name"] == nz_record["last_name"] and \
                    phuket_record["phone_number"] == nz_record["phone_number"]:
                is_potential = False
                break

        if is_potential:
            yield phuket_record

Good Example

def find_potential_customers_v2(users_visited_phuket, users_visited_nz):
    """Find people who visited Phuket but not New Zealand."""
    nz_records_idx = {
        (rec["first_name"], rec["last_name"], rec["phone_number"])
        for rec in users_visited_nz
    }

    for rec in users_visited_phuket:
        key = (rec["first_name"], rec["last_name"], rec["phone_number"])
        if key not in nz_records_idx:
            yield rec

Bad Example

import os
import os.path


def unify_ext_with_os_path(path):
    """Rename .txt files to .csv in a directory."""
    for filename in os.listdir(path):
        basename, ext = os.path.splitext(filename)
        if ext == ".txt":
            abs_filepath = os.path.join(path, filename)
            os.rename(abs_filepath, os.path.join(path, f"{basename}.csv"))

Good Example

from pathlib import Path


def unify_ext_with_pathlib(path):
    for fpath in Path(path).glob("*.txt"):
        fpath.rename(fpath.with_suffix(".csv"))

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