diff --git a/.codex/config.toml b/.codex/config.toml new file mode 100644 index 00000000..c66f05fc --- /dev/null +++ b/.codex/config.toml @@ -0,0 +1,11 @@ +notify = ["bash", "-lc", "afplay /System/Library/Sounds/Glass.aiff"] + +[mcp_servers.playwright] +command = "npx" +args = ["@playwright/mcp@latest"] + +[mcp_servers.o3] +command = "npx" +args = ["o3-search-mcp"] +# Set OPENAI_API_KEY via environment to avoid committing secrets +env = { OPENAI_API_KEY = "", SEARCH_CONTEXT_SIZE = "medium", REASONING_EFFORT = "medium" } diff --git a/.codex/prompts/README.md b/.codex/prompts/README.md new file mode 100644 index 00000000..7195933b --- /dev/null +++ b/.codex/prompts/README.md @@ -0,0 +1,334 @@ +# Claude Automated Commands + +This directory contains 14 pre-configured commands that provide automated workflows for common development tasks. These commands can be invoked directly by Claude or triggered automatically based on repository events and context. + +## Command Categories + +### Quality & Testing + +#### `check-coverage.md` + +**Purpose**: Analyzes test coverage reports and identifies areas needing attention +**Triggers**: + +- Coverage drops below configured thresholds +- New code additions without corresponding tests +- Manual coverage analysis requests + +#### `quality-check.md` + +**Purpose**: Runs comprehensive code quality analysis including linting, formatting, and static analysis +**Triggers**: + +- Pre-commit hooks +- Pull request creation +- Manual quality validation requests + +#### `test-all.md` + +**Purpose**: Executes complete test suite with proper reporting and failure analysis +**Triggers**: + +- Major code changes +- Release preparation +- CI/CD pipeline integration + +### Project Management + +#### `init-project.md` + +**Purpose**: Sets up new projects with standardized structure, tools, and configurations +**Features**: + +- Dependency management setup +- CI/CD pipeline configuration +- Quality gate establishment +- Documentation templates + +#### `issue-auto-resolve.md` + +**Purpose**: Automated issue analysis and resolution using specialized agents +**Capabilities**: + +- Issue classification and priority assessment +- Automated fix generation for common problems +- Multi-agent coordination for complex issues +- Solution validation and testing + +#### `issue-create.md` + +**Purpose**: Creates well-structured GitHub issues with proper templates and metadata +**Features**: + +- Issue template selection +- Automatic labeling and assignment +- Related issue linking +- Priority and milestone setting + +#### `issue-review.md` + +**Purpose**: Reviews existing issues for completeness, priority, and actionability +**Functions**: + +- Issue triage and categorization +- Duplicate detection and consolidation +- Priority reassessment +- Resolution pathway recommendations + +### Pull Request Workflow + +#### `pr.md` + +**Purpose**: Comprehensive pull request analysis and preparation +**Features**: + +- Automated PR description generation +- Change impact analysis +- Reviewer suggestion based on code ownership +- Merge readiness assessment + +#### `review-feedback-processor.md` + +**Purpose**: Processes and responds to code review feedback systematically +**Capabilities**: + +- Feedback categorization and prioritization +- Automated response generation +- Code change suggestions +- Discussion thread management + +### CI/CD & Maintenance + +#### `fix-ci.md` + +**Purpose**: Diagnoses and resolves continuous integration pipeline failures +**Diagnostic Areas**: + +- Build failures and dependency issues +- Test failures and environment problems +- Deployment issues and configuration errors +- Performance bottlenecks and resource constraints + +#### `security-review.md` + +**Purpose**: Conducts comprehensive security analysis of code changes +**Security Checks**: + +- Vulnerability scanning and assessment +- Authentication and authorization validation +- Data protection compliance +- Security best practices enforcement + +#### `update-deps.md` + +**Purpose**: Manages dependency updates with safety checks and compatibility validation +**Features**: + +- Automated dependency analysis +- Breaking change detection +- Security vulnerability assessment +- Update strategy recommendations + +### Integration & Automation + +#### `n8n-mcp-setup.md` + +**Purpose**: Configures n8n workflows with Model Context Protocol (MCP) integration +**Setup Areas**: + +- Workflow automation configuration +- API endpoint integration +- Event trigger setup +- Data flow optimization + +#### `commit.md` + +**Purpose**: Ensures commit message quality and conventional commit compliance +**Validation**: + +- Conventional commit format enforcement +- Commit message clarity and completeness +- Change scope validation +- Breaking change identification + +## Command Usage + +### Direct Invocation + +Commands can be invoked directly in Claude interactions: + +``` +@claude run the quality-check command on the current branch +@claude execute check-coverage for the test suite +@claude use fix-ci to diagnose the build failure +@claude run issue-auto-resolve for issue #123 +``` + +### Automatic Triggers + +Commands are automatically triggered by: + +- **Repository Events**: Push, PR creation, issue updates +- **Quality Thresholds**: Coverage drops, lint failures, security issues +- **Time-based Triggers**: Scheduled maintenance, dependency updates +- **Context Patterns**: Specific file changes, error patterns, user actions + +### Workflow Integration + +Commands integrate with development workflows through: + +- **GitHub Actions**: Automated execution in CI/CD pipelines +- **Git Hooks**: Pre-commit, pre-push, and post-merge execution +- **IDE Integration**: Direct invocation from development environments +- **Slack/Teams**: Notification-driven execution + +## Command Configuration + +### Global Settings + +Command behavior is configured in: + +- `.claude/settings.json`: Global command preferences and thresholds +- `.claude/CLAUDE.md`: Quality standards and workflow requirements +- Repository-specific overrides in individual command files + +### Environment Variables + +Commands support customization through environment variables: + +- `CLAUDE_COVERAGE_THRESHOLD`: Test coverage requirements +- `CLAUDE_SECURITY_LEVEL`: Security analysis strictness +- `CLAUDE_CI_TIMEOUT`: CI operation timeout limits +- `CLAUDE_REVIEWER_COUNT`: Required reviewer count for PRs + +### Quality Gates + +Commands enforce quality standards through: + +- **Coverage Requirements**: 70%+ line coverage for all repositories +- **Security Standards**: Critical vulnerability blocking +- **Performance Thresholds**: Response time and resource usage limits +- **Documentation Standards**: Completeness and consistency requirements + +## Best Practices + +### For Development Teams + +#### Command Usage + +- **Use specific commands** for targeted analysis and fixes +- **Combine commands** for comprehensive workflows +- **Monitor command results** and act on recommendations +- **Customize thresholds** based on project requirements + +#### Integration Strategies + +- **Incorporate in CI/CD** for automated quality assurance +- **Use in code reviews** for consistent feedback +- **Schedule regular maintenance** commands for proactive management +- **Train team members** on command capabilities and usage + +### For Project Maintainers + +#### Configuration Management + +- **Set appropriate thresholds** for quality gates +- **Customize command behavior** for technology stack +- **Monitor command performance** and effectiveness +- **Update configurations** based on team feedback + +#### Workflow Optimization + +- **Identify bottlenecks** in development processes +- **Automate repetitive tasks** with command workflows +- **Measure improvement** in code quality and velocity +- **Refine triggers** based on usage patterns + +## Advanced Usage + +### Command Chaining + +Commands can be chained for complex workflows: + +``` +@claude run quality-check followed by test-all, then create a PR if all pass +@claude execute issue-auto-resolve, update dependencies, and run security-review +``` + +### Conditional Execution + +Commands support conditional execution based on context: + +``` +@claude run fix-ci only if tests are failing +@claude execute security-review if changes affect authentication code +@claude run check-coverage if new code was added +``` + +### Custom Workflows + +Create custom workflows by combining commands: + +```yaml +# Example: Release Preparation Workflow +- quality-check +- test-all +- check-coverage +- security-review +- update-deps +- pr (with release template) +``` + +## Monitoring and Analytics + +### Command Performance + +Monitor command effectiveness through: + +- **Execution time** and resource usage +- **Success rates** and failure patterns +- **Code quality improvements** over time +- **Developer productivity** metrics + +### Quality Trends + +Track quality improvements through: + +- **Coverage trend** analysis +- **Security vulnerability** reduction +- **CI/CD reliability** improvements +- **Issue resolution time** reduction + +## Troubleshooting + +### Command Failures + +If commands fail or produce unexpected results: + +1. **Check prerequisites** (dependencies, permissions, environment) +2. **Review configuration** (settings, thresholds, environment variables) +3. **Examine logs** for error messages and stack traces +4. **Test manually** with reduced scope or simplified inputs +5. **Update command definitions** if necessary + +### Performance Issues + +If commands are slow or timing out: + +1. **Review scope** and reduce if necessary +2. **Check resource availability** (memory, CPU, network) +3. **Optimize thresholds** and filters +4. **Consider parallel execution** for independent operations +5. **Monitor API rate limits** and usage + +### Integration Problems + +If commands don't integrate properly with workflows: + +1. **Verify trigger configurations** and event handling +2. **Check permissions** and access controls +3. **Review environment variables** and context passing +4. **Test isolated execution** before workflow integration +5. **Update integration configurations** as needed + +For detailed configuration and customization options, see the main [CLAUDE.md](../CLAUDE.md) documentation. diff --git a/.codex/prompts/git-sync.md b/.codex/prompts/git-sync.md new file mode 100644 index 00000000..7147c14c --- /dev/null +++ b/.codex/prompts/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/.codex/prompts/setup-husky.md b/.codex/prompts/setup-husky.md new file mode 100644 index 00000000..98374421 --- /dev/null +++ b/.codex/prompts/setup-husky.md @@ -0,0 +1,128 @@ +Husky + lint-staged + commitlint 最小構成 + +コミット前に軽量な自動整形と静的チェックを行い、プッシュ前とCIで重い検証を実行します。 + +方針 +• pre-commit: ステージ済みファイルに対して ESLint 自動修正と Prettier 整形を高速実行 +• pre-push: 型チェックとテストを実行 +• commit-msg: Conventional Commits を commitlint で検証 +• npm --prefix next で一貫して next/ の依存を使用 + +⸻ + +セットアップ + +npm i -D husky lint-staged @commitlint/cli @commitlint/config-conventional +npm pkg set scripts.prepare="husky" +npm run prepare +npx husky add .husky/pre-commit "npx lint-staged" +npx husky add .husky/commit-msg "npx commitlint --edit \$1" +npx husky add .husky/pre-push "npm --prefix next run type-check && npm --prefix next run test:ci" + +⸻ + +必要な npm scripts(next/package.json) + +{ +"scripts": { +"type-check": "tsc --noEmit", +"lint": "eslint .", +"format": "prettier --write .", +"format:check": "prettier --check .", +"test:ci": "jest --ci --runInBand" +} +} + +⸻ + +設定ファイル + +.lintstagedrc.json(リポジトリルート) + +{ +"next/**/\*.{ts,tsx}": [ +"npm --prefix next exec eslint --cache --cache-location .cache/eslint --max-warnings=0 --fix", +"npm --prefix next exec prettier --write" +], +"next/**/\*.{js,jsx,json,md,css,scss}": [ +"npm --prefix next exec prettier --write" +] +} + +.commitlintrc.json(リポジトリルート) + +{ +"extends": ["@commitlint/config-conventional"] +} + +.eslintignore(任意、next/に配置) + +node_modules +.next +dist +coverage +public + +.prettierignore(任意、next/に配置) + +node_modules +.next +dist +coverage +build + +package.json(任意、ルート。Nodeバージョン固定) + +{ +"engines": { +"node": ">=20 <23" +} +} + +.nvmrc(任意、ルート) + +20 + +⸻ + +CI 例(GitHub Actions) + +.github/workflows/ci.yml + +name: CI +on: +push: +branches: [main] +pull_request: +jobs: +node: +runs-on: ubuntu-latest +steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 +with: +node-version: 20 +cache: npm - run: npm ci - run: npm ci +working-directory: next - run: npm run type-check +working-directory: next - run: npm run lint +working-directory: next - run: npm run format:check +working-directory: next - run: npm run test:ci +working-directory: next + +⸻ + +トラブルシューティング + +フックの確認 + +git config core.hooksPath + +Husky の再初期化 + +rm -rf .husky +npm run prepare +npx husky add .husky/pre-commit "npx lint-staged" +npx husky add .husky/commit-msg "npx commitlint --edit \$1" +npx husky add .husky/pre-push "npm --prefix next run type-check && npm --prefix next run test:ci" + +一時的にフックをスキップ + +git commit --no-verify -m "urgent: emergency fix" diff --git a/README.md b/README.md index d1a5a2ba..4d99b4e7 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ It includes settings for various tools, such as the shell (Zsh), Git, npm, and V - **13 specialized AI agents**: Architecture validation (DDD, Clean Architecture), accessibility & design validation, concurrency safety analysis, documentation consistency checking, dependency auditing, performance analysis, testability & coverage analysis, and issue resolution workflows - **14 automated commands**: Code coverage checking, CI/CD troubleshooting, project initialization, pull request creation, quality checks, security reviews, test execution, dependency updates, and n8n MCP integration setup - **Development quality standards**: Japanese-language guidelines for TDD methodology, static quality gates, Git workflow conventions, and AI-assisted development practices +- `.codex/`: Codex CLI mirror of the Claude configuration with migrated prompts in `prompts/` and `config.toml` defining matching MCP servers plus desktop notifications - `.devcontainer/`: Development container configuration providing containerized development environment with consistent tooling across different machines. - `brew/`: Contains Brewfiles for different operating systems (Linux, macOS) and dependency configurations, including lock files for reproducible package installations. Supports categorized package management and dependency analysis. - `credentials/`: Contains templates and scripts for secure credential management using 1Password CLI integration.