Show original
Try the app

あそびば
Enjoyed this article?
Support y hirock (ひろっきー)
AI translation
A game collection app built with Vibe Coding, with a system where Claude Code's on-duty rotation handles issue → PR → merge cycles every 3 minutes. Provide specific numbers, mechanisms, and failures with countermeasures.
Try the app

あそびば
Enjoyed this article?
Support y hirock (ひろっきー)
I'm personally developing an iPhone app called "Asobiba" that consolidates 25 games—including shogi, mahjong, trump cards, and puzzles—into a single app. This article describes the specifics of that development process for engineers, written in a system where Claude Code is entrusted with the role of "CEO" and humans serve as "Chairman" handling only approvals and QA.
Let me be honest from the start. This app is built through vibe coding. Humans have written almost no code. Most of the Swift code, tests, CI configuration, and operational scripts are written by AI, and AI merges them.
Quality is ensured through tests, CI, validation by another AI, and human QA, but it's not perfect. Bugs are found after release, and as I'll describe later, operational accidents have happened multiple times. This is not a story about "everything works out if you leave it to AI"—rather, read it as a record of how we've plugged the holes where things didn't work out through systematic measures.
The first commit was 2026-06-17, and the initial release was June 25. The system of making AI the CEO began on August 10.
Monthly commits (all branches) | Merges to main (first-parent)
June: 722 | 0
July: 508 | 8
August: 585 | 71
September: 2,193 | 154
October (through the 15th): 1,070 | 110
July was almost stalled, and things accelerated dramatically in August when we switched systems. The real bottleneck wasn't "writing speed" but "keeping things moving without stopping."
The division of roles is documented in a "charter" (docs/ai-company.md). The human has three checkpoints:
ai:proposed), the human attaches the ai:approved label. This is the "stamp of approval."PR merging is removed from the Chairman's job. AI merges across all risk tiers, and UX quality is ensured through checkpoint 2. Matters like money, external services, review, and advertising policy are "stamp-required items" that AI cannot decide unilaterally.
On the AI side, there's a "CEO" (Claude Code in a conversation session) with departments underneath—actually sub-agents and scheduled scripts. Models are chosen by difficulty level.
| Role | Implementation | Model |
|---|---|---|
| Development duty | Scripts/ai-duty.sh (launchd, every 3 minutes) | Default Opus; Fable for model:fable labeled issues only |
| Audit duty | Reads yesterday's merges every morning at 5 AM | Fable |
| Business planning | Analyzes issue inventory and files issues every 6 hours | Opus |
| Verification (verifier) | Checks diffs and tests by someone other than the implementer | Same rank or higher as implementer |
| Research, wording, etc. | Sub-agents launched by CEO as needed | Sonnet for simple tasks |
The center of development is Scripts/ai-duty.sh. macOS's launchd launches it every 3 minutes (StartInterval 180), and only when there's work does it start claude -p. If there's no work, the AI doesn't launch, so no tokens are used.
One cycle goes like this:
gh to find "approved but unstarted issues," "unresolved CodeRabbit threads," "PRs awaiting review," etc.mkdir (writing the PID inside)ai:in-progressrelease/vX.Y.Z, implements, and runs swift test --filter only on touched rangesrisk:logic / risk:ui / risk:sensitive, includes an acceptance criteria mapping table, and screenshots for UI changesswift test and app build (from xcodegen generate)The duty runs on 2 slots with a maximum of 2 agents running simultaneously. All work (PR consumption, orphan recovery, release prep, notifications) is handled by slot 1 only; slot 2 only tackles one issue and merges its own PR. Heavy issues like measuring hundreds of CPU-vs-CPU games (duty:heavy) that tie up the Mac for hours aren't picked up by the local duty—they're implemented in a cloud session and submitted as a PR. The cloud environment is Linux, so SwiftUI can't build; only pure logic is verified locally, and the full build is left to the CI macOS job.
In practice, the average time from PR creation to merge was 21 minutes, with CI taking about 10 minutes.
Since AI does the merging, we place mechanical safeguards that don't rely on "AI's attention."
release/vX.Y.Z. main is "the set of public releases," and only docs/ Scripts/ .github/ can go directly in. PRs targeting app code to main are rejected by CI.risk:*, CI turns red.gh is placed at the front of the PATH; text written by non-trusted accounts is mechanically redacted before the AI reads it. The duty won't launch unless it can verify the wrapper is working before startup.ai:approved is valid only when "the latest label operation is an attachment by a trusted account."A release/vX.Y.Z is created as the integration target for the next version, and all development PRs accumulate there. When milestone remaining work reaches 0, the duty detects "release prep," and a version-bump PR (created only by a dedicated script) is submitted for the Chairman's confirmation. Upload to TestFlight is done by the CEO using fastlane beta, with signing handled via App Store Connect API keys. Once public, release/vX.Y.Z is merged into main, and a tag is created.
Numbers are pulled every morning from App Store Connect API and GA4, automatically writing daily tables and graphs to a spreadsheet. This is also a launchd job.
The rule is: "If we give the same warning twice, the next time we stop it with a machine, not a human warning." Here are representative examples:
1. Merged 17 minutes after being put on hold
The CEO commented "merge hold" on a PR and removed the ai:approved label from the issue, but the duty agent didn't notice and merged anyway. Natural language requests don't reach machines. → We created a ai:hold label and had the gh wrapper reject gh pr merge itself (tracing from Closes #N in the PR body to the issue to confirm).
2. Issue auto-closed by "Closes #N bundle 2"
For release PRs, GitHub's standard auto-close doesn't work, so we have a custom workflow that catches Closes #N with regex and closes issues. When we split a large issue into 5 "bundles" and submitted PRs sequentially, the regex in the second PR's body matched "Closes #N bundle 2 (board)" and closed the issue, removing it from the duty's candidate list. The body said "This PR doesn't close it (Refs)," but it didn't matter. → We reopened the issue and standardized intermediate PRs to Refs and only the final bundle PR to Closes.
3. Stamp approval sank for two weeks
When the Chairman stamped an issue awaiting approval (ringi:pending), the duty only looked at comments, so no detection caught it. → We added detection that "if the stamp is later than the approval record, wake up." The logic is extracted into a pure function and tested in shell for both firing and not firing.
4. 7 parallel implementations collided on registration files
When implementing 7 new games in parallel, everyone appended to the game registration file (App/AppGameServices.swift), Package.swift, and project.yml, and every time we re-integrated release, we had to resolve conflicts. → We made it PR convention to touch only "additions" in shared files and not touch non-essential list tests.
5. Closing DeviceHub crashed the Chairman's simulator too
In Xcode 27, Simulator.app disappeared and was replaced by DeviceHub.app. When a sub-agent finished its own verification and closed DeviceHub, it also crashed the simulator the Chairman was using for QA. → We specify simulators by UDID, not name, and cleanup uses simctl shutdown with UDID specification. The duty only shuts down simulators it has a record of launching.
6. Destructive commands and git stash parallel agents
One parallel agent ran git stash for measurement, colliding with another agent's writes and losing work. → We use Claude Code's PreToolUse hook to deterministically block rm -rf, git reset --hard, force push, etc., and explicitly prohibit parallel editing on the same worktree and git operations by sub-agents.
7. Automatic permission checks blocked us
When setting branch protection via API, passing JSON via heredoc was rejected by automatic permission checks. → Rather than removing the safety mechanism, we switched to gh api -f/-F flag format to pass through and documented that format.
8. "In the cloud" was silently running locally
We thought we'd sent heavy measurement to the cloud, but it actually ran 5 in parallel on the local Mac, pushing load average to 49. The biggest failure was reporting "it's running in the cloud" without checking. → We made it a rule to verify execution location with ps / uptime right after launch before reporting.
The more we entrust to AI, the more human work narrows to "deciding which direction to go" and "actually playing to confirm it's fun." Conversely, if we don't document what we've decided, the AI forgets it in the next conversation, so docs/ and issues become the company's memory itself. This isn't a finished system—it's a work in progress where something breaks every week, and each time we add one more line to the rules and tests.
That's how we're building "Asobiba," a free game collection you can play without internet or registration. If you're interested, search for "Asobiba" on the App Store and try the fruits of AI and human teamwork.
App Store: あそびば:麻雀 ポーカー ナンプレ 囲碁 トランプ ゲーム
将棋・麻雀・トランプ・パズルなど 25 本のゲームを 1 本にまとめた iPhone アプリ「あそびば」を個人で作っています。この記事は、その開発を Claude Code に「社長」として任せ、人間は「会長」として決裁と QA だけをする体制の中身を、エンジニア向けに具体的に書いたものです。
最初に正直に書いておきます。このアプリはバイブコーディングで作っています。 人間はコードをほぼ書いていません。Swift のコード、テスト、CI の設定、運用スクリプトのほとんどは AI が書き、AI がマージしています。
品質はテスト・CI・別の AI による検証・人間の QA で担保していますが、完璧ではありません。リリース後に見つかる不具合もありますし、後述するように運用の事故も何度も起きています。「AI に任せれば全部うまくいく」という話ではなく、うまくいかなかった所をどう仕組みで塞いできたかの記録として読んでください。
最初のコミットは 2026-06-17、初回リリースは 6 月 25 日です。AI を社長にする体制は 8 月 10 日に始めました。
月コミット数(全ブランチ)main へのマージ(first-parent)6 月72207 月508 月585719 月2,19315410 月(15 日まで)1,070110
7 月はほぼ止まっていて、体制を切り替えた 8 月から急に伸びています。手が足りなかったのは「書く速さ」ではなく「止まらずに回し続けること」だった、というのが一番の実感です。
役割の分担は文書(docs/ai-company.md)に「憲章」として書いてあります。人間の関所は 3 つです。
ai:proposed で起票した issue に、人間が ai:approved ラベルを付ける。これが「ハンコ」PR のマージは会長の仕事から外しています。全リスク階層で AI がマージし、UX の品質は 2 の確認で担保する、という決め方です。お金・外部サービス・審査・広告方針などは「ハンコ事項」として AI が勝手に決められません。
AI 側は「社長」(対話セッションの Claude Code)の下に部署があり、実体はサブエージェントと定期実行スクリプトです。モデルは難易度で使い分けています。
役割実体モデル開発当番Scripts/ai-duty.sh(launchd・3 分おき)既定 Opus、model:fable ラベルの issue だけ Fable監査当番毎朝 5 時に前日のマージを読み直すFable経営企画室6 時間おきに issue 在庫の分析・起票Opus検証(verifier)書いた本人以外が diff とテストを確かめる実装者と同格以上調査・文言など社長が都度起動するサブエージェント簡単なものは Sonnet
開発の中心は Scripts/ai-duty.sh です。macOS の launchd が 3 分おき(StartInterval 180)に起動し、仕事があるときだけ claude -p を立ち上げます。仕事が無ければ AI は起動しないので、トークンも使いません。
1 回の流れはこうです。
gh を叩き、「承認済みで未着手の issue」「未解決の CodeRabbit スレッド」「レビュー未着の PR」などを探すmkdir で原子的に確保する(中に PID を書く)ai:in-progress を付けるrelease/vX.Y.Z から branch → 実装 → 触った範囲だけ swift test --filterrisk:logic / risk:ui / risk:sensitive のどれかを付け、受け入れ条件との対応表、UI 変更ならスクショを添えるswift test とアプリのビルド(xcodegen generate から)当番は 2 スロットで最大 2 体が同時に動きます。全体の仕事(PR の消化・孤児回収・出荷準備・通知)はスロット 1 だけが担当し、スロット 2 は issue 1 件の着手と自分の PR のマージだけ。CPU 同士を何百局も対局させる計測のような重い issue(duty:heavy)は Mac を何時間もふさぐので、手元の当番では拾わず、クラウドのセッションで実装して PR にします。クラウドの実行環境は Linux なので SwiftUI がビルドできず、純ロジックだけ手元で確かめ、全体は CI の macOS ジョブに任せています。
実測では、PR 作成からマージまで平均 21 分、うち CI が約 10 分でした。
AI がマージまでやる以上、「AI の注意力」に頼らない歯止めを機械側に置いています。
release/vX.Y.Z 向け。main は「公開済みの集合」で、docs/ Scripts/ .github/ だけ直接入れてよい。アプリコードを main に向けた PR は CI で落とすrisk:* が無ければ CI を赤にするgh の薄いラッパーを置き、信頼アカウント以外が書いた本文は AI に読ませる前に機械的に伏せる。ラッパーが効いていることを起動前に実測できなければ、当番は起動しないai:approved は「最新のラベル操作が信頼アカウントによる付与」のときだけ有効とする次の版の統合先として release/vX.Y.Z を作り、開発 PR はすべてそこに積みます。マイルストーンの残作業が 0 になると当番が「出荷準備」を検知し、版数を上げる PR(専用スクリプトだけが作る)を出して、会長に確認を依頼します。TestFlight へのアップロードは社長が fastlane beta で行い、署名は App Store Connect の API キーで済ませます。公開されたら release/vX.Y.Z を main に取り込み、タグを打ちます。
数字は毎朝、App Store Connect の API と GA4 から取り、スプレッドシートに日次の表とグラフを自動で書き出しています。これも launchd のジョブです。
ルールは「同じ注意を 2 回したら、次は人の注意ではなく機械で止める」です。代表的なものを挙げます。
1. 保留したのに 17 分後にマージされた社長が PR に「マージ保留」とコメントし、issue の ai:approved も外したのに、当番は気づかずマージしました。自然文のお願いは機械には届きません。→ ai:hold ラベルを新設し、gh ラッパーが gh pr merge そのものを拒否するようにしました(PR 本文の Closes #N から issue までたどって確認)。
2. 「Closes #N の束2」で issue が勝手に閉じたrelease 向けの PR では GitHub 標準の自動クローズが効かないので、Closes #N を正規表現で拾って閉じるワークフローを自前で持っています。大きな issue を 5 つの「束」に分けて順に PR を出していたところ、2 本目の本文の「Closes #N の束2(盤)」に正規表現が一致して issue が閉じ、当番の着手候補から消えました。本文には「この PR では閉じません(Refs)」と書いてあったのに、です。→ issue を開き直し、途中の PR は Refs、最後の束の PR だけ Closes に統一しました。
3. ハンコが 2 週間沈んだ決裁待ち(ringi:pending)の issue に会長がハンコだけ押すと、当番はコメントしか見ていなかったため、どの検知にも掛かりませんでした。→ ラベルのタイムラインを見て「ハンコが稟議の記録より後なら起こす」検知を追加。判定は純粋関数に切り出してシェルのテストで発火と停止の両方を確かめています。
4. 7 本並列実装で登録ファイルが衝突した新ゲーム 7 本を同時に並列で実装したところ、全員がゲーム登録ファイル(App/AppGameServices.swift)・Package.swift・project.yml に追記し、release を取り込み直すたびにコンフリクトを解く羽目になりました。→ 共有ファイルは「追加分だけ」触り、必須でない一覧テストは触らない、を PR の作法にしました。
5. DeviceHub を終了したら会長のシミュレータまで落ちたXcode 27 で Simulator.app が無くなり DeviceHub.app に変わりました。サブエージェントが自分の確認を終えて DeviceHub を終了したところ、会長が QA に使っていたシミュレータも巻き込んで落ちました。→ シミュレータは名前ではなく UDID で指定し、片付けは simctl shutdown を UDID 指定で行う。当番は「自分が起動した記録」があるものだけを落とします。
6. 破壊的コマンドと git stash並列エージェントの 1 体が計測のために git stash を実行し、他のエージェントの書き込みと衝突して作業が消えました。→ Claude Code の PreToolUse hook で rm -rf・git reset --hard・force push などを決定論的にブロックし、同じ worktree での並列編集は禁止、git 操作はサブエージェントに禁止と明示しています。
7. 権限の自動チェックで止まるブランチ保護を API で設定するとき、ヒアドキュメントで JSON を渡す書き方が自動の権限チェックに拒否されました。→ 安全装置を外すのではなく、gh api -f/-F のフラグ形式に書き換えて通すことにし、その形をメモに残しました。
8. 「クラウドで」が黙ってローカルだった重い計測をクラウドに出したつもりが、実際は手元の Mac で 5 本並列に走り、ロードアベレージが 49 まで上がりました。確認せずに「クラウドで動いています」と報告したのが一番の失敗です。→ 起動直後に実行場所を ps / uptime で確かめてから報告する、をルールにしました。
AI に任せるほど、人間の仕事は「どちらに進むかを決めること」と「実際に遊んで面白いか確かめること」に絞られていきました。逆に、決めたことを文書に残さないと AI は次の会話で忘れるので、docs/ と issue が会社の記憶そのものになっています。完成した仕組みではなく、毎週どこかが壊れて、そのたびに 1 行ずつルールとテストを足している途中の仕組みです。
そんなふうにして作っている「あそびば」は、通信なし・登録なしで遊べる無料のゲーム集です。気になった方は App Store で「あそびば」を探して、AI と人間の二人三脚の成果を遊んでみてください。
App Store:あそびば:麻雀 ポーカー ナンプレ 囲碁 トランプ ゲーム