Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Codex / Claude 向けの agent、skill、設定、プロンプトを管理し、

## ブランチ運用

- 作業ブランチをデフォルトブランチの最新状態へ追従させるときは、merge ではなく rebase を使用します。
- 作業ブランチをデフォルトブランチの最新状態へ追従させるときは、merge や `git rebase` ではなく `grape rebase` を使用します。

## 配布時の確認

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Codex / Claude などの AI エージェントに配布するルール、プロ
- `make deploy` で `deploy.json` と `external-skills.json` に基づいて設定とスキルを配置します。

`make deploy` は Codex 用の補助コマンドも `~/.codex/bin` に配置します。
`safe-git-push` は agent が prompt なしで使うための安全な `git push` wrapper です
push と rebase には、ポリシーに基づいて Git 操作を制限する `grape` を使います
`safe-gh-edit` は自分が作成した PR / Issue だけを prompt なしで編集するための `gh pr edit` / `gh issue edit` wrapper です。
`safe-local-curl` は localhost / loopback / private address 宛ての確認だけを prompt なしで行うための安全な `curl` wrapper です。

Expand Down
7 changes: 4 additions & 3 deletions claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ KPI やカバレッジ目標が与えられたら、達成するまで試行す

## ブランチ運用

- 作業ブランチをデフォルトブランチの最新状態へ追従させるときは、merge ではなく rebase を使用します。
- 作業ブランチをデフォルトブランチの最新状態へ追従させるときは、merge や `git rebase` ではなく `grape rebase` を使用します。

