Elective
by @wjsoj
PKU Course Selection (选课网) CLI tool built in Rust. Use this skill when working on the elective crate, debugging elective commands, adding features, or when t...
clawhub install pku-elective📖 About This Skill
name: elective description: "PKU Course Selection (选课网) CLI tool built in Rust. Use this skill when working on the elective crate, debugging elective commands, adding features, or when the user mentions 选课, elective, course selection, auto-enroll, CAPTCHA solving, dual-degree, or elective.pku.edu.cn. Also use when dealing with CAPTCHA recognition backends (utool/ttshitu/yunma), automated course enrollment loops, or elective SSO callback. NOT for general course schedule / 课表 / 这学期上什么课 questions — use the
treehole skill (treehole course) instead, which gives a unified weekly grid with 主修+辅修+双学位. The elective show command only sees one program at a time and easily misses courses from the other program for dual-degree students."
version: 2.0.0
Elective - 北大选课网 CLI
A CLI client for PKU's course selection system with auto-enrollment automation.
Architecture
crates/elective/app_id="elective") → elective SSO endpoint callbackKey Source Files
src/main.rs — Clap CLI with subcommandssrc/commands.rs — Command implementations including auto-enroll loopsrc/api.rs — HTML scraping, CAPTCHA image extractionsrc/display.rs — Terminal output formattingsrc/client.rs — reqwest client buildersCLI Commands
| Command | Alias | Function |
|---------|-------|----------|
| login | | IAAA login (supports --dual for dual-degree students) |
| logout / status | | Session management |
| show | | View current course selections |
| list | ls | Browse available courses for add/drop |
| set | | Add a course to auto-enroll target list |
| unset | | Remove from auto-enroll targets |
| config-captcha | | Configure CAPTCHA solver backend |
| launch | | Start auto-enrollment polling loop |
| otp | | TOTP 2FA management |
CAPTCHA Backends
The config-captcha command supports multiple recognition backends:
manual — Display CAPTCHA image, user inputs answerutool — UTool OCR servicettshitu — TTShiTu recognition APIyunma — Yunma recognition APIAuto-Login for AI Agents
# Check session status
info-auth checkAuto-login (reads credentials from OS keyring, no password needed)
elective login -p # single degree
elective login -p --dual major # dual degree - major
elective login -p --dual minor # dual degree - minor
Note: Dual-degree students MUST specify --dual major or --dual minor, otherwise login will fail with an error.
Development Notes
--dual flag at login for separate sessionanyhow::Result with .context("中文描述")~/.config/info/elective/info_common::credential (keyring → env → interactive)