Skip to main content
skill CX Codex

12306 — Claude Code skill: China Railway tickets and timetables

This skill pulls train schedules, seat availability and station lists from the official 12306 API. Handy when you plan a trip across China without leaving the chat.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add kirorab/12306-skill --skill 12306 -a claude-code
Open on GitHub

What 12306 does

Two Node.js scripts do the work. query.mjs takes a departure and arrival point and returns trains with type, departure and arrival times, duration and seat counts per class. stations.mjs lists which stations belong to a city. That second step matters: a city-name query returns trains for every station in that city, so 武汉 covers 武汉站, 汉口站, 武昌站 and 武汉东站, not one central terminal.

Output format is a flag. The default writes an HTML file and prints its path; -f md prints a table straight to the chat. You can narrow results by train type (-t G), departure or arrival window, maximum travel time, bookable trains only, and seat class. --json dumps the raw response, which is the reliable way to confirm exact station names for a transfer.

No API key is involved — the data comes from 12306 directly. Node.js has to be installed. Station data is cached for 7 days in {baseDir}/data/stations.json. When you plan a connection, keep both legs at the same station: two different terminals in one city mean extra travel, not a quick change.

What it helps with

  • check which trains run from Beijing to Shanghai on a given date
  • narrow the list to morning high-speed departures under two hours
  • see whether second-class seats are still available
  • find out which stations a city actually has before routing
  • confirm both legs of a transfer use the same station

Example prompts for the agent

  • Show me trains from 北京 to 上海 tomorrow, G only, as a table
  • Which stations are in 武汉?
  • Find 深圳 → 长沙 departures before noon with seats available

How to install 12306

1Skills CLI (Vercel)

npx skills add kirorab/12306-skill --skill 12306 -a claude-code

2Manually: put the files in place

~/.claude/skills/12306/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/12306/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about 12306

How do I install 12306 in Claude Code?

Run npx skills add kirorab/12306-skill --skill 12306 -a claude-code. The skill lands at ~/.claude/skills/12306/SKILL.md.

What does the 12306 skill do?

It queries the official 12306 API for train schedules, remaining tickets and station info. It covers G, D, Z, T and K train types.

Do I need an API key?

No. Data is fetched from 12306 directly, and the scripts need Node.js to run.

Similar skills

All skills for Agent setup: memory, context, orchestration →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor