Skip to content

feat: Phase 1 scaffold — hooks, skills, agents, rules, templates#1

Open
robotlearning123 wants to merge 28 commits intomainfrom
feat/phase1-scaffold
Open

feat: Phase 1 scaffold — hooks, skills, agents, rules, templates#1
robotlearning123 wants to merge 28 commits intomainfrom
feat/phase1-scaffold

Conversation

@robotlearning123
Copy link
Copy Markdown
Member

Summary

Complete v0.0.1 scaffold for agent-driven development with Claude Code + Codex.

This PR delivers the full Phase 1 scaffold, shaped by ccz deep review (6.4/10 → estimated 7.5-8.0):

  • 9 hooks — observability, quality gates, branch guards, context rotation, lint, stall detection
  • 5 skills/init-project, /dispatch, /plan, /ship, /metrics
  • 4 agents — coordinator, implementer, reviewer, tester
  • 4 rules — context management, git workflow, quality standards, security
  • 3 templates — CLAUDE.md per stack (Python, React, fullstack) + AGENTS.md
  • Test suite — 10/10 passing (tests/test_hooks.sh)
  • Research — 5 reports informing the design

Bug fixes (from ccz review)

  • Float comparison crash in context rotation hook (bash [ -ge ] on decimals)
  • set -euo pipefail causing premature exits on expected grep/jq failures → set -uo pipefail
  • pytest exit code 5 (no tests collected) treated as failure in 3 hooks
  • npm test exit code lost through pipe in subagent-stop-metrics
  • Stall detector dead code (not wired in settings.json)

Shell conventions (unified across all hooks)

  • set -uo pipefail (NOT -euo)
  • # Requires: header declaring external deps
  • # shellcheck shell=sh for static analysis
  • Explicit error handling via || true, 2>/dev/null

Test plan

  • tests/test_hooks.sh — 10/10 passing
  • Installed on lab-manager (real project validation) — all hooks adapted and working
  • find .claude/hooks -name "*.sh" -exec test -x {} \; -print — all executable

Generated with Claude Code
via Happy

Co-Authored-By: Claude noreply@anthropic.com
Co-Authored-By: Happy yesreply@happy.engineering

sandia777 and others added 28 commits March 27, 2026 16:40
Agents: coordinator, implementer, reviewer, tester
Hooks: post-edit-lint, branch-guard, stall-detector, subagent-stop-verify, task-completed-gate
Rules: context-management, git-workflow, quality-standards, security
Observability: metrics and traces directories
Docs: DESIGN.md spec + research docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- post-tool-use-trace: JSON-lines action logging per session
- subagent-stop-metrics: outcome logging + test verification
- pre-compact-rotation: 65% context rotation enforcement
- session-start-handover: auto episodic memory generation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- README with quick start and Day 1 scenario
- CLAUDE.md for the repo itself (<40 lines)
- settings.json wiring all 9 hooks to 6 lifecycle events
- /init-project skill with stack detection
- CLAUDE.md templates (Python, TypeScript)
- AGENTS.md template
- Structured docs (WORKFLOW, PROGRESS, PLAN, PROMPT, CONVENTIONS)
- Procedural memory example (python-fastapi-feature)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4-file doc pattern: PROMPT.md, PLAN.md, PROGRESS.md, CONVENTIONS.md
Structured memory: procedural/python-fastapi-feature.md,
pitfalls/common-agent-failures.md, episodic/ (empty, gitkeep)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- /dispatch skill: wave planning, dependency resolution, parallel execution,
  cross-engine review, staged merging protocol
- VERSION: 0.0.1
- LICENSE: MIT

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nore

- Rename session-start-handover.sh → session-end-episodic.sh (matches purpose)
- Reduce trace hook scope: Bash|Edit|Write only (Read/Glob/Grep too noisy)
- Add .gitignore (metrics, traces, episodic are runtime data)
- Add fullstack + react templates (from ralph loop)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
/init-project: stack detection, config generation, agent-readiness scoring
Templates: python, react, fullstack CLAUDE.md + AGENTS.md
Auto-detects: test/lint/format commands, framework, project type

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…emplates

