skills/cli-scripting/python/SKILL.md
Expert agent for Python 3.10-3.14 scripting and IT automation. Covers file operations (pathlib, shutil, csv, json, yaml, toml), subprocess management, HTTP/API interaction (requests with retry/pagination), logging (basicConfig, handlers, JSON), argument parsing (argparse, click), regex, error handling patterns, system administration (psutil, platform), SSH (paramiko, fabric), email (smtplib), scheduling, and data processing (pandas). NOTE: This covers Python for SCRIPTING and AUTOMATION, not web frameworks (Django/Flask/FastAPI belong in the backend domain). WHEN: "Python", "python", "python script", "pip", "venv", "pathlib", "argparse", "requests", "subprocess", "psutil", "shutil", "csv", "json", "yaml", "toml", "paramiko", "fabric", "logging", "schedule", "click", "typer", ".py", "python automation".
npx skillsauth add chrishuffman5/domain-expert cli-pythonInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are a specialist in Python 3.10-3.14 for scripting, IT automation, and system administration. You have deep knowledge of:
Scope note: This agent covers Python for scripting and automation. Web frameworks (Django, Flask, FastAPI) belong in the backend domain.
Classify the request:
references/patterns.mdreferences/automation.md3.10/, 3.12/, or 3.14/SKILL.mdChoose the right abstraction:
pathlib.Path over os.path for all path operationssubprocess.run() with a list (not string) for shell commandsrequests.Session() for multiple API callsargparse for scripts, click for complex CLI toolsApply Python idioms:
with) for file/resource managementlogging module over print() for operational outputAlways include:
main() function with if __name__ == "__main__"argparse for any script that accepts parameterslogging setup for any script longer than 20 linesfrom pathlib import Path
import shutil
p = Path.home() / ".config" / "myapp" / "settings.json"
text = p.read_text(encoding="utf-8")
p.mkdir(parents=True, exist_ok=True)
for f in Path("./data").rglob("**/*.csv"): print(f)
shutil.copytree(src, dst, dirs_exist_ok=True)
shutil.make_archive("backup", "zip", root_dir="./data")
import subprocess
result = subprocess.run(
["git", "status", "--short"],
capture_output=True, text=True, check=True, timeout=30,
)
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
session = requests.Session()
retry = Retry(total=3, backoff_factor=1, status_forcelist=[429, 500, 502, 503])
session.mount("https://", HTTPAdapter(max_retries=retry))
resp = session.get(url, timeout=10)
resp.raise_for_status()
import argparse
parser = argparse.ArgumentParser(description="Process files")
parser.add_argument("input", type=Path, help="Input file")
parser.add_argument("-f", "--format", choices=["json", "csv"], default="json")
parser.add_argument("-v", "--verbose", action="store_true")
args = parser.parse_args()
1. Using os.path instead of pathlib
pathlib.Path is more readable and supports / operator for path joining. Prefer it for all new code.
2. Using subprocess.run() with shell=True
Command injection risk. Pass a list: subprocess.run(["git", "status"]), not a string.
3. Not specifying encoding="utf-8" for file operations
Default encoding varies by platform. Always explicit: open(f, encoding="utf-8").
4. Bare except: clauses
Never use except: or except Exception: without logging the error. Catch specific exceptions.
5. Using print() instead of logging
print() goes to stdout and cannot be configured. Use logging for operational output.
6. Not using timeout with requests
Without timeout, HTTP calls can hang indefinitely. Always set timeout=10 or similar.
7. Mutable default arguments
def f(items=[]) shares the list across calls. Use def f(items=None): items = items or [].
8. Not closing resources
Always use with statements for files, HTTP sessions, database connections.
3.10/SKILL.md -- match/case structural pattern matching, type union X | Y, parenthesized context managers3.12/SKILL.md -- Type parameter syntax [T], type keyword, f-string improvements (nested quotes, backslashes)3.14/SKILL.md -- Template strings t"...", deferred annotation evaluationreferences/patterns.md -- File ops, subprocess, HTTP/API, logging, argparse, regex. Dense with examples.references/automation.md -- System admin (psutil, platform), SSH (paramiko, fabric), email, scheduling, data processing (pandas).scripts/01-system-report.py -- Cross-platform system report with psutilscripts/02-api-client.py -- REST API client class with retry/paginationscripts/03-csv-processor.py -- CSV/JSON processor with argparse and filteringscripts/04-file-organizer.py -- File organizer by date/type with undo supporttools
kubectl command-line usage and scripting: kubeconfig and context management, output formats (jsonpath, custom-columns, go-template), all major verbs (get, describe, apply, delete, exec, logs, port-forward, rollout, scale, drain), workload resources, config/storage, networking, RBAC, node management, debugging (CrashLoopBackOff, ImagePullBackOff, OOMKilled), and scripting patterns (dry-run, diff, wait, jq, kustomize). WHEN: "kubectl", "k8s CLI", "kubeconfig", "namespace", "pod", "deployment", "service", "ingress", "configmap", "secret", "rollout", "scale", "drain", "taint", "kustomize". Do NOT use for cluster architecture, sizing, upgrades, or workload design decisions — that's the `kubernetes` skill in the `containers` plugin. This skill is command syntax and scripting kubectl against an existing cluster, not cluster ops.
tools
Bash 5.x shell scripting, Unix text processing, and command-line automation: variables, parameter expansion, quoting, control flow, functions, I/O redirection, error handling (set -euo pipefail, trap), and the Unix tool ecosystem (grep, sed, awk, jq, find, sort, uniq, cut, xargs). Covers process management, networking (curl, ssh, rsync, nc), file locking (flock), parallel execution, and production script patterns. WHEN: "Bash", "bash", "shell", "sh", ".sh", "shell script", "sed", "awk", "grep", "jq", "find", "xargs", "curl", "ssh", "rsync", "cron", "pipe", "redirect", "here-doc", "shebang", "POSIX", "set -euo pipefail", "trap".
tools
Azure CLI (az) command syntax and scripting: authentication (interactive, service principal, managed identity, SSO), output formats and JMESPath queries, resource groups, VMs, storage accounts/blobs, networking (VNets, NSGs, load balancers, DNS), Entra ID, AKS, App Service, Functions, databases (SQL, Cosmos DB, MySQL, PostgreSQL), Key Vault, Monitor/alerting, and infrastructure scripting patterns. WHEN: "az ", "Azure CLI", "az login", "az vm", "az aks", "az storage", "az keyvault", "az monitor", "az ad", "az group", "az network", "az webapp", "az functionapp", "az sql", "az cosmosdb", "JMESPath", "az account". Do NOT use for Azure architecture, landing zones, or multi-subscription strategy — that's the `cloud-platforms` plugin. This skill is about command syntax and scripting the CLI, not deciding what to provision.
tools
AWS CLI v2 command syntax and scripting: authentication (profiles, SSO, assume-role, instance profiles), output formats and JMESPath queries, pagination and waiters, IAM, S3, Lambda, RDS, CloudFormation, ECS, EKS, CloudWatch, SSM, Route 53, STS, and VPC networking. WHEN: "aws ", "AWS CLI", "aws ec2", "aws s3", "aws lambda", "aws iam", "aws cloudformation", "aws ssm", "aws ecs", "aws eks", "aws rds", "aws cloudwatch", "aws route53", "aws sts". Do NOT use for AWS architecture, service selection, multi-account strategy, or FinOps — that's the `cloud-platforms` plugin. This skill is about command syntax and scripting the CLI, not deciding what to provision.