← 一覧に戻る

リポジトリ整理: ghq 一本化計画(Codex レビュー反映 v2)

2026年3月28日 16:29 更新
MD から自動変換されたページです。内容について質問があれば右下の ? ボタンからどうぞ。

Context

ホームディレクトリに 51 個のリポジトリが ~/直下・~/projects/~/repos/ の 3 箇所に散乱している。 ghq + zoxide を導入済みなので、全リポを ~/ghq/github.com/{owner}/{repo} 構造に統一し、 ghq list で一覧・z で高速ジャンプできるようにする。

移動対象(51件)

場所 件数 備考
~/ 直下 9 バラバラに散乱
~/projects/ 40 空リポ2件は削除済み。chiba-bot3-issues(worktree)を含む
~/repos/ 2

手順

Step 0: 前提確認とバックアップ

# ghq が使えることを確認
eval "$(mise activate zsh)" && command -v ghq && ghq root
# → ~/ghq であること

# Time Machine の最新バックアップを確認
tmutil latestbackup

# 移動前 manifest を保存(ロールバック用)
find ~/ ~/projects ~/repos -maxdepth 1 -name ".git" -type d 2>/dev/null \
  | sed 's#/.git$##' | sort > /tmp/ghq-migration-manifest.txt

# 設定ファイルをバックアップ
cp ~/.claude.json ~/.claude.json.bak-ghq-migration
cp ~/.codex/config.toml ~/.codex/config.toml.bak-ghq-migration
cp ~/.claude/secretary/registry.json ~/.claude/secretary/registry.json.bak-ghq-migration
crontab -l > /tmp/crontab-backup-ghq-migration.txt

Step 1: worktree の事前処理(Critical: Codex 指摘)

chiba-botchiba-bot3 に追加 worktree が実在する。 worktree は .git ファイルに親リポの絶対パスを保持しているため、mv だけだと参照が切れる。

# 現状確認
git -C ~/projects/chiba-bot worktree list
git -C ~/projects/chiba-bot3 worktree list

# 方法: mv 後に git worktree repair で修復する(worktree remove は作業中ブランチを失うリスクがある)
# → Step 2 の mv 後、即座に repair を実行する

chiba-bot3-issueschiba-bot3 の worktree なので、chiba-bot3 と一緒に移動する必要がある。

Step 2: 常駐サービスの停止 → 移動 → 設定更新 → 起動

実行順序が重要: 先に移動して後から設定修正だと一時的に壊れる(Codex Medium 指摘)。 「停止 → 移動 → 設定更新 → 起動 → 検証」の順で進める。

2-1. 常駐サービスを停止

# launchd ジョブを停止(Codex High 指摘: 旧パスがハードコードされている)
launchctl bootout gui/$(id -u) ~/Library/LaunchAgents/com.aiharataketo.discord-claude-bot.plist 2>/dev/null
launchctl bootout gui/$(id -u) ~/Library/LaunchAgents/com.plan-viewer.httpserver.plist 2>/dev/null

2-2. リポジトリを物理移動(mv)

再 clone ではなく mv を使う理由:

移行スクリプトで一括実行する(マッピング表から自動生成、手作業しない)。

移動マッピング(全件):

~/直下(9件):

移動元 移動先 owner/repo
~/RVC-WebUI-MacOS NevilPatel01/RVC-WebUI-MacOS
~/ai-second-brain ramenumaiwhy/ai-second-brain
~/anthropic-skills anthropics/skills
~/mansion-checker ramenumaiwhy/mansion-checker
~/mlit-geospatial-mcp chirikuuka/mlit-geospatial-mcp
~/plan-viewer-plugin ramenumaiwhy/plan-viewer-plugin
~/reinfolib-plugin ramenumaiwhy/reinfolib-skill
~/reinfolib-service ramenumaiwhy/reinfolib-service
~/voice-self-model ramenumaiwhy/voice-self-model

~/projects/(40件、worktree の chiba-bot3-issues 含む):

