diff --git a/.claude/commands/check-coverage.md b/.claude/commands/check-coverage.md deleted file mode 100644 index b0646f74..00000000 --- a/.claude/commands/check-coverage.md +++ /dev/null @@ -1,100 +0,0 @@ -# check-coverage - -## 目的 - -テストカバレッジが全リポジトリ70%以上、クリティカルパス100%の基準を満たしているか確認する。カバレッジの詳細レポートを生成し、改善点を特定。 - -## 実行手順 - -1. **カバレッジの測定** - - ```bash - # カバレッジ付きでテストを実行 - npm run test -- --coverage - ``` - -2. **カバレッジサマリの確認** - - ```bash - # コンソールでサマリを表示 - npm run coverage:summary - ``` - -3. **詳細レポートの生成** - - ```bash - # HTMLレポートを生成 - npm run coverage:html - - # レポートの場所を表示 - echo "Coverage report: ./coverage/lcov-report/index.html" - ``` - -4. **クリティカルパスの確認** - - ```bash - # クリティカルパスのリストを確認 - echo "クリティカルパス:" - echo "- 認証/認可関連機能" - echo "- 決済処理" - echo "- セキュリティ関連機能" - echo "- データの保存/削除処理" - echo "- エラーハンドリング" - ``` - -5. **カバレッジが低いファイルの特定** - - ```bash - # カバレッジが50%未満のファイルをリスト - npm run coverage:low-files - ``` - -6. **カバレッジレポートのCI用出力** - - ```bash - # CI用のJUnit形式で出力 - npm run coverage:ci - ``` - -7. **カバレッジ履歴の確認** - ```bash - # 過去のカバレッジと比較 - git show HEAD~1:coverage/coverage-summary.json 2>/dev/null || echo "履歴なし" - ``` - -## 成功基準 - -- ✅ 全体のラインカバレッジが70%以上 -- ✅ ブランチカバレッジが60%以上 -- ✅ 関数カバレッジが65%以上 -- ✅ クリティカルパスのカバレッジが100% -- ✅ カバレッジレポートが正常に生成される - -## トラブルシューティング - -### カバレッジが基準を満たさない場合 - -1. HTMLレポートで未カバーのコードを確認 -2. 優先度順にテストを追加: - - クリティカルパス > ビジネスロジック > ユーティリティ -3. テストが難しいコードはリファクタリングを検討 - -### カバレッジが測定されない場合 - -1. `jest.config.js` またはテスト設定を確認 -2. `collectCoverageFrom` の設定を確認 -3. テストが実行されているか確認 - -### クリティカルパスの特定が難しい場合 - -1. ビジネス要件を確認 -2. セキュリティチームと連携 -3. リスクアセスメントを実施 -4. `.critical-paths.json` ファイルで明示的に定義 - -### カバレッジの向上方法 - -1. TDDを徹底(テストファースト) -2. モックを活用して依存関係を分離 -3. エッジケースのテストを追加 -4. カバレッジ目標を段階的に設定(60% → 70% → 80%) diff --git a/.claude/commands/commit.md b/.claude/commands/commit.md deleted file mode 100644 index 0156ce31..00000000 --- a/.claude/commands/commit.md +++ /dev/null @@ -1,168 +0,0 @@ -# Claude Command: Commit - -This command helps you create well-formatted commits with conventional commit messages and emoji. - -## Usage - -To create a commit, just type: - -``` -/commit -``` - -Or with options: - -``` -/commit --no-verify -``` - -## What This Command Does - -1. Unless specified with `--no-verify`, automatically runs pre-commit checks: - - `pnpm lint` to ensure code quality - - `pnpm build` to verify the build succeeds - - `pnpm generate:docs` to update documentation -2. Checks which files are staged with `git status` -3. If 0 files are staged, automatically adds all modified and new files with `git add` -4. Performs a `git diff` to understand what changes are being committed -5. Analyzes the diff to determine if multiple distinct logical changes are present -6. If multiple distinct changes are detected, suggests breaking the commit into multiple smaller commits -7. For each commit (or the single commit if not split), creates a commit message using emoji conventional commit format - -## Best Practices for Commits - -- **Verify before committing**: Ensure code is linted, builds correctly, and documentation is updated -- **Atomic commits**: Each commit should contain related changes that serve a single purpose -- **Split large changes**: If changes touch multiple concerns, split them into separate commits -- **Conventional commit format**: Use the format `: ` where type is one of: - - `feat`: A new feature - - `fix`: A bug fix - - `docs`: Documentation changes - - `style`: Code style changes (formatting, etc) - - `refactor`: Code changes that neither fix bugs nor add features - - `perf`: Performance improvements - - `test`: Adding or fixing tests - - `chore`: Changes to the build process, tools, etc. -- **Present tense, imperative mood**: Write commit messages as commands (e.g., "add feature" not "added feature") -- **Concise first line**: Keep the first line under 72 characters -- **Emoji**: Each commit type is paired with an appropriate emoji: - - ✨ `feat`: New feature - - 🐛 `fix`: Bug fix - - 📝 `docs`: Documentation - - 💄 `style`: Formatting/style - - ♻️ `refactor`: Code refactoring - - ⚡️ `perf`: Performance improvements - - ✅ `test`: Tests - - 🔧 `chore`: Tooling, configuration - - 🚀 `ci`: CI/CD improvements - - 🗑️ `revert`: Reverting changes - - 🧪 `test`: Add a failing test - - 🚨 `fix`: Fix compiler/linter warnings - - 🔒️ `fix`: Fix security issues - - 👥 `chore`: Add or update contributors - - 🚚 `refactor`: Move or rename resources - - 🏗️ `refactor`: Make architectural changes - - 🔀 `chore`: Merge branches - - 📦️ `chore`: Add or update compiled files or packages - - ➕ `chore`: Add a dependency - - ➖ `chore`: Remove a dependency - - 🌱 `chore`: Add or update seed files - - 🧑‍💻 `chore`: Improve developer experience - - 🧵 `feat`: Add or update code related to multithreading or concurrency - - 🔍️ `feat`: Improve SEO - - 🏷️ `feat`: Add or update types - - 💬 `feat`: Add or update text and literals - - 🌐 `feat`: Internationalization and localization - - 👔 `feat`: Add or update business logic - - 📱 `feat`: Work on responsive design - - 🚸 `feat`: Improve user experience / usability - - 🩹 `fix`: Simple fix for a non-critical issue - - 🥅 `fix`: Catch errors - - 👽️ `fix`: Update code due to external API changes - - 🔥 `fix`: Remove code or files - - 🎨 `style`: Improve structure/format of the code - - 🚑️ `fix`: Critical hotfix - - 🎉 `chore`: Begin a project - - 🔖 `chore`: Release/Version tags - - 🚧 `wip`: Work in progress - - 💚 `fix`: Fix CI build - - 📌 `chore`: Pin dependencies to specific versions - - 👷 `ci`: Add or update CI build system - - 📈 `feat`: Add or update analytics or tracking code - - ✏️ `fix`: Fix typos - - ⏪️ `revert`: Revert changes - - 📄 `chore`: Add or update license - - 💥 `feat`: Introduce breaking changes - - 🍱 `assets`: Add or update assets - - ♿️ `feat`: Improve accessibility - - 💡 `docs`: Add or update comments in source code - - 🗃️ `db`: Perform database related changes - - 🔊 `feat`: Add or update logs - - 🔇 `fix`: Remove logs - - 🤡 `test`: Mock things - - 🥚 `feat`: Add or update an easter egg - - 🙈 `chore`: Add or update .gitignore file - - 📸 `test`: Add or update snapshots - - ⚗️ `experiment`: Perform experiments - - 🚩 `feat`: Add, update, or remove feature flags - - 💫 `ui`: Add or update animations and transitions - - ⚰️ `refactor`: Remove dead code - - 🦺 `feat`: Add or update code related to validation - - ✈️ `feat`: Improve offline support - -## Guidelines for Splitting Commits - -When analyzing the diff, consider splitting commits based on these criteria: - -1. **Different concerns**: Changes to unrelated parts of the codebase -2. **Different types of changes**: Mixing features, fixes, refactoring, etc. -3. **File patterns**: Changes to different types of files (e.g., source code vs documentation) -4. **Logical grouping**: Changes that would be easier to understand or review separately -5. **Size**: Very large changes that would be clearer if broken down - -## Examples - -Good commit messages: - -- ✨ feat: add user authentication system -- 🐛 fix: resolve memory leak in rendering process -- 📝 docs: update API documentation with new endpoints -- ♻️ refactor: simplify error handling logic in parser -- 🚨 fix: resolve linter warnings in component files -- 🧑‍💻 chore: improve developer tooling setup process -- 👔 feat: implement business logic for transaction validation -- 🩹 fix: address minor styling inconsistency in header -- 🚑️ fix: patch critical security vulnerability in auth flow -- 🎨 style: reorganize component structure for better readability -- 🔥 fix: remove deprecated legacy code -- 🦺 feat: add input validation for user registration form -- 💚 fix: resolve failing CI pipeline tests -- 📈 feat: implement analytics tracking for user engagement -- 🔒️ fix: strengthen authentication password requirements -- ♿️ feat: improve form accessibility for screen readers - -Example of splitting commits: - -- First commit: ✨ feat: add new solc version type definitions -- Second commit: 📝 docs: update documentation for new solc versions -- Third commit: 🔧 chore: update package.json dependencies -- Fourth commit: 🏷️ feat: add type definitions for new API endpoints -- Fifth commit: 🧵 feat: improve concurrency handling in worker threads -- Sixth commit: 🚨 fix: resolve linting issues in new code -- Seventh commit: ✅ test: add unit tests for new solc version features -- Eighth commit: 🔒️ fix: update dependencies with security vulnerabilities - -## Command Options - -- `--no-verify`: Skip running the pre-commit checks (lint, build, generate:docs) - -## Important Notes - -- By default, pre-commit checks (`pnpm lint`, `pnpm build`, `pnpm generate:docs`) will run to ensure code quality -- If these checks fail, you'll be asked if you want to proceed with the commit anyway or fix the issues first -- If specific files are already staged, the command will only commit those files -- If no files are staged, it will automatically stage all modified and new files -- The commit message will be constructed based on the changes detected -- Before committing, the command will review the diff to identify if multiple commits would be more appropriate -- If suggesting multiple commits, it will help you stage and commit the changes separately -- Always reviews the commit diff to ensure the message matches the changes diff --git a/.claude/commands/fix-ci.md b/.claude/commands/fix-ci.md deleted file mode 100644 index 6bdadd08..00000000 --- a/.claude/commands/fix-ci.md +++ /dev/null @@ -1,134 +0,0 @@ -# fix-ci - -## 目的 - -CI失敗時の対応手順を提供し、24時間以内修正ルールを遵守する。CI Red → Slack #ci-alerts → 24h以内修正 or Owner Escalateのフローを実行。 - -## 実行手順 - -1. **CIエラーの特定** - - ```bash - # GitHub Actionsのログを確認 - gh run list --limit 5 - gh run view - - # 失敗したジョブの詳細を確認 - gh run view --log-failed - ``` - -2. **エラータイプの分類** - - ```bash - echo "エラータイプを確認:" - echo "1. テスト失敗" - echo "2. Lintエラー" - echo "3. ビルドエラー" - echo "4. セキュリティ/脆弱性" - echo "5. デプロイ失敗" - ``` - -3. **ローカルでの再現** - - ```bash - # CI環境と同じコマンドを実行 - npm ci - npm run test:all - npm run quality:check - npm run build - ``` - -4. **修正の実施** - - ### テスト失敗の場合 - - ```bash - # 失敗したテストを特定 - npm run test -- --verbose - # 修正後、再度テスト - npm run test -- --watch - ``` - - ### Lintエラーの場合 - - ```bash - # 自動修正を試す - npm run lint -- --fix - npm run format:fix - ``` - - ### ビルドエラーの場合 - - ```bash - # キャッシュをクリア - rm -rf node_modules package-lock.json - npm install - npm run build - ``` - - ### セキュリティ問題の場合 - - ```bash - # 脆弱性を修正 - npm audit fix - # 強制的に修正(注意が必要) - npm audit fix --force - ``` - -5. **修正の確認とプッシュ** - - ```bash - # ローカルでCIと同じチェックを実行 - npm run ci:check - - # 修正をコミット - git add . - git commit -m "fix: CIエラーを修正 (#)" - - # プッシュ - git push - ``` - -6. **CIの再実行を確認** - - ```bash - # CIがグリーンになるまでモニタリング - gh run watch - ``` - -7. **対応完了の報告** - ```bash - # Slack #ci-alertsへの報告テンプレート - echo "CI修正完了報告:" - echo "- エラー: <エラー内容>" - echo "- 原因: <原因>" - echo "- 対応: <対応内容>" - echo "- PR: #" - ``` - -## 成功基準 - -- ✅ CIがグリーンになる -- ✅ 24時間以内に修正完了 -- ✅ Slack #ci-alertsに報告済み -- ✅ 根本原因が特定され、再発防止策が実施される - -## トラブルシューティング - -### 24時間以内に修正できない場合 - -1. Ownerにエスカレーション -2. 一時的なワークアラウンドを検討 -3. RevertしてCIをグリーンにし、後日修正 - -### ローカルで再現しない場合 - -1. CI環境との差分を確認(Nodeバージョン、環境変数等) -2. DockerでCI環境を再現 -3. CIのキャッシュをクリア - -### 繰り返しCIが失敗する場合 - -1. Flakyテストの可能性を確認 -2. テストの安定性を改善(タイムアウト設定、非同期処理の改善) -3. CIパイプラインのリトライ設定を追加 diff --git a/.claude/commands/git-sync.md b/.claude/commands/git-sync.md new file mode 100644 index 00000000..7147c14c --- /dev/null +++ b/.claude/commands/git-sync.md @@ -0,0 +1,243 @@ +# Git Sync Commands + +## sync-main + +mainブランチに戻って最新版をpullする + +```bash +#!/bin/bash +set -e + +echo "🔄 Syncing with main branch..." + +# 現在のブランチを保存 +CURRENT_BRANCH=$(git branch --show-current) + +# 変更がある場合は確認 +if ! git diff --quiet || ! git diff --cached --quiet; then + echo "⚠️ Uncommitted changes detected!" + echo "Please commit or stash your changes before syncing." + exit 1 +fi + +# mainブランチに切り替え +echo "📦 Switching to main branch..." +git checkout main + +# 最新の変更を取得 +echo "⬇️ Pulling latest changes..." +git pull origin main + +echo "✅ Successfully synced with main branch!" +echo "📊 Latest commits:" +git log --oneline -5 +``` + +## sync-current + +現在のブランチを最新のmainと同期する + +```bash +#!/bin/bash +set -e + +echo "🔄 Syncing current branch with latest main..." + +# 現在のブランチを保存 +CURRENT_BRANCH=$(git branch --show-current) + +if [ "$CURRENT_BRANCH" = "main" ]; then + echo "📦 Already on main branch, pulling latest..." + git pull origin main +else + # 変更がある場合は確認 + if ! git diff --quiet || ! git diff --cached --quiet; then + echo "⚠️ Uncommitted changes detected!" + echo "Please commit or stash your changes before syncing." + exit 1 + fi + + echo "📦 Current branch: $CURRENT_BRANCH" + + # mainの最新を取得 + echo "⬇️ Fetching latest main..." + git fetch origin main + + # 現在のブランチにmainをマージ + echo "🔀 Merging latest main into $CURRENT_BRANCH..." + git merge origin/main + + echo "✅ Successfully synced $CURRENT_BRANCH with main!" +fi + +echo "📊 Latest commits:" +git log --oneline -5 +``` + +## create-pr + +現在のブランチからPRを作成する + +```bash +#!/bin/bash +set -e + +echo "🚀 Creating Pull Request..." + +# 現在のブランチを確認 +CURRENT_BRANCH=$(git branch --show-current) + +if [ "$CURRENT_BRANCH" = "main" ]; then + echo "❌ Cannot create PR from main branch!" + echo "Please create a feature branch first." + exit 1 +fi + +# 変更がある場合はコミット +if ! git diff --quiet || ! git diff --cached --quiet; then + echo "📝 Uncommitted changes detected." + read -p "Do you want to commit them? (y/n): " -n 1 -r + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + git add -A + read -p "Enter commit message: " COMMIT_MSG + git commit -m "$COMMIT_MSG" + else + echo "⚠️ Please commit your changes before creating a PR." + exit 1 + fi +fi + +# ブランチをプッシュ +echo "⬆️ Pushing branch to remote..." +git push -u origin "$CURRENT_BRANCH" + +# PRを作成 +echo "📝 Creating PR..." +gh pr create --fill + +echo "✅ Pull Request created successfully!" +``` + +## stash-and-sync + +変更を一時保存してmainと同期 + +```bash +#!/bin/bash +set -e + +echo "📦 Stashing changes and syncing with main..." + +# 変更がある場合はstash +if ! git diff --quiet || ! git diff --cached --quiet; then + echo "💾 Stashing current changes..." + git stash push -m "Auto-stash before sync $(date +%Y%m%d-%H%M%S)" + STASHED=true +else + STASHED=false +fi + +# 現在のブランチを保存 +CURRENT_BRANCH=$(git branch --show-current) + +# mainに切り替えて最新を取得 +echo "📦 Switching to main..." +git checkout main +git pull origin main + +# 元のブランチに戻る(mainでない場合) +if [ "$CURRENT_BRANCH" != "main" ]; then + echo "🔄 Returning to $CURRENT_BRANCH..." + git checkout "$CURRENT_BRANCH" + + # mainの変更をマージ + echo "🔀 Merging latest main..." + git merge main +fi + +# stashした変更を戻す +if [ "$STASHED" = true ]; then + echo "📤 Restoring stashed changes..." + git stash pop +fi + +echo "✅ Sync complete!" +echo "📊 Status:" +git status --short +``` + +## branch-status + +現在のブランチの状態を確認 + +```bash +#!/bin/bash + +echo "📊 Branch Status Report" +echo "=======================" + +# 現在のブランチ +CURRENT_BRANCH=$(git branch --show-current) +echo "📍 Current branch: $CURRENT_BRANCH" + +# リモートとの差分 +echo "" +echo "🔄 Remote status:" +git fetch origin --quiet +LOCAL=$(git rev-parse HEAD) +REMOTE=$(git rev-parse @{u} 2>/dev/null || echo "no-remote") + +if [ "$REMOTE" = "no-remote" ]; then + echo " ⚠️ No remote tracking branch" +else + if [ "$LOCAL" = "$REMOTE" ]; then + echo " ✅ Up to date with remote" + else + BEHIND=$(git rev-list --count HEAD..@{u}) + AHEAD=$(git rev-list --count @{u}..HEAD) + if [ "$BEHIND" -gt 0 ]; then + echo " ⬇️ Behind by $BEHIND commits" + fi + if [ "$AHEAD" -gt 0 ]; then + echo " ⬆️ Ahead by $AHEAD commits" + fi + fi +fi + +# mainとの差分 +if [ "$CURRENT_BRANCH" != "main" ]; then + echo "" + echo "📈 Comparison with main:" + git fetch origin main --quiet + BEHIND_MAIN=$(git rev-list --count HEAD..origin/main) + AHEAD_MAIN=$(git rev-list --count origin/main..HEAD) + + if [ "$BEHIND_MAIN" -gt 0 ]; then + echo " ⬇️ Behind main by $BEHIND_MAIN commits" + fi + if [ "$AHEAD_MAIN" -gt 0 ]; then + echo " ⬆️ Ahead of main by $AHEAD_MAIN commits" + fi + if [ "$BEHIND_MAIN" -eq 0 ] && [ "$AHEAD_MAIN" -eq 0 ]; then + echo " ✅ Even with main" + fi +fi + +# ローカルの変更 +echo "" +echo "📝 Local changes:" +CHANGES=$(git status --porcelain | wc -l) +if [ "$CHANGES" -eq 0 ]; then + echo " ✅ Working directory clean" +else + echo " 📄 Modified files: $(git diff --name-only | wc -l)" + echo " ➕ Staged files: $(git diff --cached --name-only | wc -l)" + echo " ❓ Untracked files: $(git ls-files --others --exclude-standard | wc -l)" +fi + +# 最近のコミット +echo "" +echo "📜 Recent commits:" +git log --oneline -5 +``` diff --git a/.claude/commands/init-project.md b/.claude/commands/init-project.md deleted file mode 100644 index a26b0d42..00000000 --- a/.claude/commands/init-project.md +++ /dev/null @@ -1,265 +0,0 @@ -# Project Initialization - -このプロジェクトではDevContainerを使用した開発環境を推奨しています。必要に応じて以下の設定を調整してください。 - -## 推奨開発環境 - -### DevContainerの使用 - -このプロジェクトは`.devcontainer/devcontainer.json`に定義されたDevContainerで開発することを前提としています。 - -すでに初期化されており、このコマンドが実行されている場合には、以下の内容を踏まえプロジェクト特有のfeaturesを追加/その他の設定の追加をしてください。 -プロジェクトの実際の要件を確認して、必要なfeaturesのみを含むように設定してください。 - -#### 推奨されるFeatures - -- **Node.js**: フロントエンド開発 -- **pnpm**: パッケージ管理("ghcr.io/devcontainers-extra/features/pnpm:2") -- **GitHub CLI (gh)**: PR作成やGitHub操作 -- **Git**: バージョン管理 -- **Terraform**: インフラ管理 -- **Google Cloud CLI**: GCP操作 -- **AWS CLI**: AWS操作 -- **kubectl**: Kubernetes操作 -- **act**: GitHub Actionsのローカル実行 -- **Homebrew**: 追加パッケージの管理 -- **jq-likes**: JSON/YAML処理ツール("ghcr.io/eitsupi/devcontainer-features/jq-likes:2") -- **1Password CLI**: セキュアな認証情報管理 - -https://containers.dev/features - -上記で存在の確認をしてから導入するようにしてください。 - -### DevContainerのカスタマイズ - -プロジェクト固有の要件がある場合は、`.devcontainer/devcontainer.json`の`features`セクションを編集してください: - -```json -"features": { - // 既存のfeatures... - // 新しいfeatureを追加 - "ghcr.io/devcontainers/features/python:1": { - "version": "3.11" - } -} -``` - -## プロジェクト固有の設定 - -### postCreateCommand - -コンテナ作成後に実行される処理: - -```bash -npm ci && npm run prepare -``` - -これによりHuskyなどのGit hooksが自動的にセットアップされます。 - -### マウント設定 - -ホストマシンの以下のディレクトリがコンテナにマウントされます: - -- `~/.gitconfig`: Git設定 -- `~/.gitignore`: Git ignore設定 -- `~/.config/gh/hosts.yml`: GitHub CLIの設定 - -## 推奨Git設定 - -### Commitlint設定(日本語対応) - -プロジェクトで日本語のコミットメッセージを使用する場合、`commitlint.config.js`に以下の設定を推奨します: - -```javascript -module.exports = { - extends: ['@commitlint/config-conventional'], - rules: { - 'subject-case': [0], // 日本語対応のため無効化 - 'subject-empty': [2, 'never'], - 'type-empty': [2, 'never'], - 'scope-empty': [0], - }, -}; -``` - -この設定により、日本語のコミットメッセージでも`subject-case`エラーが発生しなくなります。 - -### Conventional Commits - -以下の形式でコミットメッセージを記述します: - -``` -(): - - - -