Re: ワークフロー簡略化の実装プラン策定(再依頼)
Goal
owner指示メモ 19c747414d3 に基づき、ワークフローを大幅に簡略化する。具体的には: (1) ロールベースメモ管理を agent/owner の2 inbox に統合、(2) 5ロール廃止と専門sub-agent群への移行、(3) docs/ の情報を .claude/skills/ と .claude/rules/ に移動、(4) CLAUDE.md を60行以内に簡素化、(5) Hooks による制約の確定的強制、(6) サイクル管理のテンプレート化。
実装プラン
フェーズ1: メモシステムの再構築(最優先、他フェーズの前提)
Step 1.1: memo/ディレクトリ構造の変更
変更内容: 7つのロール別ディレクトリを agent と owner の2つに統合する。
新しいディレクトリ構造:
memo/
├── agent/
│ ├── inbox/
│ ├── active/
│ └── archive/
├── owner/ (既存のまま)
│ ├── inbox/
│ ├── active/
│ └── archive/
├── builder/ (既存データ保持、読み取り専用アーカイブ)
├── planner/ (既存データ保持、読み取り専用アーカイブ)
├── project-manager/(既存データ保持、読み取り専用アーカイブ)
├── researcher/ (既存データ保持、読み取り専用アーカイブ)
├── reviewer/ (既存データ保持、読み取り専用アーカイブ)
└── process-engineer/(既存データ保持、読み取り専用アーカイブ)
作業手順:
memo/agent/inbox/,memo/agent/active/,memo/agent/archive/ディレクトリを作成- 旧ロールディレクトリの既存メモは移動しない(履歴保持のため)
- 新規メモはすべて
agentまたはowner宛てに作成
受入基準:
-
memo/agent/{inbox,active,archive}/ディレクトリが存在する - 旧ロールディレクトリの既存メモファイルがすべて残っている
- 新しいメモが
memo/agent/inbox/またはmemo/owner/inbox/に作成される
Step 1.2: scripts/memo/types.ts の更新
変更内容: VALID_ROLES と ROLE_SLUG_MAP を更新する。
ファイル: /home/ena/yolo-web/scripts/memo/types.ts
変更後の内容:
export interface MemoFrontmatter {
id: string;
subject: string;
from: string;
to: string;
created_at: string;
tags: string[];
reply_to: string | null;
}
export interface Memo {
frontmatter: MemoFrontmatter;
body: string;
filePath: string;
}
export const VALID_ROLES = [
"owner",
"agent",
// Legacy roles (read-only, for historical memo access)
"project-manager",
"researcher",
"planner",
"builder",
"reviewer",
"process-engineer",
] as const;
export type RoleSlug = (typeof VALID_ROLES)[number];
/** Map display names to directory slugs */
export const ROLE_SLUG_MAP: Record<string, RoleSlug> = {
owner: "owner",
agent: "agent",
// Legacy mappings (for reading historical memos)
"project manager": "project-manager",
"project-manager": "project-manager",
researcher: "researcher",
planner: "planner",
builder: "builder",
reviewer: "reviewer",
"process engineer": "process-engineer",
"process-engineer": "process-engineer",
};
受入基準:
-
agentが VALID_ROLES に含まれている -
npm run memo -- create agent agent "test" --body "test"が成功する - 既存テストがすべてパスする
Step 1.3: scripts/memo/commands/mark.ts の owner保護強制
変更内容: 環境変数 YOLO_AGENT が設定されている場合(Claude Code内から呼び出し時)、owner宛てメモのmark操作を拒否する。
ファイル: /home/ena/yolo-web/scripts/memo/commands/mark.ts
変更箇所: markMemo関数内、既存の YOLO_AGENT チェックの直後に以下を追加:
// Agents cannot mark owner memos
const yoloAgent = process.env.YOLO_AGENT;
if (yoloAgent) {
// Determine the role directory from the memo file path
const roleDir = path.basename(path.dirname(path.dirname(memo.filePath)));
if (roleDir === "owner") {
throw new Error(
"Permission denied: agents cannot change state of owner memos"
);
}
}
さらに、既存の YOLO_AGENT チェック(from/to ベースのチェック)を更新: 現在の memo.frontmatter.to !== yoloAgent のチェックを削除し、上記のowner保護のみにする。理由: 新しいシステムでは全agentが agent inbox を共有するため、from/to による制限は不要になり、ownerメモの保護のみが必要。
受入基準:
-
YOLO_AGENT=agent npm run memo -- mark <owner-memo-id> archiveがエラーになる -
YOLO_AGENT=agent npm run memo -- mark <agent-memo-id> archiveが成功する - 環境変数未設定時は従来通り制限なし
Step 1.4: scripts/memo/commands/create.ts の owner保護強制
変更内容: 環境変数 YOLO_AGENT が設定されている場合、owner宛ての create のみ許可し、owner「から」の create を拒否する(なりすまし防止)。
ファイル: /home/ena/yolo-web/scripts/memo/commands/create.ts
追加箇所: createMemo関数内、resolveRoleSlug の直後:
const yoloAgent = process.env.YOLO_AGENT;
if (yoloAgent && fromSlug === "owner") {
throw new Error(
"Permission denied: agents cannot create memos as owner"
);
}
受入基準:
-
YOLO_AGENT=agent npm run memo -- create owner agent "test" --body "test"がエラー -
YOLO_AGENT=agent npm run memo -- create agent owner "test" --body "test"が成功 - 環境変数未設定時は制限なし
Step 1.5: メモシステムのテスト更新
変更内容: 既存テスト12ファイルのうち、VALID_ROLES や ROLE_SLUG_MAP に依存するテストを更新。agent ロールのテストケースを追加。owner保護のテストを追加。
受入基準:
-
npm testが全テストパス - agent ロールの create/mark/list テストが存在する
- owner保護のテストが存在する
フェーズ2: CLAUDE.md の簡素化と .claude/rules/ への分離
Step 2.1: .claude/rules/ ディレクトリの作成と内容
新規作成ファイル一覧:
ファイル 2.1a: /home/ena/yolo-web/.claude/rules/memo-system.md
# Memo System
All work decisions and progress are recorded as memos.
## Directory Structure
- \`memo/agent/\` -- shared inbox for all agent work
- \`memo/owner/\` -- owner communications (read-only for agents)
## Memo CLI
All memo operations use \`npm run memo\`:
- \`npm run memo -- list [--state inbox|active|archive|all] [--to agent|owner] [--from <role>]\`
- \`npm run memo -- read <id>\`
- \`npm run memo -- create <from> <to> <subject> --body "<body>" [--reply-to <id>] [--tags <tags>]\`
- \`npm run memo -- mark <id> <state>\`
Direct manipulation of \`memo/\` directory files is prohibited. Use the CLI only.
## Memo Lifecycle
1. Check agent inbox and active at work start
2. Read each memo, triage: archive (done/informational) or activate (ongoing)
3. Respond by creating a reply memo with \`--reply-to\`
4. Triage all inbox memos before concluding work
## Routing
- Agent-to-agent communication: from=agent, to=agent
- Reports to owner: from=agent, to=owner
- Owner instructions: from=owner, to=agent
## Historical Memos
Legacy role-based memos (builder/, planner/, etc.) remain in the repository as read-only archives. Use \`npm run memo -- list --to <legacy-role>\` to query them.
ファイル 2.1b: /home/ena/yolo-web/.claude/rules/coding-standards.md
---
paths:
- "src/**/*.{ts,tsx}"
- "scripts/**/*.ts"
---
# Coding Standards
## TypeScript
- Strict mode enabled. Prefer type aliases over interfaces.
- Explicit return types for public APIs. Avoid \`any\`.
## Style
- Prettier: double quotes, semicolons, 2-space indent, trailing commas, 80 char width.
- ESLint: next/core-web-vitals + typescript + prettier config.
## Quality Checks
Before committing, all checks must pass:
\`\`\`bash
npm run typecheck && npm run lint && npm run format:check && npm test && npm run build
\`\`\`
## Architecture
- Static-first: prefer static content and build-time generation. No databases.
- No user accounts or authentication.
- Small, composable modules. Narrow components, independently testable.
- All site content is AI-owned. AI experiment disclosure is mandatory (Constitution Rule 3).
## Testing
- Vitest + jsdom + @testing-library/react
- Test files: \`__tests__/<filename>.test.ts(x)\` alongside source
- Test: utilities, component rendering, data transforms, edge cases
ファイル 2.1c: /home/ena/yolo-web/.claude/rules/cycle-management.md
# Cycle Management
Each cycle represents a unit of work (feature, content addition, redesign).
## Cycle Document
Every cycle creates a tracking document at \`docs/cycles/<cycle-number>.md\` using the template at \`.claude/skills/cycle-template/SKILL.md\`.
## Lifecycle
1. **Kickoff**: Select work from backlog, create cycle document, report to owner
2. **Research**: Delegate investigation to research-focused sub-agents
3. **Plan**: Delegate planning to planning-focused sub-agents
4. **Build**: Delegate implementation to builder sub-agents (parallelize when areas do not overlap)
5. **Review**: Every build output must pass review before shipping
6. **Ship**: Commit, push to main (auto-deploys via Vercel), report to owner
## Blog Articles
Create a blog article when any cycle includes: new service type, bulk content addition, major site change, or significant learnings.
## Backlog
Maintained at \`docs/backlog.md\`. Updated at cycle start and completion.
ファイル 2.1d: /home/ena/yolo-web/.claude/rules/git-conventions.md
# Git Conventions
## Commit Author
Set \`--author "Claude <noreply@anthropic.com>"\` or \`--author "Codex <codex@localhost>"\` on all commits.
## Commit Freely
Commits do not require owner approval. Commit frequently to create rollback checkpoints.
## Deploy
Push to \`main\` triggers Vercel auto-deploy. Rollback via \`git revert <commit>\`.
受入基準:
- 4つの .claude/rules/*.md ファイルが存在する
- coding-standards.md に paths フロントマターがある
- 各ファイルの内容が上記の通りである
Step 2.2: CLAUDE.md の書き換え(60行以内)
ファイル: /home/ena/yolo-web/CLAUDE.md
変更後の全内容 (目標: 55行以内):
# yolos.net
AI-operated experimental website aiming to increase page views.
## Constitution
\`docs/constitution.md\` is immutable. Every action and content must comply with it. Read it first.
## Core Workflow
1. Record all decisions and work as memos (\`npm run memo\`). See \`.claude/rules/memo-system.md\`.
2. Use specialized sub-agents (\`.claude/agents/\`) and skills (\`.claude/skills/\`) for all work.
3. Reports to owner go to \`memo/owner/inbox/\`. Agent coordination uses \`memo/agent/inbox/\`.
4. Every build output passes review before shipping.
5. Parallelize independent tasks. Commit frequently for rollback safety.
## Sub-Agent Dispatch
Assign specific memo IDs when launching sub-agents. Each sub-agent works only on its assigned memo(s).
## Toolchain
Next.js / TypeScript / ESLint / Prettier / Vitest + jsdom
## Key References
- \`.claude/rules/\` -- Detailed rules (memo system, coding standards, cycles, git)
- \`.claude/skills/\` -- Reusable task procedures (blog writing, cycle management, etc.)
- \`.claude/agents/\` -- Specialized sub-agent definitions
- \`docs/constitution.md\` -- Immutable project rules
- \`docs/backlog.md\` -- Product backlog (main agent may edit directly)
受入基準:
- CLAUDE.md が60行以内である
- 否定形の指示が含まれていない(肯定形のみ)
- constitution.md への参照がある
- メモシステム、sub-agent、skills への参照がある
フェーズ3: Sub-Agent定義の再構築
Step 3.1: 既存の4つのロールベースagent定義を削除
削除するファイル:
/home/ena/yolo-web/.claude/agents/researcher.md/home/ena/yolo-web/.claude/agents/planner.md/home/ena/yolo-web/.claude/agents/builder.md/home/ena/yolo-web/.claude/agents/reviewer.md
Step 3.2: 新しい専門sub-agent定義の作成
以下のsub-agentを作成する。各ファイルの完全な内容を示す。
ファイル 3.2a: /home/ena/yolo-web/.claude/agents/researcher.md
---
name: researcher
description: "Investigates the codebase and internet for accurate, relevant information. Use for any research or information gathering task."
tools: Read, Glob, Grep, Bash, WebFetch, WebSearch
disallowedTools: Edit, Write, MultiEdit
model: inherit
permissionMode: bypassPermissions
memory: project
---
# Researcher
You investigate and provide accurate information.
## Instructions
1. Read \`docs/constitution.md\` (immutable rules) and \`.claude/rules/memo-system.md\`.
2. Check assigned memo(s) with \`npm run memo -- read <id>\`.
3. Investigate the repository and/or internet as needed.
4. Report findings as a reply memo: \`npm run memo -- create agent agent "Re: <subject>" --reply-to <id> --body "<findings>"\`
5. Include: questions answered, sources inspected, confidence level, unknowns.
6. For owner-relevant findings, also send a summary to owner: \`npm run memo -- create agent owner "<subject>" --body "<summary>"\`
## Constraints
- Read-only: gather and report information only. Implementation and planning belong to other agents.
- Set \`YOLO_AGENT=agent\` when using memo CLI.
ファイル 3.2b: /home/ena/yolo-web/.claude/agents/planner.md
---
name: planner
description: "Creates detailed implementation plans with exact specifications. Use for planning features, architecture decisions, and task breakdowns."
tools: Read, Glob, Grep, Bash, WebFetch, WebSearch
disallowedTools: Edit, Write, MultiEdit
model: inherit
permissionMode: bypassPermissions
memory: project
---
# Planner
You create reliable, detailed implementation plans.
## Instructions
1. Read \`docs/constitution.md\` (immutable rules) and \`.claude/rules/memo-system.md\`.
2. Check assigned memo(s) with \`npm run memo -- read <id>\`.
3. Create a step-by-step plan with acceptance criteria for each step.
4. Plans must be specific enough for a builder agent to implement without ambiguity.
5. Send the plan as a reply memo: \`npm run memo -- create agent agent "Re: <subject>" --reply-to <id> --body "<plan>"\`
6. After planning, request review by creating a review-request memo.
## Plan Format
Include: Goal, Step-by-step plan, Acceptance criteria per step, Required artifacts, Rollback approach.
## Constraints
- Read-only: create plans only. Implementation belongs to builder agents.
- Set \`YOLO_AGENT=agent\` when using memo CLI.
ファイル 3.2c: /home/ena/yolo-web/.claude/agents/builder.md
---
name: builder
description: "Implements plans and tasks exactly as instructed. Use for code changes, file creation, dependency installation, and build tasks."
tools: Read, Edit, Write, MultiEdit, Bash, Glob, Grep
model: inherit
permissionMode: bypassPermissions
memory: project
skills:
- blog-article-writing
---
# Builder
You implement reliably, exactly as instructed.
## Instructions
1. Read \`docs/constitution.md\` (immutable rules) and \`.claude/rules/memo-system.md\`.
2. Check assigned memo(s) with \`npm run memo -- read <id>\`.
3. Implement the plan/task within the memo's acceptance criteria scope.
4. Run all quality checks before reporting completion:
\`\`\`bash
npm run typecheck && npm run lint && npm run format:check && npm test && npm run build
\`\`\`
5. Send completion report: \`npm run memo -- create agent agent "Re: <subject>" --reply-to <id> --body "<report>"\`
6. Request review by creating a review-request memo for the reviewer agent.
## Completion Report Format
Include: what was implemented, changed files list, quality check results, how to validate.
## Constraints
- Keep changes scoped to the memo's acceptance criteria. No unrequested changes.
- Set \`YOLO_AGENT=agent\` when using memo CLI.
- Commit with \`--author "Claude <noreply@anthropic.com>"\`.
ファイル 3.2d: /home/ena/yolo-web/.claude/agents/reviewer.md
---
name: reviewer
description: "Reviews code, plans, and documents for correctness, quality, and constitution compliance. Use for all review tasks."
tools: Read, Glob, Grep, Bash
disallowedTools: Edit, Write, MultiEdit
model: inherit
permissionMode: bypassPermissions
memory: project
---
# Reviewer
You find all problems.
## Instructions
1. Read \`docs/constitution.md\` (immutable rules).
2. Check assigned memo(s) with \`npm run memo -- read <id>\`.
3. Review for: correctness, clarity, maintainability, constitution compliance.
4. Reply with verdict: \`npm run memo -- create agent agent "Re: <subject>" --reply-to <id> --body "<review>"\`
## Review Format
Include: verdict (approved/changes-requested/rejected), specific issues (file paths, line numbers), constitution compliance check, actionable feedback.
## Constraints
- Read-only: review and report only. Do not fix issues directly.
- Set \`YOLO_AGENT=agent\` when using memo CLI.
ファイル 3.2e: /home/ena/yolo-web/.claude/agents/content-ideator.md(新規)
---
name: content-ideator
description: "Generates ideas for new website content, tools, games, and features based on SEO potential and user value. Use when brainstorming what to build next."
tools: Read, Glob, Grep, Bash, WebFetch, WebSearch
disallowedTools: Edit, Write, MultiEdit
model: inherit
permissionMode: bypassPermissions
---
# Content Ideator
You generate creative, actionable content ideas that drive page views.
## Instructions
1. Read \`docs/constitution.md\` (immutable rules).
2. Check assigned memo(s) with \`npm run memo -- read <id>\`.
3. Analyze the current site content (\`src/content/\`, \`src/app/\`) to understand existing offerings.
4. Research SEO opportunities, trending topics, and competitor sites.
5. Propose ideas with: title, description, target audience, estimated SEO impact, implementation complexity.
6. Reply with ideas: \`npm run memo -- create agent agent "Re: <subject>" --reply-to <id> --body "<ideas>"\`
## Constraints
- Read-only: propose ideas only.
- Set \`YOLO_AGENT=agent\` when using memo CLI.
ファイル 3.2f: /home/ena/yolo-web/.claude/agents/blog-writer.md(新規)
---
name: blog-writer
description: "Writes blog articles about site changes, decisions, and learnings. Use when a cycle requires a blog post."
tools: Read, Edit, Write, Bash, Glob, Grep
model: inherit
permissionMode: bypassPermissions
skills:
- blog-article-writing
---
# Blog Writer
You write engaging, informative blog articles for yolos.net.
## Instructions
1. Read \`docs/constitution.md\` (immutable rules).
2. Check assigned memo(s) with \`npm run memo -- read <id>\`.
3. Follow the blog-article-writing skill for format and requirements.
4. Include AI experiment disclosure (Constitution Rule 3).
5. Send completion report: \`npm run memo -- create agent agent "Re: <subject>" --reply-to <id> --body "<report>"\`
## Constraints
- Scope changes to blog content files only (\`src/content/blog/\`).
- Set \`YOLO_AGENT=agent\` when using memo CLI.
- Commit with \`--author "Claude <noreply@anthropic.com>"\`.
受入基準:
- 6つのagent定義ファイルが .claude/agents/ に存在する
- researcher, planner, reviewer に disallowedTools: Edit, Write, MultiEdit が設定されている
- builder, blog-writer に skills フィールドがある
- 全agentに memory: project が設定されている(content-ideator以外)
- 全agentのmemo操作で from=agent, to=agent (または to=owner) を使用する指示がある
フェーズ4: Skills の拡充とドキュメント移行
Step 4.1: サイクルテンプレートSkillの作成(新規)
ファイル: /home/ena/yolo-web/.claude/skills/cycle-template/SKILL.md
---
name: cycle-template
description: "サイクルドキュメントのテンプレート。新サイクル開始時にこのテンプレートをコピーして docs/cycles/<number>.md を作成する。"
disable-model-invocation: true
---
# Cycle Document Template
Copy this template to \`docs/cycles/<cycle-number>.md\` and fill in the details.
## Template
\`\`\`markdown
# Cycle <NUMBER>: <TITLE>
## Status: <in-progress|completed|cancelled>
## Goal
<What this cycle aims to achieve>
## Pre-flight Checklist
- [ ] Previous cycle completed or carry-over items logged in backlog
- [ ] Agent inbox triaged
- [ ] CodeQL alerts checked: \\\`gh api --method GET '/repos/macrat/yolo-web/code-scanning/alerts?state=open'\\\`
- [ ] Dependabot PRs checked: \\\`gh pr list --author 'app/dependabot'\\\`
- [ ] Backlog reviewed and cycle items marked as in-progress
- [ ] Owner notified of cycle start
## Research
| Topic | Memo ID | Status |
|-------|---------|--------|
| | | |
## Plan
| Item | Plan Memo ID | Review Status |
|------|-------------|---------------|
| | | |
## Build
| Item | Builder Memo ID | Review Status | Commit |
|------|----------------|---------------|--------|
| | | | |
## Completion Checklist
- [ ] All quality checks pass (typecheck, lint, format, test, build)
- [ ] All reviews approved
- [ ] Blog article created (if applicable)
- [ ] Backlog updated
- [ ] Changes pushed to main
- [ ] Owner notified of cycle completion
\`\`\`
受入基準:
- cycle-template/SKILL.md が存在する
- disable-model-invocation: true が設定されている
- テンプレートにpre-flightチェックリストと完了チェックリストが含まれる
Step 4.2: cycle-kickoff Skill の更新
ファイル: /home/ena/yolo-web/.claude/skills/cycle-kickoff/SKILL.md
変更内容: 新しいメモシステム(agent/owner)に合わせて更新。サイクルドキュメント作成の手順を追加。PM固有の言及を main agent に変更。
主な変更点:
- メモコマンド例の
--to project-managerを--to agentに変更 - サイクルドキュメントの作成手順(cycle-template の参照)を追加
- ownerへの報告を
npm run memo -- create agent ownerに変更 - PM固有の制約記述を削除し、main agent向けの一般的な記述に変更
受入基準:
- agent/owner のメモルーティングを使用している
- cycle-template への参照がある
- docs/cycles/ ディレクトリへのドキュメント作成手順がある
Step 4.3: cycle-completion Skill の更新
ファイル: /home/ena/yolo-web/.claude/skills/cycle-completion/SKILL.md
変更内容: 新しいメモシステムに合わせて更新。
主な変更点:
- メモコマンド例を agent/owner ルーティングに変更
- reviewer の確認を
npm run memo -- list --to agent --tag review等に変更 - builder の完了報告確認を agent inbox から検索する形に変更
受入基準:
- agent/owner のメモルーティングを使用している
- サイクルドキュメントの完了チェックリスト更新手順がある
Step 4.4: docs/ の整理
削除するファイル(内容が .claude/rules/ や .claude/skills/ に移行済み):
/home/ena/yolo-web/docs/workflow.md-- 内容は .claude/rules/memo-system.md, .claude/rules/cycle-management.md, 各agent定義に分散/home/ena/yolo-web/docs/memo-spec.md-- 内容は .claude/rules/memo-system.md に統合/home/ena/yolo-web/docs/style.md-- 内容は .claude/rules/coding-standards.md に統合/home/ena/yolo-web/docs/testing.md-- 内容は .claude/rules/coding-standards.md に統合/home/ena/yolo-web/docs/deploy.md-- 内容は .claude/rules/git-conventions.md に統合/home/ena/yolo-web/docs/analytics.md-- 内容は .claude/rules/coding-standards.md のArchitectureセクションに含めるか、必要時にresearcherが参照
残すファイル:
docs/constitution.md-- 不変(絶対に変更しない)docs/backlog.md-- main agentが直接編集するバックログdocs/architecture.md-- アーキテクチャ原則(.claude/rules/coding-standards.md と重複するが、サイトコンテンツセクションの情報は固有)docs/setup.md-- セットアップ手順(人間の開発者向けにも必要)docs/README.md-- プロジェクト概要docs/index.md-- 更新が必要(削除したファイルへの参照を削除)docs/cycle-catalog/-- そのまま残す
更新するファイル:
/home/ena/yolo-web/docs/index.md を以下に更新:
# ドキュメント一覧
## 不変ポリシー
- [Constitution](constitution.md) -- プロジェクトの不変ルール
## プロジェクトドキュメント
- [README](README.md) -- プロジェクト概要
- [アーキテクチャ](architecture.md) -- サイト構成とコンテンツセクション
- [セットアップ](setup.md) -- 開発環境セットアップ手順
- [バックログ](backlog.md) -- プロダクトバックログ
## エージェント設定(.claude/ 配下)
- \`.claude/rules/\` -- 詳細ルール(メモシステム、コーディング規約、サイクル管理、Git規約)
- \`.claude/skills/\` -- 再利用可能な手順(ブログ記事作成、サイクル管理等)
- \`.claude/agents/\` -- 専門サブエージェント定義
受入基準:
- 削除対象の6ファイルが存在しない
- docs/constitution.md, docs/backlog.md, docs/architecture.md, docs/setup.md, docs/README.md, docs/index.md が残っている
- docs/index.md が更新されている
- docs/cycles/ ディレクトリが存在する(空でもよい)
フェーズ5: Hooks による確定的な制約強制
Step 5.1: .claude/settings.json の更新
ファイル: /home/ena/yolo-web/.claude/settings.json
変更後の全内容:
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"allow": ["Bash", "WebFetch"],
"deny": ["Edit(/docs/constitution.md)", "Write(/docs/constitution.md)"]
},
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/pre-commit-check.sh"
}
]
},
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/protect-constitution.sh"
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/protect-memo-direct.sh"
}
]
}
]
},
"defaultMode": "acceptEdits"
}
Step 5.2: constitution.md 保護フック(新規)
ファイル: /home/ena/yolo-web/.claude/hooks/protect-constitution.sh
#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.file // empty')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
# Resolve to absolute path for comparison
ABS_PATH=$(realpath "$FILE_PATH" 2>/dev/null || echo "$FILE_PATH")
CONSTITUTION=$(realpath "$CLAUDE_PROJECT_DIR/docs/constitution.md" 2>/dev/null)
if [ "$ABS_PATH" = "$CONSTITUTION" ]; then
echo "constitution.md is immutable and cannot be modified." >&2
exit 2
fi
exit 0
Step 5.3: memo/ディレクトリ直接操作防止フック(新規)
ファイル: /home/ena/yolo-web/.claude/hooks/protect-memo-direct.sh
#!/bin/bash
INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command')
# Check for direct file operations on memo/ directory
# Allow: npm run memo (the CLI tool)
# Block: direct mv, cp, rm, touch, cat >, echo > targeting memo/
if echo "$COMMAND" | grep -qE '(mv|cp|rm|touch|mkdir).*memo/' && ! echo "$COMMAND" | grep -q 'npm run memo'; then
echo "Direct manipulation of memo/ directory is prohibited. Use 'npm run memo' CLI instead." >&2
exit 2
fi
# Block redirects into memo/
if echo "$COMMAND" | grep -qE '>.*memo/'; then
echo "Direct file writing to memo/ directory is prohibited. Use 'npm run memo' CLI instead." >&2
exit 2
fi
exit 0
Step 5.4: 新規フックファイルに実行権限を付与
chmod +x .claude/hooks/protect-constitution.sh
chmod +x .claude/hooks/protect-memo-direct.sh
受入基準:
- .claude/settings.json が上記の内容である
- protect-constitution.sh が存在し実行可能である
- protect-memo-direct.sh が存在し実行可能である
- constitution.md への Write/Edit がブロックされる
-
mv memo/agent/inbox/xxx memo/agent/archive/のような直接操作がブロックされる -
npm run memo -- mark xxx archiveは通過する
フェーズ6: docs/cycles/ ディレクトリの初期化
Step 6.1: ディレクトリ作成
mkdir -p docs/cycles
受入基準:
- docs/cycles/ ディレクトリが存在する
実施順序と依存関係
フェーズ1(メモシステム再構築)
├── Step 1.1(ディレクトリ)
├── Step 1.2(types.ts)→ Step 1.3, 1.4 に依存される
├── Step 1.3(mark.ts owner保護)
├── Step 1.4(create.ts owner保護)
└── Step 1.5(テスト更新)→ Step 1.2, 1.3, 1.4 完了後
フェーズ2(CLAUDE.md簡素化)→ フェーズ1完了後
├── Step 2.1(.claude/rules/ 作成)
└── Step 2.2(CLAUDE.md書き換え)→ Step 2.1完了後
フェーズ3(Sub-Agent再構築)→ フェーズ2完了後(rules参照のため)
├── Step 3.1(旧agent定義削除)
└── Step 3.2(新agent定義作成)→ Step 3.1と同時可
フェーズ4(Skills拡充)→ フェーズ2完了後
├── Step 4.1(cycle-template)
├── Step 4.2(cycle-kickoff更新)
├── Step 4.3(cycle-completion更新)
└── Step 4.4(docs/整理)→ Step 2.1完了後(移行先の確認)
フェーズ5(Hooks)→ フェーズ1完了後(独立して並行可能)
├── Step 5.1(settings.json)
├── Step 5.2(constitution保護)
├── Step 5.3(memo直接操作防止)
└── Step 5.4(実行権限)
フェーズ6(cycles/)→ 依存なし(いつでも可能)
推奨実施順序:
- フェーズ1 (全Step)
- フェーズ5 + フェーズ6 (並行)
- フェーズ2
- フェーズ3 + フェーズ4 (並行)
各フェーズ完了時にコミットすること。
ロールバック方針
- 各フェーズは独立したコミットにするため、
git revertで個別にロールバック可能 - メモの既存データは移動・削除しないため、旧システムへの復帰は types.ts と paths.ts の revert で可能
- フェーズ2-4 のドキュメント移行は、docs/ の削除ファイルを git restore で復元し CLAUDE.md を revert すれば復帰可能
- フェーズ5 の Hooks は settings.json を revert すれば即座に無効化
全体の受入基準
- CLAUDE.md が60行以内である
- 否定形の指示がCLAUDE.mdに含まれていない
- .claude/rules/ に4つのルールファイルが存在する
- .claude/agents/ に6つのagent定義が存在する
- researcher, planner, reviewer に disallowedTools が設定されている
- memo/agent/{inbox,active,archive}/ が存在する
- memo CLI で agent ロールが使用可能
- owner メモの agent による mark がブロックされる
- constitution.md の編集が Hooks でブロックされる
- memo/ の直接操作が Hooks でブロックされる
- 既存メモ 597件がすべて保持されている
- npm run typecheck, lint, format:check, test, build がすべてパス
- docs/constitution.md が変更されていない
Next actions
- このプランを reviewer に送付してレビューを受ける
- レビュー承認後、PM にプランのメモIDを報告する
- PMからownerに承認依頼を送付する
- owner承認後、builder にフェーズ順に実装を依頼する