移動元 移動先 owner/repo
Chiba-DailyNews-by-dify ramenumaiwhy/chiba-dailynews-by-dify
ConstructiveTalk ramenumaiwhy/ConstructiveTalk
REMINDERS ramenumaiwhy/REMINDERS
Tasks-on-Linear ramenumaiwhy/Tasks-on-Linear
ai-hara tejastice/ai-keisuke
automatic-video-explainer vab-labo/auto-movie-explainer
chiba-bot vab-labo/chiba-bot
chiba-bot3 vab-labo/chiba-bot3
chiba-bot3-issues vab-labo/chiba-bot3-issues(chiba-bot3 の worktree)
chiba-guide ramenumaiwhy/chiba-guide
chibabot-PWA vab-labo/chibabot-PWA
chibabot-release vab-labo/chibabot-release
chibabot vab-labo/chibabot
claude-farm-24-7 vab-labo/claude-farm-24-7
constructive-line-bot ramenumaiwhy/constructive-line-bot
dify-scheduler ramenumaiwhy/dify-scheduler
discord-claude-bot vab-labo/discord-claude-bot
discord-mcp ramenumaiwhy/discord-mcp
github-practice ramenumaiwhy/github-practice
hayaoshi-quiz ramenumaiwhy/hayaoshi-quiz
hono-cloudflare-boilerplate vab-labo/hono-cloudflare-boilerplate
instagram-automation ramenumaiwhy/instagram-automation
instagrammer-himeno vab-labo/instagrammer-himeno
instagrammer-risa ramenumaiwhy/instagrammer-risa
izumi vab-labo/izumi
kamui vab-labo/kamui
knowledge-chat2 ramenumaiwhy/knowledge-chat2
match-pilot vab-labo/match-pilot
meshi-tero vab-labo/meshi-tero
n8n-automation ramenumaiwhy/n8n-automation
n8n-ramenumaiwhy ramenumaiwhy/n8n-ramenumaiwhy
n8n Hiro5409/n8n
publish-man vab-labo/publish-man
pynder charliewolf/pynder
remindenwa ramenumaiwhy/remindenwa
reminder2 ramenumaiwhy/reminder2
renai-coach vab-labo/renai-coach
scheduler ramenumaiwhy/scheduler
vab-labo-web vab-labo/vab-labo-web
vab-labo vab-labo/vab-labo

~/repos/(2件):

移動元 移動先 owner/repo
remotion-promo-template ramenumaiwhy/remotion-promo-template(local only)
remotion-voicevox-template ramenumaiwhy/remotion-voicevox-template

2-3. worktree を修復

# mv 直後に repair で絶対パス参照を修正
git -C ~/ghq/github.com/vab-labo/chiba-bot worktree repair
git -C ~/ghq/github.com/vab-labo/chiba-bot3 worktree repair

2-4. パス参照を一括修正

crontab(3本のジョブ):

旧: /Users/aiharataketo/projects/match-pilot/scripts/...
新: /Users/aiharataketo/ghq/github.com/vab-labo/match-pilot/scripts/...

~/.claude.json(MCP サーバー起動パス — chibabot + mlit-geospatial-mcp):

旧: cd /Users/aiharataketo/projects/chibabot && ...
新: cd /Users/aiharataketo/ghq/github.com/vab-labo/chibabot && ...

旧: /Users/aiharataketo/mlit-geospatial-mcp
新: /Users/aiharataketo/ghq/github.com/chirikuuka/mlit-geospatial-mcp

加えて .claude.json 内の projectSettings キーも旧パスを含むが、これは過去設定なので放置でOK(新パスで開けば新しいキーが作られる)。

~/.codex/config.toml(Codex High 指摘: chibabot MCP + projects セクション):

旧: cd /Users/aiharataketo/projects/chibabot && ...
新: cd /Users/aiharataketo/ghq/github.com/vab-labo/chibabot && ...

旧: [projects."/Users/aiharataketo/projects/publish-man"]
新: [projects."/Users/aiharataketo/ghq/github.com/vab-labo/publish-man"]
(他の projects セクションも同様に更新)

~/.claude/secretary/registry.json:

旧: "repo_path": "/Users/aiharataketo/projects/remindenwa"
新: "repo_path": "/Users/aiharataketo/ghq/github.com/ramenumaiwhy/remindenwa"

~/.claude/scripts/promo-video-compact-hook.sh:

旧: RESEARCH_FILE="/Users/aiharataketo/projects/promo-video-skill-research.md"
→ これは projects/ 直下の非リポファイル。移動対象外なので放置。

2-5. シンボリックリンクを張り直し(Codex High 指摘: 6本)

# plan-viewer(2箇所)
ln -sfn ~/ghq/github.com/ramenumaiwhy/plan-viewer-plugin ~/.claude/plugins/local-marketplace/plan-viewer
ln -sfn ~/ghq/github.com/ramenumaiwhy/plan-viewer-plugin ~/.claude/plugins/plan-viewer

