# 12306

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.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 636 installs · ★ 12
- Author: kirorab
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/kirorab/12306-skill/tree/HEAD/SKILL.md
- Updated: 2026-03-05
- HTML: https://affpapa.org/en/nevibecode/skills/12306

## What it 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.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add kirorab/12306-skill --skill 12306 -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/12306/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/12306/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add kirorab/12306-skill --skill 12306 -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/12306/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add kirorab/12306-skill --skill 12306 -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/12306/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install kirorab/12306-skill 12306
```

2. **Manually: put the files in place**
- File: `.github/skills/12306/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add kirorab/12306-skill --skill 12306 -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/kirorab/12306-skill
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/12306/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add kirorab/12306-skill --skill 12306 -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/kirorab/12306-skill/tree/HEAD/SKILL.md

## When to use it
- 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
- Show me trains from 北京 to 上海 tomorrow, G only, as a table
- Which stations are in 武汉?
- Find 深圳 → 长沙 departures before noon with seats available

## Similar
- [setup-matt-pocock-skills](https://affpapa.org/en/nevibecode/skills/setup-matt-pocock-skills.md) — skill · 1052851 installs
- [ask-matt](https://affpapa.org/en/nevibecode/skills/ask-matt.md) — skill · 766587 installs
- [to-tickets](https://affpapa.org/en/nevibecode/skills/to-tickets.md) — skill · 711230 installs
- [writing-plans](https://affpapa.org/en/nevibecode/skills/writing-plans.md) — skill · 282859 installs
- [caveman-review](https://affpapa.org/en/nevibecode/skills/caveman-review.md) — skill · 411800 installs
- [caveman-compress](https://affpapa.org/en/nevibecode/skills/caveman-compress.md) — skill · 411500 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
