Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
38 changes: 32 additions & 6 deletions .claude/hooks/stop_test_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@
from pathlib import Path
from common import get_git_root, detect_package_manager, build_run_command


# Test-irrelevant path definitions (skip tests when only these files changed)
IRRELEVANT_SUFFIXES = ('.md', '.txt')
IRRELEVANT_PREFIXES = (
'docs/',
'.context/',
'.gemini/',
'.cursor/',
'.vscode/',
'.idea/',
)


def affects_tests(files):
"""Return True if any changed file could affect tests."""
for f in files:
if not (
f.endswith(IRRELEVANT_SUFFIXES)
or any(f.startswith(p) for p in IRRELEVANT_PREFIXES)
):
return True
return False


# 無限ループ防止
if os.environ.get("STOP_HOOK_ACTIVE") == "1":
sys.exit(0)
Expand All @@ -39,12 +63,14 @@
["git", "ls-files", "--others", "--exclude-standard"],
capture_output=True, text=True, timeout=10, cwd=repo_root
)
has_changes = bool(
(diff_result.stdout or "").strip()
or (staged_result.stdout or "").strip()
or (untracked_result.stdout or "").strip()
)
if not has_changes:
changed_files = list(filter(None,
(diff_result.stdout or "").strip().splitlines()
+ (staged_result.stdout or "").strip().splitlines()
+ (untracked_result.stdout or "").strip().splitlines()
))
if not changed_files:
sys.exit(0)
if not affects_tests(changed_files):
sys.exit(0)
except (subprocess.TimeoutExpired, FileNotFoundError):
sys.exit(0)
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,6 @@ RUN echo "${IMAGE_VERSION}" > /etc/config-base-version \