## コマンド実行確認
- prompt なしで実行できるのは、許可済みルールに合致し、実行内容と影響範囲が明確なコマンドだけです。
- 破壊的操作、外部送信、認証情報や設定の変更、履歴改変、実行先が曖昧なコマンドは、実行前にユーザーへ確認します。
- `git push` や `git push -f` は直接実行しません。prompt なしで push する場合は、引数なしの `~/.codex/bin/safe-git-push` を使います。
- `~/.codex/bin/safe-git-push` が拒否した場合やコマンドが見つからない場合は、拒否理由を確認してからユーザーに方針を確認します。
- `git push` や `git push -f` は直接実行せず、`grape push` を使います。
- rebase の開始には `git rebase` を直接使わず、`grape rebase` を使います。競合後の継続、中止、スキップに限り、`git rebase --continue`、`git rebase --abort`、`git rebase --skip` を使えます。
- `grape` が拒否した場合やコマンドが見つからない場合は Git コマンドへ自動的にフォールバックせず、拒否理由を確認してからユーザーに方針を確認します。
- `gh pr edit` や `gh issue edit` は直接実行しません。prompt なしで自分が作成した PR / Issue を編集する場合は、`~/.codex/bin/safe-gh-edit <pr|issue> <number> [gh edit flags...]` を使います。
- `~/.codex/bin/safe-gh-edit` が拒否した場合やコマンドが見つからない場合は、拒否理由を確認してからユーザーに方針を確認します。
- curl は localhost / loopback / Docker network 内の private address 宛てなら prompt なしで実行可能
38 changes: 35 additions & 3 deletions claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,36 @@
"defaultMode": "auto",
"allow": [
"Agent",
"Bash(git *)",
"Bash(git checkout -b *)",
"Bash(git switch *)",
"Bash(git status *)",
"Bash(git diff *)",
"Bash(git log *)",
"Bash(git fetch *)",
"Bash(git pull --ff-only *)",
"Bash(git show *)",
"Bash(git rev-parse *)",
"Bash(git merge-base *)",
"Bash(git ls-files *)",
"Bash(git grep *)",
"Bash(git remote -v)",
"Bash(git config --get *)",
"Bash(git submodule status *)",
"Bash(git branch --show-current)",
"Bash(git branch --list *)",
"Bash(git branch -a)",
"Bash(git commit *)",
"Bash(git add *)",
"Bash(git branch -d *)",
"Bash(git cherry-pick *)",
"Bash(git merge --ff-only *)",
"Bash(git stash *)",
"Bash(git worktree add *)",
"Bash(git worktree list *)",
"Bash(git worktree lock *)",
"Bash(git worktree move *)",
"Bash(git worktree repair *)",
"Bash(git worktree unlock *)",
"Bash(gh *)",
"Bash(tree)",
"Bash(tree *)",
Expand Down Expand Up @@ -72,8 +101,11 @@
"Bash(python3 -m pytest *)",
"Bash(mv *)",
"Bash(docker *)",
"Bash(safe-git-push)",
"Bash(~/.codex/bin/safe-git-push)",
"Bash(grape)",
"Bash(grape *)",
"Bash(git rebase --continue)",
"Bash(git rebase --abort)",
"Bash(git rebase --skip)",
"Bash(safe-gh-edit *)",
"Bash(~/.codex/bin/safe-gh-edit *)",
"Bash(safe-local-curl *)",
Expand Down
7 changes: 4 additions & 3 deletions codex/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ KPI やカバレッジ目標が与えられたら、達成するまで試行す

## ブランチ運用

- 作業ブランチをデフォルトブランチの最新状態へ追従させるときは、merge ではなく rebase を使用します。
- 作業ブランチをデフォルトブランチの最新状態へ追従させるときは、merge や `git rebase` ではなく `grape rebase` を使用します。

## コマンド実行確認
- prompt なしで実行できるのは、許可済みルールに合致し、実行内容と影響範囲が明確なコマンドだけです。
- 破壊的操作、外部送信、認証情報や設定の変更、履歴改変、実行先が曖昧なコマンドは、実行前にユーザーへ確認します。
- `git push` や `git push -f` は直接実行しません。prompt なしで push する場合は、引数なしの `~/.codex/bin/safe-git-push` を使います。
- `~/.codex/bin/safe-git-push` が拒否した場合やコマンドが見つからない場合は、拒否理由を確認してからユーザーに方針を確認します。
- `git push` や `git push -f` は直接実行せず、`grape push` を使います。
- rebase の開始には `git rebase` を直接使わず、`grape rebase` を使います。競合後の継続、中止、スキップに限り、`git rebase --continue`、`git rebase --abort`、`git rebase --skip` を使えます。
- `grape` が拒否した場合やコマンドが見つからない場合は Git コマンドへ自動的にフォールバックせず、拒否理由を確認してからユーザーに方針を確認します。
- `gh pr edit` や `gh issue edit` は直接実行しません。prompt なしで自分が作成した PR / Issue を編集する場合は、`~/.codex/bin/safe-gh-edit <pr|issue> <number> [gh edit flags...]` を使います。
- `~/.codex/bin/safe-gh-edit` が拒否した場合やコマンドが見つからない場合は、拒否理由を確認してからユーザーに方針を確認します。
- curl は外部アクセスを避けるため、prompt なしで実行する場合は `~/.codex/bin/safe-local-curl` を使います。
1 change: 0 additions & 1 deletion codex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ commands

Codex CLI から prompt なしで実行させる補助コマンドを配置します。

- `safe-git-push`: 引数なし専用の安全な push wrapper。`main` / `master` / detached HEAD / 不正な branch / 複数 push URL を拒否し、`git push origin HEAD:<current-branch>` だけを実行します。
- `safe-gh-edit`: 自分が作成した PR / Issue だけを編集できる `gh pr edit` / `gh issue edit` wrapper。対象の author と認証中の GitHub user が一致しない場合は拒否します。
- `safe-local-curl`: localhost / loopback / private address 宛ての URL だけを実行できる `curl` wrapper。よく使う読み取り系オプションだけを許可し、外部 URL や複数 URL を拒否します。

Expand Down
57 changes: 0 additions & 57 deletions codex/bin/safe-git-push

This file was deleted.

8 changes: 4 additions & 4 deletions codex/rules/allow.rules
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ prefix_rule(
)

prefix_rule(
pattern = ["git", "rebase"],
pattern = ["git", "rebase", ["--continue", "--abort", "--skip"]],
decision = "allow",
justification = "rebase はローカルブランチの履歴整理で通常安全"
justification = "grape rebase の競合後に継続、中止、スキップするため"
)

prefix_rule(
Expand All @@ -97,9 +97,9 @@ prefix_rule(
)

prefix_rule(
pattern = ["safe-git-push"],
pattern = ["grape"],
decision = "allow",
justification = "safe-git-push validates branch and remote before pushing"
justification = "grape provides policy-gated Git and worktree operations"
)

prefix_rule(
Expand Down
5 changes: 3 additions & 2 deletions codex/skills/internal/beautify-commit/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ description: Git リポジトリで、ベースブランチまたは残したい
- 基準 ref が未指定の場合、デフォルトブランチでよいか yes/no で確認してから進める。
- 履歴を書き換える操作をするときは、対象 branch と対象 commit 範囲を明確にする。
- push 済み、共有済み、PR 作成済みの履歴を書き換える場合は、実行前にユーザー確認を取る。
- `git reset --hard`、`git rebase -i`、`git commit --amend`、`git push --force` は、必要性と影響を説明してから使う。
- `git reset --hard`、`git commit --amend`、`grape push --force-with-lease` は、必要性と影響を説明してから使う。
- `git rebase -i` は使わない。interactive rebase が必要な整理は grape が対応するまで実行せず、制約をユーザーへ報告する。
- 分割作業の前に、可能なら `backup/<branch>-before-split-<date>` のようなバックアップ branch を作る。
- 読んでいない差分を stage しない。`git add .` ではなく、ファイル単位または patch 単位で stage する。
- 分割後は、それぞれの commit が単独で目的を説明できるか確認する。
Expand Down Expand Up @@ -73,4 +74,4 @@ description: Git リポジトリで、ベースブランチまたは残したい
- 作成した commit 一覧
- 残っている未コミット変更の有無
- 実行した検証、または未実行の理由
- force push など、ユーザー側で必要な次操作があるか
- `grape push --force-with-lease` など、ユーザー側で必要な次操作があるか
Original file line number Diff line number Diff line change
Expand Up @@ -89,48 +89,11 @@ git reset <base>

## 古い commit を分割する

直近ではない commit を分割する場合は、interactive rebase で対象 commit を `edit` にする。

```bash
git branch backup/<branch>-before-split-<date>
git rebase -i <target>^
```

rebase todo で分割したい commit を `edit` に変更する。
停止したら次を実行する。

```bash
git reset HEAD^
```

変更単位ごとに stage / commit し、分割が終わったら次を実行する。

```bash
git rebase --continue
```

注意:

- rebase 中に conflict が起きたら、差分を読み、解消後に `git add <resolved-files>`、`git rebase --continue` を実行する。
- conflict 解消で無関係な変更を混ぜない。
- rebase を中止する必要がある場合は `git rebase --abort` を使えるが、実行前に現在の状態を確認する。
直近ではない commit の分割には interactive rebase が必要だが、`grape rebase` は interactive mode をサポートしていない。`git rebase -i` へフォールバックせず、grape が対応するまでこの操作は実行しない。対象範囲と必要な操作を報告して終了する。

## commit を並べ替えたり統合したりしながら分割する

複数 commit の一部を統合、一部を分割、一部を並べ替える場合は、interactive rebase を使う。

使う操作:

- `pick`: commit をそのまま残す。
- `reword`: message だけ変更する。
- `edit`: commit の中身を変更、分割する。
- `squash` / `fixup`: 前の commit に統合する。
- 行の順序変更: commit 順を変更する。

注意:

- 並べ替えは依存関係を壊しやすい。build や test が通る順序か確認する。
- 同じファイルの近い行を複数 commit が触っている場合、conflict が増える可能性がある。
複数 commit の一部を統合、一部を分割、一部を並べ替える操作にも interactive rebase が必要になる。`git rebase -i` へフォールバックせず、grape が対応するまで実行しない。

## 安全確認

Expand All @@ -152,4 +115,4 @@ git rebase --continue
- `git log --oneline --decorate -n <必要数>` で commit 一覧を確認する。
- `git status --short` が想定どおりか確認する。
- 可能なら関連テスト、lint、build を実行する。
- push 済み履歴を書き換えた場合は、通常の push では失敗する可能性と force-with-lease が必要になり得ることを伝える。
- push 済み履歴を書き換えた場合は、通常の push では失敗する可能性と `grape push --force-with-lease` が必要になり得ることを伝える。
11 changes: 6 additions & 5 deletions codex/skills/internal/cmd-create-pr/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: cmd-create-pr
description: GitHub Pull Request を安全な手順で作成または更新するときに使う。ユーザーが「PR 作って」「PR 出して」「pull request 作成して」「この変更を PR にして」「pr を出す手順を進めて」などを依頼した場合は必ず使う。差分確認、検証、commit、最新 base branch への追従、role-reviewer による PR 前レビュー、High 指摘の自動対応、safe-git-push、PR description 作成、gh pr create / edit までの順序を整理し、未確認の変更や直接 git push を避ける。
description: GitHub Pull Request を安全な手順で作成または更新するときに使う。ユーザーが「PR 作って」「PR 出して」「pull request 作成して」「この変更を PR にして」「pr を出す手順を進めて」などを依頼した場合は必ず使う。差分確認、検証、commit、最新 base branch への追従、role-reviewer による PR 前レビュー、High 指摘の自動対応、grape push、PR description 作成、gh pr create / edit までの順序を整理し、未確認の変更や直接 git push を避ける。
---

# Create PR
Expand All @@ -16,8 +16,9 @@ GitHub Pull Request を出す前後の作業を、安全で再現しやすい手
- PR は「読んだ差分」「必要な検証」「意図が分かる commit」「レビューしやすい description」が揃ってから作る。
- ユーザーの未確認変更を勝手に commit、push、PR に含めない。
- PR 作成前に `git fetch origin` で base branch を更新し、head branch を最新 base に追従させる。古い base のままレビュー、push、PR 作成を進めない。
- `git push` は直接実行しない。prompt なしで push する場合は、引数なしの `~/.codex/bin/safe-git-push` を使う。
- `safe-git-push` が拒否した場合や見つからない場合は、拒否理由を確認してユーザーに方針を確認する。
- `git push` は直接実行せず、`grape push` を使う。
- rebase の開始には `git rebase` を直接使わず、`grape rebase` を使う。競合後の継続、中止、スキップには `git rebase --continue`、`git rebase --abort`、`git rebase --skip` を使える。
- `grape` が拒否した場合や見つからない場合は Git コマンドへ自動的にフォールバックせず、拒否理由を確認してユーザーに方針を確認する。
- 既存 PR がある場合は、新規作成ではなく更新を検討する。
- PR を新規作成または更新する前に `$role-reviewer` で差分をレビューし、High severity の指摘は PR 作成前に自動対応する。
- PR 本文を作るときは `$format-pr-description` を使う。
Expand Down Expand Up @@ -62,13 +63,13 @@ git fetch origin
- `git merge-base --is-ancestor origin/<base> HEAD` が成功するなら、head は最新 base に追従済み。
- 成功しない場合は、まず `git log --oneline HEAD..origin/<base>` と `git log --oneline origin/<base>..HEAD` で base 側と head 側の差分を確認する。
- current branch に独自 commit がない場合だけ、`git merge --ff-only origin/<base>` で fast-forward してよい。
- current branch に独自 commit がある場合は、merge commit 作成、rebase、作業の積み直しのどれを使うかユーザーへ確認する。確認なしに rebase や merge commit を作らない。
- current branch に独自 commit がある場合は、merge commit 作成、`grape rebase`、作業の積み直しのどれを使うかユーザーへ確認する。確認なしに rebase や merge commit を作らない。
7. 追従後に変更内容に合う検証を実行する。文書だけの変更なら、Markdown のリンク、見出し、差分確認で十分な場合がある。
8. `git log --oneline <base>..HEAD` と `git diff --stat <base>...HEAD` で PR 差分を確認する。
9. `$role-reviewer` で PR 差分をレビューする。レビュー対象は `<base>...HEAD` の差分、実行済み検証、未コミット変更の有無、最新 base への追従状況。
10. High severity の指摘がある場合は、PR 作成前に自動で対応する。対応後は必要な検証を再実行し、必要に応じて `$cmd-commit` で追加 commit を作る。
11. High 指摘が残っていないことを確認するまで `$role-reviewer` の確認を繰り返す。
12. `~/.codex/bin/safe-git-push` で current branch を push する。
12. `grape push` で current branch を push する。
13. `$format-pr-description` で PR description を作る。
14. 既存 PR がなければ `gh pr create`、既存 PR があれば `gh pr edit` で description を更新する。
15. `gh pr view` で URL、base、head、state を確認する。
Expand Down
Loading
Loading