Your campus life, from the terminal.
A unified command-line toolkit for Peking University services — treehole, courses, campus card, elective, credential management, and WeChat article crawler.
Getting Started · Tools · Claude Code Integration · Architecture
You need a Rust toolchain (rustup recommended).
Linux additionally needs system libraries used by two transitive -sys crates:
| Package | Used by | Purpose |
|---|---|---|
pkg-config |
build system | locate the libs below |
OpenSSL dev headers (libssl-dev / openssl-devel) |
openssl-sys ← reqwest's native-tls |
HTTPS to PKU services |
D-Bus dev headers (libdbus-1-dev / dbus-devel) |
libdbus-sys ← keyring's Linux Secret Service backend |
store/read IAAA credentials |
C toolchain (build-essential / gcc) |
linker for the above | compile native code |
One-liners:
# Debian / Ubuntu
sudo apt install -y pkg-config libssl-dev libdbus-1-dev build-essential
# Fedora / RHEL
sudo dnf install -y pkg-config openssl-devel dbus-devel gcc
# Arch
sudo pacman -S --needed pkgconf openssl dbus base-develNote
At runtime, info-auth store on Linux talks to a running Secret Service
(GNOME Keyring, KWallet, KeePassXC, …). On a headless server without one,
fall back to env vars: export PKU_USERNAME=… PKU_PASSWORD=….
macOS and Windows need no extra system packages — native-tls uses
Security framework / SChannel and keyring uses Keychain / Credential Manager.
Just install the Rust toolchain.
cargo install pku-cli --lockedOne command installs the unified pku binary with access to all tools:
pku treehole login -p # Login to treehole
pku course courses --all # List all courses
pku card info # Campus card balance
pku elective show # View course selections
pku auth store # Store IAAA credentials
pku spider search "北大" # Search WeChat articlesTip
You can also install tools individually if you only need specific ones:
cargo install pku-treehole pku-course pku-campuscard pku-elective pku-auth pkuinfo-spider1. Store your IAAA credentials once (encrypted in your OS keychain):
info-auth store2. Login to any service — credentials resolve automatically:
treehole login -p
course login -p
campuscard login -p
elective login -pNote
Passwords are never exposed in CLI arguments, environment variables, or logs.
The info-auth store command uses interactive input and stores credentials in the
OS keychain (macOS Keychain / GNOME Keyring / Windows Credential Manager).
Anonymous forum client with full read/write support.
treehole list # Browse latest posts
treehole search "关键词" # Full-text search
treehole show 12345 # View post + replies
treehole post -t "Hello world" # Create a post
treehole score # View your grades
treehole schedule # This week's scheduleCourse management, assignments, lecture recordings, and tools for teaching assistants.
course courses --all # List all courses
course assignments # Pending assignments
course videos # Lecture recordings
course submit # Submit homework (interactive)
course browse # Interactive course browser
course ta --help # TA tools: post files, create assignments, grade (writes need --yes)Campus card balance, payments, transaction history.
campuscard info # Card info & balance
campuscard pay # Show payment QR code
campuscard bills --month 2026-03 # Transaction history
campuscard stats # Monthly spending breakdown
campuscard recharge -a 100 # Top up 100 yuanCourse selection with automated retry and CAPTCHA handling.
elective show # Current selections
elective list # Available courses
elective set # Pick target courses (interactive)
elective launch -t 15 # Auto-select loop, 15s intervalBrowse and download PKU Netdisk files (read-only): personal, shared and department libraries.
disk ls # All document libraries
disk ls 个人/课件 # Browse a folder
disk download 个人/课件 -o ./out # Download a folder, keeping its structureStudent mailbox (@stu.pku.edu.cn, NetEase Enterprise Mail): folders, list, read, search, attachments, contacts, send and reply. Logs in with your student ID and IAAA password (checked by the mail server itself, not via IAAA); a new machine needs one SMS code. Sending always previews first and only goes out with --yes.
mail login -p # SMS code once per machine
mail ls --unread # Unread mail in the inbox
mail read <mid> # Read (does not mark as read)
mail search 奖学金 # Full-text search
mail download <mid> -o ./out # All attachments
mail send --to a@pku.edu.cn -s "Hi" --body "..." # Preview; add --yes to sendToday's dishes in every canteen, the current meal's picks, live crowd levels and opening hours, ratings and the monthly leaderboard (rec.pku.edu.cn, signed in through the info portal). Favorites and ratings preview unless --yes.
fanxb login -p
fanxb recommend # What to eat now
fanxb menu --meal dinner -q 牛肉 # Filter by meal / keyword / canteen (-c 学一)
fanxb canteens --open # Open canteens and how crowded they are
fanxb top # Monthly best-rated dishesAsk PKU's official campus assistant (student handbooks, library, finance, computing center, security …); prints the Markdown answer and its sources.
xiaobei login -p
xiaobei ask "本科生休学最长可以多久?"Course tutors built on course material: list and join public courses, ask questions answered from a course's knowledge bases (streamed). Join/leave preview unless --yes.
zhixue login -p
zhixue courses --public
zhixue ask "傅里叶变换的物理意义?" -c <course id>Read-only: live head counts, bookable sites, the free/taken grid per court and hour, your bookings and notices (epe.pku.edu.cn). Booking needs a captcha, so it stays in the browser (venues open prints the link).
venues login -p
venues crowd # Gym / pool head counts
venues slots 五四 羽毛球 --date 2026-11-29
venues open 86 # Booking page for the userVisitor appointments for 燕园 (form, list, add, cancel), campus entry/exit status and CET-4/6 scores (simso.pku.edu.cn). Adding, submitting and cancelling preview unless --yes; submitting needs a second factor — your bound 手机令牌 is filled in automatically, otherwise you enter the SMS code.
simso login -p
simso visitor form # Bookable dates, gates, rules
simso visitor add --date 2026-11-29 --time 10:00 --gate 南门 --reason 父母探望 \
--name 张三 --phone 138xxxxxxxx --id-number <id> # Preview; add --yes to submit
simso visitor list # Review state of my appointments
simso cet # CET-4/6 scoresSeats left on the 燕园–新燕园 commuter shuttle, your bookings, book and cancel (wproc.pku.edu.cn). Campus network only. Book and cancel preview unless --yes.
shuttle login -p
shuttle seats --upcoming # Today's remaining departures and seats
shuttle book -r 7 --date 2026-11-30 --time 07:00 # Preview; add --yes to book
shuttle minerepair lists and files requests with 校园环境与后勤报修平台 (submit previews unless --yes; the reporter's student ID always comes from your login). people searches the university directory by name and unit (students see name, unit and category only).
repair login -p
repair list
repair submit --phone 138xxxxxxxx --address "理科1号楼 304 室" --content "走廊灯管坏了" # Preview
people search 张三 -u 物理学院i看牙 dental booking (departments, doctors, free slots, your appointments, book, cancel) and the health / lab / exam reports (list, download a PDF to a file you name). Plain HTTP to the campus hospital host only, campus network only. Book and cancel preview unless --yes; reports need a second factor (手机令牌 auto-filled, else SMS code).
hospital login -p
hospital departments # Which projects have numbers
hospital doctors --need 26
hospital slots --need 26 --doctor 57
hospital book --need 26 --doctor 57 --slot <号源> # Preview; add --yes to book
hospital reports --kind lab
hospital report --kind lab --date 20261101 --out lab.pdfWeChat Official Account article crawler (standalone auth, not IAAA).
info-spider login # WeChat QR code login
info-spider search "人民日报" # Search official accounts
info-spider articles --name "X" # List articles from an account
info-spider scrape <url> # Convert article to MarkdownPKU CLI is designed to work with Claude Code as an AI-powered campus assistant.
Via Clawhub (recommended):
npm i -g clawhub
clawhub install pku-treehole
clawhub install pku-course
clawhub install pku-campuscard
clawhub install pku-elective
clawhub install pku-info-spider
clawhub install pku-info-common
clawhub install pku-info-authVia Claude Code Plugin Marketplace:
/plugin marketplace add pkuinfo/pkucli
/plugin install pku-cli@pku-cli
Use this system prompt to enable Claude Code to manage your PKU services autonomously:
You have access to PKU CLI tools. Before using any tool, run `info-auth check`
to verify session status. If a session is expired or missing, run
`<tool> login -p` to auto-login using stored credentials.
Available tools:
- treehole: browse/post/search the PKU anonymous forum
- course: manage Blackboard Learn courses, assignments, videos
- campuscard: check balance, pay, view transaction history
- elective: automated course selection with CAPTCHA solving
- mail: student mailbox — read/search/download; send/reply preview unless --yes
- fanxb: canteen menus, picks, crowd, hours, ratings (fav/rate preview unless --yes)
- xiaobei: ask the official campus knowledge-base assistant
- zhixue: course AI tutors — courses, join/leave (preview unless --yes), ask
- venues: sports venues — crowd, free courts, my bookings (read-only)
- simso: visitor appointments, campus entry status, CET scores (visitor add/submit/cancel preview unless --yes)
- shuttle: 新燕园 shuttle seats and bookings, campus network only (book/cancel preview unless --yes)
- repair: 后勤报修 list/submit (submit previews unless --yes); people: directory search by name/unit
- hospital: 校医院 i看牙 booking and health reports, campus network only (book/cancel preview unless --yes)
- info-spider: crawl WeChat official account articles
- info-auth: manage IAAA credentials (store/check/clear)
Credentials are stored in the OS keyring. Never ask the user for passwords.
Use `info-auth store` only when no credentials exist.
Important
Run info-auth store interactively before giving Claude Code access.
AI Agents cannot and should not handle password input — they only call
<tool> login -p which reads from the OS keyring automatically.
pku-cli Unified entry point — `pku` binary
pkuinfo-common (lib) Shared: IAAA auth, OTP, session, credential resolution
│
├── pku-treehole Treehole anonymous forum
├── pku-course Blackboard Learn
├── pku-campuscard Campus card (Synjones)
├── pku-elective Course selection
└── pku-auth Credential management
pkuinfo-spider WeChat article crawler (standalone auth)
All PKU services share a unified IAAA single-sign-on flow:
OS Keyring ──→ IAAA SSO ──→ Service callback ──→ Session persisted
│
├── treehole: JWT token
├── course: Blackboard session
├── campuscard: Synjones JWT
└── elective: Cookie session
Credential resolution order:
- OS Keyring — set by
info-auth store - Environment variables —
PKU_USERNAME+PKU_PASSWORD - Interactive prompt — fallback
| Crate | Type | Description |
|---|---|---|
pku-cli |
meta | One install for all tools |
pkuinfo-common |
lib | IAAA auth & shared utilities |
pku-treehole |
bin | Treehole CLI |
pku-course |
bin | Blackboard Learn CLI |
pku-campuscard |
bin | Campus card CLI |
pku-elective |
bin | Course selection CLI |
pku-auth |
bin | Credential management |
pkuinfo-spider |
bin | WeChat article crawler |
pku-disk |
bin | PKU Netdisk CLI |
pku-mail |
bin | Student mail (@stu.pku.edu.cn) CLI |
pku-fanxb |
bin | 饭小北 canteen menus CLI |
pku-xiaobei |
bin | 小北 campus Q&A CLI |
pku-zhixue |
bin | 小北智学 course tutors CLI |
pku-venues |
bin | 智慧场馆 sports venues CLI |
pku-simso |
bin | 学生信息服务 visitors / entry / CET CLI |
pku-shuttle |
bin | 新燕园班车预约 CLI |
pku-campus-services |
bin | repair (我要报修) and people (人员查询) CLIs |
pku-hospital |
bin | 校医院 i看牙 and reports CLI |