name: session-start description: "Session start report -- git status, PR/CI, Issue list, recommended tasks. Auto-invoked by other skills."
Session Start Routine
Run independent information-gathering steps in parallel. Phase 0 must complete alone first.
Phase 0: Update Repository (run alone)
git branch --show-currentgit status --short- On main:
git pull origin main --ff-only - Not on main: Run branch auto-return logic (below)
- Stale Worktree Cleanup:
git worktree list --porcelain. If stale worktrees exist, rungit worktree prune. Record for Phase 3 report. git log --oneline -5
Branch Auto-Return Logic
git fetch origin maingit log --oneline origin/main..HEAD --no-merges- 0 commits →
git checkout main && git pull origin main(auto-return) - 1+ commits →
gh pr list --head <branch> --state merged - Merged PR found → auto-return to main
- No merged PR → report as ongoing work
Phase 1: Information Gathering (parallel)
A. GitHub Account Check
gh api user --jq .login
B. Open PRs and CI
gh pr list --author @me --state open- For open PRs →
gh pr view <number> --json title,state,reviewDecision,statusCheckRollup,mergeable - 別セッション検出(lease スキャン):
scripts/session-lease-scan.shを実行し、stdout に出力された branch 名を「別セッション作業中 branch セット」として記録する。 このヘルパはBRANCH_LEASE_DIR(既定/tmp/claude-branch-leases)を走査し、BRANCH_LEASE_TTL_LOCAL(既定 7200s)以内の fresh lease を持つ branch を列挙する。 Draft 状態・CI 状態・mergeable を問わず、ヘルパ出力に headRefName が含まれる open PR はすべて🔒 別セッション作業中として扱う(read-only 表示のみ)。
C. GitHub Issues
gh issue list --state open --limit 20
D. First-Time Setup and Legacy Migration (.claude/config.yml)
This phase handles (a) first-time project setup and (b) migration from the legacy .claude/workflow-config.yml to .claude/config.yml. The single source of truth for project-side settings is now .claude/config.yml (carrying the platform field migrated from the old workflow-config.yml). All migration logic is idempotent and logs its outcome into the Phase 3 sync report (migrated / skipped / merged / no-op).
D-1. Legacy migration branches (AC7)
Evaluate the two files and act per the branch table below. All branches are idempotent: running this phase twice on the same project state is a no-op on the second run.
.claude/workflow-config.yml (old) |
.claude/config.yml (new) |
Action | Sync report |
|---|---|---|---|
| present | absent | old-only — write new file (platform field, see D-3), then delete old. If the write fails, leave old in place (no partial state). | migrated: workflow-config.yml → config.yml |
| absent | present | new-only — no-op. | skipped: config.yml already present |
| present | present, platform key present in new |
both-exist, platform present — delete old only; do not merge (duplicate merge is skipped to avoid silently overwriting a user edit). | merged-skipped: config.yml already owns platform; deleted old workflow-config.yml |
| present | present, platform key absent in new |
both-exist, platform absent — merge the old platform value into new, then delete old. |
merged: platform from old workflow-config.yml → config.yml; deleted old |
| absent | absent | both-absent — no-op (first-time setup runs in D-2 next). | (no entry; D-2 may add one) |
The write-then-delete ordering (old-only and both-exist/platform-absent branches) keeps the process crash-safe: if the process dies between the write and the delete, the next session re-enters D-1 and the both-exist branch idempotently completes the delete without re-writing.
D-2. First-time setup (only when both files are absent)
If both .claude/workflow-config.yml and .claude/config.yml are absent after D-1:
- Auto-detect platform:
*.xcodeproj,*.xcworkspace, orPackage.swift→iospackage.json→web- Neither → "No platform detected. Run
/atdd-kit:setup-iosor/atdd-kit:setup-web."
- Confirm with user — read
${CLAUDE_PLUGIN_ROOT}/addons/<platform>/addon.ymland show:<Platform> project detected. The following will be set up: MCP Servers: <list mcp_servers keys from addon.yml> Hooks: <list matcher patterns from addon.yml hooks> Deploy Files: <list dest paths from addon.yml deploy> Skills: <list skills from addon.yml> Proceed? [Y/n] - Process addon:
- MCP servers: Merge
mcp_serversinto.mcp.json(create if missing, preserve existing) - Deploy files: Copy each
deployentry from${CLAUDE_PLUGIN_ROOT}/addons/<platform>/<src>to<dest> - Hooks: Add
hooks.PreToolUseentries to.claude/settings.json(preserve existing) - Guidance: Display the
guidancetext
- MCP servers: Merge
- Optional addons (opt-in, default OFF): these are not auto-detected from repo files; offer each and require an explicit
ybefore enabling — never enable without consent.- Discord notifications (
${CLAUDE_PLUGIN_ROOT}/addons/discord/): per-issue Discord threads streaming full-autopilot progress / escalations. AskEnable Discord notifications addon? (needs a forum-channel webhook) [y/N]— default N. Only on explicity, run the/atdd-kit:setup-discordsteps (deployaddons/discord/scripts/fa-notify-discord.sh, configureFA_NOTIFY_CMD/FA_DISCORD_WEBHOOK). On no/blank, skip silently.
- Discord notifications (
- Write
.claude/config.ymlusing the template spec in D-3 below. - Continue to Phase 1-E
D-3. .claude/config.yml template (idempotent)
Every write to .claude/config.yml under D-1 (old-only migration) and D-2 (first-time setup) writes the platform field. Skip writing if the file already has a platform section so the process is idempotent (running the phase twice never duplicates or overwrites a user edit), and validates as YAML (DoD smoke test: python3 -c "import yaml; yaml.safe_load(open('.claude/config.yml'))").
Reference template (embed verbatim):
platform:
- <detected-platform>
E. Plugin Version Check
- Run
${CLAUDE_PLUGIN_ROOT}/scripts/check-plugin-version.sh "${CLAUDE_PLUGIN_ROOT}" "${HOME}/.claude/plugin-cache" - Parse output (check in this order):
FIRST_RUN: 2 lines:FIRST_RUN,<version>. Show current version in report.STALE_SESSION: 3 lines:STALE_SESSION,<loaded>,<cached>. The current session is running a version older than the marker — another newer session already ran. Skip E2 Auto-Sync entirely. Show in report: "⚠ ロード版 v<loaded> がマーカー版 v<cached> より古い — セッション再起動が必要"RESTART_REQUIRED: 3 lines:RESTART_REQUIRED,<loaded>,<installed>. A newer version is installed locally but not yet active. Skip E2 Auto-Sync entirely. Show in report: "⚠ 新版 v<installed> がインストール済み — セッション再起動で反映されます"NO_UPDATE: No action.UPDATED: 5 lines:UPDATED,<old>,<new>,VERSIONS: <N|UNKNOWN>,BREAKING: <M>. Parse counts for report.
E2. Auto-Sync on Plugin Update (only if UPDATED — STALE_SESSION / RESTART_REQUIRED 時は実行しない)
Read .claude/config.yml for platform. For each platform:
- Read
${CLAUDE_PLUGIN_ROOT}/addons/<platform>/addon.yml - Copy each
deployentry (overwrite without asking)
Always-sync files (all platforms):
| Plugin Source | Project Destination |
|---|---|
templates/issue/en/*.yml |
.github/ISSUE_TEMPLATE/*.yml |
templates/issue/ja/*.yml |
.github/ISSUE_TEMPLATE/*-ja.yml |
templates/pr/en/pull_request_template.md |
.github/pull_request_template.md |
Record synced files for the Phase 3 report.
F. Recent Activity (24h)
In parallel:
gh pr list --state merged --search "merged:>=$(date -u -v-24H +%Y-%m-%dT%H:%M:%SZ)" --limit 10 --json number,title,mergedAtgh issue list --state closed --json number,title,closedAt --limit 10— filter to last 24h
If both results are empty, skip the Recent Activity section.
G. Agent Teams Environment Check
Ensure CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 in .claude/settings.local.json (per-machine, gitignored).
- Read
.claude/settings.local.json:- Missing → create with:
Report: "Agent Teams env var configured."{ "env": { "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1" } } - Invalid JSON → warn: "
.claude/settings.local.jsoncontains invalid JSON — fix manually." Skip (do not block). - Valid JSON, key missing → deep-merge
{"env": {"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"}}, preserving all other keys. Report: "Agent Teams env var added." - Key present → no action.
- Missing → create with:
Phase 2: Status Assessment
| Status | Condition |
|---|---|
| Auto-returned | Branch auto-return ran in Phase 0 |
| Ongoing work | Not on main, unmerged commits exist |
| Clean start | On main, no uncommitted changes, no open PRs |
| Needs cleanup | Uncommitted changes present |
Phase 3: Summary Report
## Session Start Report
**Plugin Version:** atdd-kit vX.Y.Z
**Agent Teams:** Configured <-- only if settings.local.json was created or updated in Phase 1-G
**Updated: v<old> → v<new> (<N> versions, <M> breaking changes). See CHANGELOG.md for details.** <-- only if UPDATED
**⚠ BREAKING CHANGE detected** <-- only if UPDATED and BREAKING > 0
**⚠ ロード版 v<loaded> がマーカー版 v<cached> より古い — セッション再起動が必要** <-- only if STALE_SESSION
**⚠ 新版 v<installed> がインストール済み — セッション再起動で反映されます** <-- only if RESTART_REQUIRED
### Plugin Sync <-- only if UPDATED
| File | Status |
|------|--------|
| .github/ISSUE_TEMPLATE/development.yml | Updated |
| .github/pull_request_template.md | Updated |
| .claude/hooks/sim-pool-guard.sh | Updated (iOS) |
**Branch:** `<branch>` (<clean / uncommitted changes>)
### Previous Work <-- only if ongoing work exists
- PR #XX: <title> -- <CI status> / <review status> / ⚠ CONFLICTING <-- if ready (non-Draft) @me PR and mergeable == CONFLICTING, and branch NOT in session-lease-scan output
- 🔒 別セッション作業中: PR #YY: <title> <-- if open PR and branch is in session-lease-scan output (fresh lease held by another session); read-only display only; Draft/green/mergeable 問わず適用
### Recent Activity (24h) <-- only if recent activity exists
| Type | # | Title | When |
|------|---|-------|------|
| PR merged | #XX | <title> | 3h ago |
| Issue closed | #YY | <title> | 12h ago |
### Worktree Cleanup <-- only if stale worktrees were found
| Worktree | Action |
|----------|--------|
| worktree-123 | Pruned (orphaned) |
### Open Issues
| # | Title | Labels |
|---|-------|--------|
### Recommended Tasks
| Priority | Issue | Reason | 推奨経路 |
|----------|-------|--------|----------|
Task Recommendation Rules
Step 1: Build exclusion list
- Issues with
in-progresslabel → EXCLUDE_SET - Issues with open PRs (Phase 1-B) → add to EXCLUDE_SET
- Lease-based exclusion: Issues whose PR branch appears in
session-lease-scanoutput (fresh lease 保持 → 別セッション作業中) → add to EXCLUDE_SET(Draft/非 Draft・CI 状態・mergeable を問わず除外)
Step 2: Filter and rank
- Highest priority: ready (non-Draft)
@mePRs withmergeable == CONFLICTINGand whose branch is NOT insession-lease-scanoutput(別セッションの fresh lease を保持していないこと)— recommend rebase:
Any PR branch appearing ingit fetch origin main git checkout <branch> git rebase origin/main # After resolving conflicts git push --force-with-leasesession-lease-scanoutput(= 別セッションが fresh lease を保持中)は CONFLICTING であっても rebase 推奨から除外し、🔒 別セッション作業中として read-only 表示する(Draft / 非 Draft・CI 状態・mergeable を問わない)。 - Remove EXCLUDE_SET from open Issues
- Rank remaining: bugs > features > refactoring > research
Step 3: Route recommendation(経路判定)
各 Issue に autopilot または express の推奨経路を付与し、Recommended Tasks 表の「推奨経路」列に記入する。
判定基準(express 適格信号 / autopilot 信号 / 曖昧時フォールバック / 不変条件)は docs/methodology/route-eligibility.md に集約されている。