COPY package.json package-lock.json /tmp/
COPY .husky /tmp/.husky/
COPY git/commitlint.config.js /tmp/commitlint.config.js
COPY commitlint.config.js /tmp/commitlint.config.js
# package.json の overrides により handlebars >= 4.7.9 (CVE-2026-33937対応) が強制インストールされる
RUN cd /tmp && npm ci && npm run prepare || true
18 changes: 18 additions & 0 deletions .devcontainer/claude-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,24 @@
"command": "python3 /home/vscode/.claude/hooks/post_pr_ai_review.py"
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "python3 /home/vscode/.claude/hooks/post_pr_ci_watch.py"
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "bash -c 'cd \"$(git rev-parse --show-toplevel 2>/dev/null || echo .)\" && python3 /home/vscode/.claude/hooks/post_commit_adr_reminder.py'"
}
]
}
],
"Stop": [
Expand Down
14 changes: 14 additions & 0 deletions .filelengthignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# .filelengthignore - 行数チェック (check-file-length.sh) の除外パターン
#
# .gitignore と同じ記法でパターンを指定できます。
# - 空行とコメント行 (#) は無視されます
# - glob パターンが使えます(*, **, ? など)
# - パスはリポジトリルートからの相対パスで評価されます

# 自動生成パターン
**/*.generated.*
**/*.gen.*
**/database.types.ts

# テンプレートサンプルファイル(網羅的な参照実装のため分割不可)
templates/testing/**
61 changes: 61 additions & 0 deletions .github/sync-downstream.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"groups": {
"claude-config": [
{ "source": ".claude/hooks/", "target": ".claude/hooks/" },
{ "source": ".claude/rules/", "target": ".claude/rules/" },
{ "source": ".claude/settings.json", "target": ".claude/settings.json" }
],
"workflow-claude": [
{
"source": "templates/workflows/claude.yml",
"target": ".github/workflows/claude.yml"
}
],
"workflow-quality-gate-fallback": [
{
"source": "templates/workflows/quality-gate-fallback.yml",
"target": ".github/workflows/quality-gate-fallback.yml"
}
],
"workflow-dependabot-auto-merge": [
{
"source": "templates/workflows/dependabot-auto-merge.yml",
"target": ".github/workflows/dependabot-auto-merge.yml"
}
],
"workflow-label-sync": [
{
"source": "templates/workflows/label-sync.yml",
"target": ".github/workflows/label-sync.yml"
}
]
},
"repos": [
{
"name": "keito4/calendar_alerm",
"groups": ["claude-config", "workflow-claude", "workflow-quality-gate-fallback", "workflow-dependabot-auto-merge"]
},
{
"name": "keito4/effectuation",
"groups": ["claude-config", "workflow-claude", "workflow-quality-gate-fallback"]
},
{
"name": "keito4/intent-gate-android",
"groups": [
"claude-config",
"workflow-claude",
"workflow-quality-gate-fallback",
"workflow-dependabot-auto-merge",
"workflow-label-sync"
]
},
{
"name": "keito4/ohana",
"groups": ["claude-config", "workflow-claude", "workflow-quality-gate-fallback", "workflow-dependabot-auto-merge"]
},
{
"name": "keito4/raycast-extensions",
"groups": ["claude-config"]
}
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ supabase/.temp/
credentials/*.env
!credentials/*.env.template
credentials/secrets/
.env
.env.secret
.env*.local
.devcontainer.env
Expand Down
19 changes: 14 additions & 5 deletions docs/adr/0016-use-kanary-for-keyboard-remapping.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ADR 0016: Use Kanary for Keyboard Remapping
# ADR 0016: Use Kanary and skhd for Keyboard Remapping

## Status

Expand All @@ -15,7 +15,10 @@ Karabiner Elements has been used for local macOS keyboard behavior:
Kanary provides a macOS 14+ Apple Silicon menu bar app for keyboard-focused
workflows, including modifier-key taps, app hotkeys, window movement, input
switching, per-app input defaults, and a built-in Caps Lock to Control remap for
JIS users.
JIS users. cmux uses Ghostty for terminal behavior, but neither cmux nor Ghostty
provides a stable built-in shortcut action for running arbitrary shell commands
from terminal keybindings. tmux `user-keys` only help when the focused terminal
is actually running tmux.

Kanary is distributed from `https://kanary.download/download`, which currently
redirects to a versioned ZIP file such as `Kanary-2.3.8.zip`. It is not available
Expand All @@ -38,6 +41,10 @@ Stop using Karabiner Elements for local keyboard remapping.
- Left Command tap to alphanumeric input.
- Right Command tap to kana input.
- Per-app default input modes where useful.
- Use nix-darwin's `services.skhd` for terminal-friendly IME shortcuts without
Karabiner:
- `Ctrl+Shift+J` selects Google Japanese Input hiragana.
- `Ctrl+Shift+;` selects Google Japanese Input alphanumeric.

## Consequences

Expand All @@ -51,6 +58,8 @@ Kanary installation and app-level settings are manual for now. The repository
avoids adding a bespoke ZIP download, checksum, and install flow while Kanary is
not available through the normal package sources used by this configuration.

The previous cmux-specific `Ctrl+Shift+J`, `Ctrl+Shift+;`, and `Ctrl+Shift+'`
IME mappings are no longer generated by this repository. Use Kanary's modifier
tap input switching and per-app input defaults instead.
The `Ctrl+Shift+J` and `Ctrl+Shift+;` IME mappings are handled by skhd as a
user-level hotkey daemon, so they work in cmux terminals even when the foreground
process is Claude Code, Codex, zsh, or another TUI instead of tmux. This still
avoids Karabiner and its DriverKit extension, but skhd must be allowed in macOS
Accessibility settings before it can observe keyboard events.
64 changes: 64 additions & 0 deletions docs/adr/0017-downstream-template-auto-sync.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# ADR 0017: Downstream Template Auto-Sync

## Status

Accepted (amends ADR 0009)

## Context

ADR 0009 established `templates/` as the single template root and added a CI
check that detects drift between templates and this repository's own runnable
workflows. It did not address propagation: the five downstream repositories
(calendar_alerm, effectuation, intent-gate-android, ohana, raycast-extensions)
receive templates and `.claude/` assets (hooks, rules, settings) only when
`setup-new-repo.sh` runs or when someone manually runs `/repo-maintenance` in
the downstream repository. `check_downstream_sync()` in
`script/repo-maintenance.sh` merely prints a warning. In practice downstream
copies go stale as soon as config changes.

## Decision

Add an automated downstream sync pipeline:

- **Manifest** `.github/sync-downstream.json` declares sync groups (named sets
of source→target file or directory mappings) and per-repository group
opt-ins with an optional `exclude` path list. The manifest lives outside
`templates/` because it is config-side metadata, not distributed content.
- **Sync engine** `script/sync-downstream.js` performs pure file copies from
this repository into a downstream checkout. It never invokes git or gh, so
its behavior is fully covered by Jest (`test/sync-downstream.test.js`).
Python bytecode artifacts (`__pycache__/`, `*.pyc`) are always ignored.
- **Delivery** (follow-up change): a GitHub Actions workflow triggered by
pushes to `main` that touch synced paths fans out over the manifest matrix,
runs the sync engine against each downstream checkout, and opens an
idempotent PR on the fixed branch `chore/config-template-sync` using
`CLAUDE_PAT`.

Local downstream modifications are never overwritten directly: the sync only
proposes a PR, and permanent divergence is expressed as a one-line manifest
`exclude` entry instead of downstream-side marker files.

Role separation: initial placement stays with `setup-new-repo.sh`, container
builds keep baking hooks into the config-base image, and ongoing convergence
is owned by this sync pipeline.

## Consequences

### Positive

- Downstream repositories track config changes without manual
`/repo-maintenance` runs; review happens per-repository via the sync PR.
- The manifest gives one auditable place that answers "what is managed where".
- The sync engine is testable in isolation; workflow YAML stays thin.

### Negative

- The manifest is maintained by hand; adding a repository or template requires
a manifest edit.
- Downstream repositories with intentional local changes will keep receiving
sync PRs until the path is excluded in the manifest.

### Mitigation

- Manifest schema violations fail fast in CI through the Jest suite, which
validates the checked-in manifest against the real file tree.
3 changes: 2 additions & 1 deletion docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
| [0012](0012-environment-source-of-truth.md) | Environment Source of Truth | Accepted |
| [0014](0014-manage-cmux-karabiner-with-home-manager.md) | Manage cmux and Karabiner Configuration with Home Manager | Superseded by 0016 |
| [0015](0015-manage-portable-user-dotfiles-with-home-manager.md) | Manage Portable User Dotfiles with Home Manager | Accepted |
| [0016](0016-use-kanary-for-keyboard-remapping.md) | Use Kanary for Keyboard Remapping | Accepted |
| [0016](0016-use-kanary-for-keyboard-remapping.md) | Use Kanary and skhd for Keyboard Remapping | Accepted |
| [0017](0017-downstream-template-auto-sync.md) | Downstream Template Auto-Sync | Accepted |

## ADR テンプレート

Expand Down
24 changes: 16 additions & 8 deletions docs/mcp-servers-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ MCPサーバーは `.mcp.json` ファイルで設定します。このファイ
"playwright": {
"type": "stdio",
"command": "npx",
"args": ["@playwright/mcp@latest"],
"args": ["--yes", "@playwright/mcp@latest"],
"env": {}
}
}
Expand All @@ -56,8 +56,12 @@ GitHub操作の統合。
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/"
"type": "stdio",
"command": "bash",
"args": [
"-c",
"TOKEN=\"${GITHUB_PERSONAL_ACCESS_TOKEN:-${GITHUB_TOKEN:-$(gh auth token 2>/dev/null)}}\"; [ -n \"$TOKEN\" ] || { echo 'GitHub MCP: missing token (run gh auth login or set GITHUB_PERSONAL_ACCESS_TOKEN/GITHUB_TOKEN)' >&2; exit 1; }; export GITHUB_PERSONAL_ACCESS_TOKEN=\"$TOKEN\"; exec npx --yes @modelcontextprotocol/server-github"
]
}
}
}
Expand All @@ -67,9 +71,9 @@ GitHub操作の統合。

- リポジトリの操作
- Issue/PRの管理
- GitHub Copilot連携
- コード検索

**注意:** Claude Codeには GitHub MCP が組み込まれているため、`gh` CLI認証があれば追加設定不要です。
**注意:** `gh auth login` 済みの場合、`GITHUB_PERSONAL_ACCESS_TOKEN` や `GITHUB_TOKEN` の設定は不要です。`gh auth token` で自動取得されます。

### Figma

Expand Down Expand Up @@ -130,12 +134,16 @@ Supabaseデータベースとの統合。
"playwright": {
"type": "stdio",
"command": "npx",
"args": ["@playwright/mcp@latest"],
"args": ["--yes", "@playwright/mcp@latest"],
"env": {}
},
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/"
"type": "stdio",
"command": "bash",
"args": [
"-c",
"TOKEN=\"${GITHUB_PERSONAL_ACCESS_TOKEN:-${GITHUB_TOKEN:-$(gh auth token 2>/dev/null)}}\"; [ -n \"$TOKEN\" ] || { echo 'GitHub MCP: missing token' >&2; exit 1; }; export GITHUB_PERSONAL_ACCESS_TOKEN=\"$TOKEN\"; exec npx --yes @modelcontextprotocol/server-github"
]
},
"figma": {
"type": "http",
Expand Down
6 changes: 3 additions & 3 deletions docs/tool-catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Layer 1: ベースイメージ (ghcr.io/keito4/config-base)

| ツール | バージョン | 用途 |
| -------- | --------------- | -------------------------- |
| Node.js | 24.17.0 | JavaScript/TypeScript 実行 |
| Node.js | 24.18.0 | JavaScript/TypeScript 実行 |
| Python 3 | apt 管理 | スクリプト、AI ツール |
| pnpm | 11.8.0 | パッケージマネージャ |
| pnpm | 11.9.0 | パッケージマネージャ |
| npm | see global.json | パッケージマネージャ |
| corepack | see global.json | パッケージマネージャ切替 |

Expand All @@ -44,7 +44,7 @@ Layer 1: ベースイメージ (ghcr.io/keito4/config-base)

| ツール | バージョン管理 | 用途 |
| --------------------------------- | -------------------------- | ------------------- |
| Claude Code | native installer (2.1.185) | AI コーディング支援 |
| Claude Code | native installer (2.1.195) | AI コーディング支援 |
| Codex (`@openai/codex`) | see global.json | OpenAI Codex CLI |
| Gemini CLI (`@google/gemini-cli`) | see global.json | Google Gemini CLI |
| Happy Coder | see global.json | AI コーディング |
Expand Down
1 change: 1 addition & 0 deletions nix/home/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
./zsh.nix
./dotfiles.nix
./agent-commands.nix
./input-source.nix
./cmux.nix
];

Expand Down
20 changes: 20 additions & 0 deletions nix/home/input-source.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{ configRoot, ... }:

{
home.file.".local/share/input-source/select-input-source.swift" = {
source = configRoot + /script/macos/select-input-source.swift;
force = true;
};

home.file.".local/bin/select-input-source" = {
source = configRoot + /script/macos/agent-select-input-source.sh;
executable = true;
force = true;
};

home.file.".local/bin/agent-select-input-source" = {
source = configRoot + /script/macos/agent-select-input-source.sh;
executable = true;
force = true;
};
}
Loading