settings.json: PreToolUse, PostToolUse, SubagentStop, Stop, PreCompact, TaskCompleted
init-project skill: stack detection, config gen, readiness scoring
Templates: python, react, fullstack CLAUDE.md + AGENTS.md
README: cleaned up

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
settings.json referenced non-existent session-start-handover.sh but the
actual file is session-end-episodic.sh.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Keep .claude/skills/init-project/SKILL.md (directory format, CC standard)
and delete the root-level .claude/skills/init-project.md duplicate.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Spec says 65% mandatory rotation, hook enforced at 70%. Changed to
65% mandatory and 55% warning (10% before mandatory).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
grep -c outputs "0" on no match but exits 1, causing || echo "0" to
append a second "0" line. Use || VARIABLE=0 pattern instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|| true after command substitution makes $? always 0. Capture output
first, then check $RC separately.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Was a stub that only logged. Now checks tests and lint before allowing
task completion. Exit 2 blocks completion if checks fail.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
post-edit-lint.sh and stall-detector.sh use set -uo pipefail (no -e,
non-blocking). pre-tool-branch-guard.sh and subagent-stop-verify.sh
use set -euo pipefail (blocking hooks).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use git symbolic-ref to detect origin's default branch (main or master)
with fallback to main. Fixes hooks failing on repos using master.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Keep AGENTS.md.template as the canonical template, remove agents-md.md
duplicate.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Keep claude-md-{stack}.md naming convention (claude-md-python.md,
claude-md-react.md, claude-md-fullstack.md). Remove CLAUDE.md.python
and CLAUDE.md.typescript duplicates.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There are 9 hook scripts, not 8.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prevent local settings overrides and log files from being committed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Referenced session-start-handover but the actual hook is
session-end-episodic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Both subagent-stop-metrics.sh and subagent-stop-verify.sh had the same
bug: `RC=$?` after `$(npm test 2>&1 | tail -1)` captures tail's exit
code (always 0), not npm test's exit code. Fixed by running npm test
first, capturing RC, then tailing output separately.

Found by: QA review round 2 (12/13 pass, this was the 1 fail + 1 new)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ilure

jq exits non-zero on malformed input. With set -e, the entire hook
crashes (exit 127) instead of gracefully exiting 0. Changed to set -uo
and added 2>/dev/null || echo "" fallback on jq call.

Found by: strict QA real test suite (3 failures, this was 1 of them).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- pre-compact-rotation.sh: handle float context percentages (bash -ge
  only accepts integers, 72.5 would crash)
- subagent-stop-verify.sh: handle no-remote repos (fallback to local
  main/master/current), handle pytest exit 5 (no tests collected)
- subagent-stop-metrics.sh: same no-remote + pytest fixes, fix test
  detection glob (*/test → **/test), add Go func Test pattern
- task-completed-gate.sh: handle pytest exit 5
- settings.json: wire stall-detector.sh (was dead code)
- Add test suite: 10 tests, all passing

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
- Add methodology note to header: star counts are estimates from
  public npm data, see docs/research/ for details
- Replace exact star counts (118K★, 52K★) with estimated installs
  (npm, est.) to signal uncertainty
- Fix cc-manager success rate claim: now references docs/research/
  for methodology instead of stating as fact
- Soften compound failure claim from "85% per-step = 20% over 10"
  to "Est. 85% per-step = 20% over 10 steps (compound)"
- Context degradation: note 65% is a chosen threshold, not a
  Stanford citation (no specific paper found)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
 to agent-driven scaffold

to Plan: feature spec review with 3 parallel reviewers (security, architecture, correctness)
to Ship: quality pipeline (tests, lint, review) to PR
to Metrics: summary, session, trends, failures, clean subcommands

Coloses ccz review gap: missing /plan, /ship, /metrics skills (P1)

README referenced all 3 but now implemented

All integrate into workflow after /init-project

Generated with [Claude Code](https://claude.com/claude-code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
- Standardize all hooks to set -uo pipefail (not -euo)
  - -euo causes premature exit on grep/jq failures
  - All hooks handle errors explicitly via || true / 2>/dev/null
- Add Requires: header to all hooks listing external deps
- Add shellcheck shell=sh directive to all hooks
- Update CONVENTIONS.md with full dependency table
- Update CLAUDE.md to reflect -uo (not -euo) convention
- Update post-edit-lint.sh to use command -v for graceful dep check

All 10 tests pass.

Closes: ccz review gap - inconsistent shell style (P3)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

Generated with [Claude Code](https://claude.com/claude-code)
via [Happy](https://happy.engineering)
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants