APIエンドポイントの追加・変更で、DTO、入力検証、OpenAPI仕様、MCPツールの説明や公開範囲を揃え、エージェントからも扱いやすいAPIに整えます。
- APIエンドポイントを追加したいとき
- DTOと入力検証を整えたいとき
- MCPツールとしてAPIを公開したいとき
作業中の変更を誤って失わないよう、Git worktreeや対応する不要なPostgresデータベースを調査・分類し、確認後に整理するスキルです。
Use when cleaning up old git worktrees, removing worktrees whose branches have merged or been abandoned, or dropping orphaned compdev_* Postgres databases. Triggers on "clean up worktrees", "delete stale worktrees", "worktrees piling up", "orphaned databases", "remove unused worktree".
実行スコア 未検証
インストール方法を見る古いGit worktreeと、それに対応する開発用Postgresデータベースを調査し、状態に応じて整理候補を分類します。ブランチのマージ状況、プルリクエスト、未コミットの変更、未プッシュのコミットを確認し、残すものと確認が必要なものを区別します。候補と理由を一覧で示したうえで、承認されたworktreeとデータベースをまとめて削除し、作業後に残りを確認します。
worktreeが増えて整理したいときや、対応する開発用データベースが残っているか確認したいときに使えます。作業中の変更や未公開コミットを守りながら、削除候補を判断したい開発者にも向いています。
削除前に利用者の確認を求めます。変更のあるworktreeを強制削除する場合は明示的な承認が必要です。ローカルブランチは明示的に依頼されない限り削除しません。
この紹介文は、公開されている SKILL.md をもとに AI(OpenAI Codex)が作成しました。正確な仕様は下の原文を確認してください。
インストールする前に、エージェントに与えられる指示の中身を確認できます。
This repo's .githooks/post-checkout creates a per-worktree Postgres database (compdev_<slug>) on every git worktree add. Git has no pre-worktree-remove hook, so dead databases pile up over time. This skill defines a safe, reversible process to reap both the worktree directories and their dangling databases together.
Core principle: never delete work the user might still want. Classify first, ask second, remove last.
compdev_* DBs or running out of disk space from dead node_modulesgit worktree remove <path> + drop its DB directly — don't load the whole process)Run these four commands (parallel-safe) and capture the output:
git worktree list --porcelain
gh pr list --author @me --state all --limit 50 --json headRefName,state,url,number
git branch --no-color | cat
Then query the DB for compdev_* databases. The management URL is the main worktree's DATABASE_URL with the database path swapped to postgres:
bun -e '
import { Client } from "pg";
const raw = require("fs").readFileSync("packages/db/.env", "utf8");
const url = raw.match(/^DATABASE_URL=(.*)$/m)[1].replace(/^["\x27]|["\x27]$/g, "");
const mgmt = url.replace(/\/[^/?]+(\?|$)/, "/postgres$1");
const c = new Client({ connectionString: mgmt });
await c.connect();
const r = await c.query("SELECT datname FROM pg_database WHERE datname LIKE \x27compdev\\\\_%\x27 ORDER BY 1");
for (const row of r.rows) console.log(row.datname);
await c.end();
'
For each worktree (skip the main one):
| Signal | Classification |
|---|---|
| Branch merged to main AND clean working tree AND no unpushed commits | safe |
PR is CLOSED (not merged) | needs-confirm |
| Uncommitted changes OR unpushed commits | needs-confirm |
| No matching PR, no merge, has local commits | keep (user may still be working on it) |
| Is the main worktree | skip |
Gather per worktree:
cd <path> && git status --porcelain | wc -l — uncommitted changes countcd <path> && git log @{upstream}..HEAD --oneline 2>/dev/null | wc -l — unpushed commits (0 if no upstream)Show a table and explicit recommendations. Example:
Path Branch PR state Changes Recommendation
.worktrees/sale-45-… mariano/sale-45-… MERGED 0 / 0 ✅ safe to remove
.worktrees/old-experiment mariano/scratch — 3 / 0 ⚠ uncommitted — confirm first
.worktrees/worktree-env-auto-link mariano/worktree-env-auto-link OPEN 0 / 0 ⏳ keep (PR open)
Orphan databases (no worktree dir):
compdev_abandoned_feature
compdev_old_migration_test
Then ask: "Remove the items marked ✅? Confirm by listing anything you want me to also nuke from the ⚠ / ⏳ set."
For each worktree the user approved:
# 1. Remove the worktree dir (use --force only if user confirmed dirty-removal)
git worktree remove "<path>" # clean case
git worktree remove --force "<path>" # only after explicit user OK
# 2. Derive the slug and drop the database
slug=$(basename "<path>" | tr '[:upper:]' '[:lower:]' | tr '-' '_' | tr -cd 'a-z0-9_')
bun -e '
import { Client } from "pg";
const raw = require("fs").readFileSync("packages/db/.env", "utf8");
const url = raw.match(/^DATABASE_URL=(.*)$/m)[1].replace(/^["\x27]|["\x27]$/g, "");
const mgmt = url.replace(/\/[^/?]+(\?|$)/, "/postgres$1");
const c = new Client({ connectionString: mgmt });
await c.connect();
await c.query(`DROP DATABASE IF EXISTS "compdev_'"$slug"'"`);
await c.end();
console.log("dropped compdev_'"$slug"'");
'
For orphan databases (no matching worktree dir), just drop them — no worktree to remove.
Do NOT delete the local branch unless the user explicitly asked. Branches can be recreated from origin cheaply; worktrees cannot.
git worktree list
# then re-run the compdev_* query from step 1
Report back:
git worktree list --porcelain.--force without confirmation. Dirty worktrees can contain un-stashed work.DROP DATABASE on anything not matching ^compdev_[a-z0-9_]+$. Never drop comp, postgres, or any production-looking name.cd to the main worktree first.| Mistake | Fix |
|---|---|
| Dropping the DB but leaving the worktree dir | Run git worktree prune then git worktree remove |
| Removing the worktree but leaving the DB (accumulates orphans) | Always do both in the same pass |
| Using hyphens in the DB name | The hook slug rule is tr '-' '_' — always underscores |
| Running from inside a doomed worktree | cd to the main worktree before starting the process |
Using gh pr list on a branch with no PR | Missing data is not "abandoned" — needs needs-confirm classification |
If any of these show up mid-process, stop and ask the user:
git worktree remove errors with "working tree is not clean" → never retry with --force without explicit consentcompdev_* name has weird characters or unexpected format → don't drop# List everything
git worktree list --porcelain
gh pr list --author @me --state all --limit 50 --json headRefName,state
# Per-worktree inspection
git -C <path> status --porcelain
git -C <path> log @{upstream}..HEAD --oneline 2>/dev/null
# Clean removal
git worktree remove <path>
# Dirty removal (requires user confirmation first)
git worktree remove --force <path>
# Database drop (run from main worktree)
# See the bun -e snippets above for the exact invocation
まだレビューはありません。使ってみた感想をお寄せください。
ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。
まだコメントはありません。最初のコメントを書いてみませんか。
APIエンドポイントの追加・変更で、DTO、入力検証、OpenAPI仕様、MCPツールの説明や公開範囲を揃え、エージェントからも扱いやすいAPIに整えます。
既存コードのデザインシステム利用状況を調べ、旧UI部品やlucide-reactのアイコンを@trycompai/design-systemの部品・Carbonアイコンへ置き換えるスキルです。
指定されたファイルのフックやAPI利用を点検し、禁止パターンをSWRやapiClientなどの指定方式へ修正するための監査手順と実装規約をまとめています。
NestJSのAPIとフロントエンドを調べ、権限チェックや監査ログのルール違反を修正するための確認項目を示します。
権限で表示や操作が変わるコンポーネントの単体テストを点検し、不足分の追加や失敗の修正を行って、管理者と閲覧専用ユーザーの動作を確かめます。
Better Authを使ったTypeScript認証の設定を支援し、データベース接続、セッション管理、メール認証、OAuth、プラグインやセキュリティ項目を整理します。