write-cli-app
One argparse GitHub PR CLI in pkg/ with urllib. Use when the task is design or develop a CLI app that talks to GitHub. Do not use for weekday scripts.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-05
- Stars
- ★ 4
- Forks
- 5
01 前言 Front Matter
- name
- write-cli-app
- description
- One argparse GitHub PR CLI in pkg/ with urllib. Use when the task is design or develop a CLI app that talks to GitHub. Do not use for weekday scripts.
03 SKILL.md 正文
stdlib urllib. Token from os.environ. argparse subcommands. No curl. No secrets.
Action: edit Path: {{module}}
import argparse
import json
import os
import urllib.request
from typing import Any
def list_pulls(owner: str, repository: str) -> list[dict[str, Any]]:
token = os.environ["GITHUB_TOKEN"]
url = f"https://api.github.com/repos/{owner}/{repository}/pulls"
request = urllib.request.Request(
url,
headers={"authorization": f"Bearer {token}", "accept": "application/json"},
)
with urllib.request.urlopen(request, timeout=10.0) as response:
payload = json.loads(response.read().decode("utf-8"))
if not isinstance(payload, list):
raise ValueError("json array required")
return payload
if __name__ == "__main__":
parser = argparse.ArgumentParser()
sub = parser.add_subparsers(dest="command", required=True)
listed = sub.add_parser("list")
listed.add_argument("owner")
listed.add_argument("repository")
args = parser.parse_args()
if args.command == "list":
print(list_pulls(args.owner, args.repository))
04 同仓库更多 Skills
write-workflow
Adds one workflow YAML that runs the unit test suite. Use when the task is CI, pipeline, or workflow. Do not use for questions or one Python function.
write-tests
Adds one AAA unittest that names the behavior. Use when adding a feature or when the user asks for tests.
write-script
Adds one small argparse script in pkg/ with if __name__. Use for CLI, argv, or a weekday-style script. Do not use for questions.
write-paths
Adds one pathlib helper for venv, home, or project paths on Windows, macOS, and Linux. Use for filesystem and platform work. Do not use for questions.
write-algorithm
Adds one named algorithm (binary search, stack, tally of edges) plus a later AAA test. Use for data structures and algorithms.
walk-files
Adds one pathlib helper that walks every file under a folder, such as finding by suffix, totalling sizes, or listing newest first. Use for file system work that says under, inside, recursively, or every file in a folder. Do not use for a single known path.