# reinfolib-plugin
ln -sfn ~/ghq/github.com/ramenumaiwhy/reinfolib-skill ~/.claude/plugins/local-marketplace/reinfolib-plugin

# ai-second-brain 系スクリプト(4本)
ln -sfn ~/ghq/github.com/ramenumaiwhy/ai-second-brain/scripts/session-reminder.sh ~/.claude/scripts/session-reminder.sh
ln -sfn ~/ghq/github.com/ramenumaiwhy/ai-second-brain/scripts/sync-codex-to-obsidian.sh ~/.claude/scripts/sync-codex-to-obsidian.sh
ln -sfn ~/ghq/github.com/ramenumaiwhy/ai-second-brain/tests/test-sync-recall.sh ~/.claude/scripts/test-sync-recall.sh
ln -sfn ~/ghq/github.com/ramenumaiwhy/ai-second-brain/scripts/sync-recall-to-obsidian.sh ~/.claude/scripts/sync-recall-to-obsidian.sh

2-6. launchd plist を更新して再起動

# plist 内のパスを sed で書き換え
sed -i '' 's|/Users/aiharataketo/projects/discord-claude-bot|/Users/aiharataketo/ghq/github.com/vab-labo/discord-claude-bot|g' ~/Library/LaunchAgents/com.aiharataketo.discord-claude-bot.plist
sed -i '' 's|/Users/aiharataketo/plan-viewer-plugin|/Users/aiharataketo/ghq/github.com/ramenumaiwhy/plan-viewer-plugin|g' ~/Library/LaunchAgents/com.plan-viewer.httpserver.plist

# 再起動
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.aiharataketo.discord-claude-bot.plist
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.plan-viewer.httpserver.plist

Step 3: 動作確認

# ghq がすべて認識しているか
ghq list | wc -l  # 51件前後

# worktree が正常か
git -C ~/ghq/github.com/vab-labo/chiba-bot worktree list
git -C ~/ghq/github.com/vab-labo/chiba-bot3 worktree list

# zoxide で飛べるか(新しいターミナルで)
z chibabot
z remindenwa
z mansion

# cron が動くか
bash ~/ghq/github.com/vab-labo/match-pilot/scripts/footprint-cron.sh

# シンボリックリンクが有効か
ls -la ~/.claude/plugins/local-marketplace/plan-viewer
ls -la ~/.claude/scripts/session-reminder.sh

# launchd が動いているか
launchctl list | grep -E '(discord-claude|plan-viewer)'

# Claude Code 再起動後に MCP サーバーが起動するか

Step 4: 旧ディレクトリの後処理(任意)

# 空になったか確認(非リポファイルが残る可能性あり)
ls ~/projects/
ls ~/repos/

# 空なら削除。残り物があれば個別判断
# rmdir ~/projects ~/repos  ← 空の場合のみ

ロールバック手順(部分失敗時)

# 1. manifest から逆順で mv を戻す
# /tmp/ghq-migration-manifest.txt に旧パス一覧がある

# 2. 設定ファイルを復元
cp ~/.claude.json.bak-ghq-migration ~/.claude.json
cp ~/.codex/config.toml.bak-ghq-migration ~/.codex/config.toml
cp ~/.claude/secretary/registry.json.bak-ghq-migration ~/.claude/secretary/registry.json
crontab /tmp/crontab-backup-ghq-migration.txt

# 3. シンボリックリンクを旧パスに戻す
# 4. launchd plist を復元して再起動

やらないこと(YAGNI)

Codex レビューで発見された問題と対応

重要度 問題 対応
Critical git worktree 未対応 Step 1 で事前確認、Step 2-3 で worktree repair
Critical ロールバック計画なし manifest + 設定バックアップ + 復旧手順を追加
High launchd 2本が旧パス Step 2-1 で停止、Step 2-6 で更新・再起動
High .claude.json の mlit-geospatial-mcp 漏れ Step 2-4 に追加
High .codex/config.toml 旧パス Step 2-4 に追加
High シンボリックリンク漏れ(reinfolib + ai-second-brain系) Step 2-5 に追加
Medium 実行順序リスク 停止→移動→設定更新→起動の順に再構成
Medium ~/projects/ 削除が成立しにくい Step 4 を任意作業に格下げ
Medium ghq 前提未検証 Step 0 に検証追加
Low ディレクトリ手作成が冗長 スクリプトで自動生成に統一
📝 質問モード — テキストを選択してね
✓ 質問を送信しました