Skip to content

Commit cd75e2a

Browse files
Convert claude skills to more generic agent skills (#8064)
Assisted-by: Codex:gpt-6
1 parent e09aee7 commit cd75e2a

8 files changed

Lines changed: 252 additions & 285 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
name: apple-container
3+
description: Run RustPython tests in Apple's `container` CLI Linux environment. Use when user asks to run or compare Linux test results on macOS.
4+
allowed-tools: Bash(container:*) Bash(cargo:*) Read Grep Glob
5+
---
6+
7+
# Run Tests in Linux Container (Apple `container` CLI)
8+
9+
Run RustPython tests inside a Linux container using Apple's `container` CLI.
10+
NEVER use Docker, Podman, or any other container runtime. Only use the `container` command.
11+
12+
## Arguments
13+
14+
- Test command to run (examples: `test_io`, `test_codecs -v`, `test_io -v -m "test_errors"`)
15+
16+
## Prerequisites
17+
18+
- The `container` CLI is installed via `brew install container`.
19+
- The dev image `rustpython-dev` is already built.
20+
21+
## Workflow
22+
23+
1. Check whether the test container is already running:
24+
25+
```shell
26+
container list 2>/dev/null | grep rustpython-test
27+
```
28+
29+
2. Start the container if it is not running:
30+
31+
```shell
32+
container run -d --name rustpython-test -m 8G -c 4 \
33+
--mount type=bind,source="$(pwd)",target=/workspace \
34+
-w /workspace rustpython-dev sleep infinity
35+
```
36+
37+
3. Run the requested test command inside the container:
38+
39+
```shell
40+
container exec rustpython-test cargo run --release -- -m test <test-args>
41+
```
42+
43+
4. Report results:
44+
45+
- Show pass/fail summary and expected failures / unexpected successes.
46+
- Highlight new failures compared to macOS results, if available.
47+
- Do not stop or remove the container after testing.
48+
49+
## Notes
50+
51+
- The workspace is bind-mounted, so local code changes are immediately available in the container.
52+
- Use `container exec rustpython-test sh -c "..."` for any command inside the container.
53+
- Rebuild after code changes with:
54+
55+
```shell
56+
container exec rustpython-test sh -c "cargo build --release"
57+
```
58+
59+
- Stop the container when explicitly requested:
60+
61+
```shell
62+
container rm -f rustpython-test
63+
```
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
name: investigate-test-failure
3+
description: Investigate a failing RustPython test, compare with CPython behavior, and decide whether to implement a fix or prepare incompatibility issue details.
4+
allowed-tools: Bash(python3:*) Bash(cargo run:*) Bash(gh issue create:*) Read Grep Glob Bash(git add:*) Bash(git commit:*) Bash(cargo fmt:*) Bash(git diff:*) Task
5+
---
6+
7+
# Investigate Test Failure
8+
9+
Investigate why a specific test is failing and determine whether it can be fixed now or should be reported as an incompatibility issue.
10+
11+
## Arguments
12+
13+
- Failed test identifier (example: `test_inspect.TestGetSourceBase.test_getsource_reload`)
14+
15+
## Workflow
16+
17+
1. Analyze the failure cause:
18+
19+
- Read the test code.
20+
- Analyze failure message and traceback.
21+
- Check related RustPython implementation code.
22+
23+
2. Verify behavior in CPython:
24+
25+
- Run the test with `python3 -m unittest`.
26+
- Document expected behavior/output.
27+
28+
3. Determine fix feasibility:
29+
30+
- Simple fix (import issues, small logic bugs): implement fix, run formatting and checks, review changes, and commit.
31+
- Complex fix (major missing feature): gather issue information and report to user.
32+
33+
Pre-commit review process:
34+
35+
- Run `git diff` to review local changes.
36+
- Use a focused subagent review to compare implementation against CPython behavior and check for missed edge cases.
37+
- Commit only after review passes.
38+
39+
4. For complex issues, collect issue information using `.github/ISSUE_TEMPLATE/report-incompatibility.md`:
40+
41+
- Feature: missing or broken Python feature.
42+
- Minimal reproduction code.
43+
- CPython behavior (`python3`).
44+
- RustPython behavior (`cargo run`).
45+
- Python documentation reference link.
46+
47+
Report the collected information to the user. Create an issue only when explicitly requested.
48+
49+
Example issue command:
50+
51+
```shell
52+
gh issue create --template report-incompatibility.md --title "..." --body "..."
53+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: upgrade-pylib-next
3+
description: Pick the next CPython stdlib module ready for upgrade based on update_lib todo output and skip modules with open upgrade PRs.
4+
allowed-tools: Skill(upgrade-pylib) Bash(gh pr list:*) Bash(cargo run:*)
5+
---
6+
7+
# Upgrade Next Python Library
8+
9+
Find the next Python library module ready for upgrade and then run the `upgrade-pylib` workflow for it.
10+
11+
## Workflow
12+
13+
1. Get current TODO status:
14+
15+
```shell
16+
cargo run --release -- scripts/update_lib todo 2>/dev/null
17+
```
18+
19+
2. Get open upgrade PRs:
20+
21+
```shell
22+
gh pr list --search "Update in:title" --json number,title --template '{{range .}}#{{.number}} {{.title}}{{"\\n"}}{{end}}'
23+
```
24+
25+
3. From TODO output, select modules in this priority order:
26+
27+
- `[ ] [no deps]`
28+
- `[ ] [0/n]` where dependencies are all upgraded (for example `[0/3]`, `[0/5]`)
29+
30+
4. Skip modules that already have an open upgrade PR.
31+
32+
5. Run upgrade for selected module using the `upgrade-pylib` workflow.
33+
34+
If no modules match, report that eligible modules are blocked by dependencies.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
name: upgrade-pylib
3+
description: Upgrade a Python standard library module from CPython into RustPython using scripts/update_lib and then triage and mark remaining failures.
4+
allowed-tools: Bash(git add:*) Bash(git commit:*) Bash(git diff:*) Bash(cargo run:*) Bash(python3 scripts/update_lib quick:*) Bash(python3 scripts/update_lib auto-mark:*)
5+
---
6+
7+
# Upgrade Python Library from CPython
8+
9+
Upgrade a Python standard library module from CPython to RustPython.
10+
11+
## Arguments
12+
13+
- Library name or path (examples: `inspect`, `asyncio`, `json`, `cpython/Lib/inspect.py`, `cpython/Lib/json/`)
14+
15+
## Important: Report Tool Issues First
16+
17+
If `scripts/update_lib` shows a bug, missing automation, or unexpected behavior, stop the upgrade and report the tooling issue first, including:
18+
19+
1. What you were trying to do:
20+
21+
- Library name.
22+
- Full command used.
23+
24+
2. What went wrong or what is missing.
25+
3. Expected vs actual behavior.
26+
27+
## Workflow
28+
29+
1. Run quick upgrade with update_lib:
30+
31+
- `python3 scripts/update_lib quick <module>`
32+
- or `python3 scripts/update_lib quick cpython/Lib/<module>.py`
33+
- or `python3 scripts/update_lib quick cpython/Lib/<module>/`
34+
35+
This step copies library files, patches tests while preserving markers where possible, runs tests, auto-marks new failures, removes stale `@unittest.expectedFailure`, and creates a commit.
36+
37+
If warnings like `WARNING: TestCFoo does not exist in remote file` appear, class structure changed and some markers must be restored manually.
38+
39+
2. Review diff and restore RustPython-specific changes:
40+
41+
- Run `git diff Lib/test/test_<module>`.
42+
- Restore only changes with explicit `RUSTPYTHON` comments.
43+
- Do not restore unrelated upstream CPython changes.
44+
45+
3. Investigate failing dependent tests:
46+
47+
- Get dependencies:
48+
49+
```shell
50+
cargo run --release -- scripts/update_lib deps <module>
51+
```
52+
53+
- Find direct dependent test modules from the `- [ ] <module>:` line.
54+
- Run dependent tests and collect failures:
55+
56+
```shell
57+
cargo run --release -- -m test <test_modules...> 2>&1 | grep -E "^(FAIL|ERROR):"
58+
```
59+
60+
- For each failing test identifier, investigate with the `investigate-test-failure` workflow.
61+
62+
4. Mark remaining failures with auto-mark:
63+
64+
- `python3 scripts/update_lib auto-mark Lib/test/test_<module>.py --mark-failure`
65+
- or `python3 scripts/update_lib auto-mark Lib/test/test_<module>/ --mark-failure`
66+
67+
Note: `--mark-failure` marks all current failures including regressions; review carefully.
68+
69+
5. Handle panics manually:
70+
71+
- For tests that panic/crash/hang, use `@unittest.skip("TODO: RUSTPYTHON; ...")` rather than expectedFailure.
72+
73+
6. Handle class-specific failures:
74+
75+
- If only one subclass fails (for example `TestCFoo` but not `TestPyFoo`), move marker to the failing subclass override.
76+
77+
7. Commit test-fix markers as a separate commit:
78+
79+
```shell
80+
git add -u && git commit -m "Mark failing tests"
81+
```
82+
83+
## Example usage
84+
85+
```text
86+
upgrade-pylib inspect
87+
upgrade-pylib json
88+
upgrade-pylib asyncio
89+
upgrade-pylib cpython/Lib/inspect.py
90+
upgrade-pylib cpython/Lib/json/
91+
```
92+
93+
## Notes
94+
95+
- The `cpython/` directory should contain the CPython source used for sync.
96+
- `scripts/update_lib` modes:
97+
- `quick`: patch + auto-mark
98+
- `migrate`: patch only
99+
- `auto-mark`: mark failures only
100+
- `copy-lib`: copy library files only
101+
- Patching transfers `@unittest.expectedFailure` and `@unittest.skip` with `TODO: RUSTPYTHON` markers where possible.
102+
- The tool does not preserve every RustPython-specific change; always review and restore explicit RUSTPYTHON-marked logic.

‎.claude/commands/apple-container.md‎

Lines changed: 0 additions & 46 deletions
This file was deleted.

‎.claude/commands/investigate-test-failure.md‎

Lines changed: 0 additions & 49 deletions
This file was deleted.

‎.claude/commands/upgrade-pylib-next.md‎

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)