Skip to content
Open
Changes from all 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
98 changes: 98 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## What this repo is

This is **not an application** — it's a Claude Code **plugin**: a curated collection of agents, skills,
commands, rules, hooks, and MCP configs meant to be installed into a user's `~/.claude/` directory (or
loaded as a plugin via `/plugin install`). Changes here are authored as Markdown/JSON config files and a
small set of cross-platform Node.js scripts that implement the hooks. There is no app to build or serve.

## Commands

```bash
# Run the full test suite
node tests/run-all.js

# Run an individual test file
node tests/lib/utils.test.js
node tests/lib/package-manager.test.js
node tests/hooks/hooks.test.js
```

Tests are plain Node scripts (no test framework/runner dependency, no `package.json`). Each test file is
directly executable and prints pass/fail counts; `tests/run-all.js` just shells out to each one in turn and
aggregates results.

There is no lint/build/typecheck step — the only "source code" is the hook implementation under `scripts/`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the documented source-code boundary.

CLAUDE.md says that the only source code is under scripts/ and that non-trivial hook logic uses scripts/hooks/. However, hooks/hooks.json contains substantial inline Node implementations, including the PostToolUse PR parser, the TypeScript check, and the Stop Git scan. Clarify that this is the preferred rule for new hooks, or move these existing handlers into scripts.

Also applies to: 53-65

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CLAUDE.md` at line 28, Update the source-code guidance in CLAUDE.md to
acknowledge the substantial inline Node implementations in hooks/hooks.json,
including the PostToolUse PR parser, TypeScript check, and Stop Git scan. State
that scripts/hooks/ is the preferred location for new non-trivial hook logic, or
migrate those existing handlers there while preserving their behavior.


## Architecture

### Component types and where they live

| Dir | Purpose | Installed to |
|---|---|---|
| `agents/` | Subagent definitions (frontmatter + system prompt) for delegation | `~/.claude/agents/` |
| `skills/` | Workflow/domain-knowledge docs invoked by commands or agents | `~/.claude/skills/` |
| `commands/` | Slash commands (`/plan`, `/tdd`, `/code-review`, etc.) | `~/.claude/commands/` |
| `rules/` | Always-follow guidelines, kept modular by topic | `~/.claude/rules/` |
| `hooks/` | `hooks.json` (event → matcher → command wiring) + hook subsystems | `~/.claude/hooks/` + merged into `~/.claude/settings.json` |
| `scripts/` | The actual Node.js implementations that hooks invoke | referenced via `${CLAUDE_PLUGIN_ROOT}/scripts/...` |
| `mcp-configs/` | MCP server config templates (GitHub, Supabase, Vercel, Railway, ...) | copied into `~/.claude.json` |
| `contexts/` | Dynamic system-prompt injection snippets (dev/review/research modes) | referenced by hooks/commands |
| `examples/` | Example `CLAUDE.md` / user-level config for reference — not installed | — |
| `.claude-plugin/` | `plugin.json` (metadata, points at `commands`/`skills`) and `marketplace.json` (self-hosted marketplace catalog) | — |

Everything under `agents/`, `commands/`, `rules/`, `skills/` is a leaf config file (or small directory for
multi-file skills) — there's no cross-file coupling between them beyond naming conventions, so most changes
are additive and isolated to a single file.
Comment on lines +47 to +49

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Document the existing cross-file contracts.

The statement that these directories have no cross-file coupling is incorrect. Line 37 documents skill references from commands and agents. Line 43 documents context references from hooks and commands. Lines 78-79 document the /setup-pm reference to scripts/setup-package-manager.js. A rename or move can break these references. Replace this statement with guidance to check references before changing names or paths.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CLAUDE.md` around lines 47 - 49, Update the documentation near the statement
about agents/, commands/, rules/, and skills/ to acknowledge the existing
cross-file contracts, including skill, context, and /setup-pm script references.
Replace the claim of no cross-file coupling with guidance to search and update
all references before renaming or moving files, directories, or paths.


### Hooks: config vs. implementation split

`hooks/hooks.json` is the declarative wiring: for each lifecycle event (`PreToolUse`, `PostToolUse`,
`PreCompact`, `Stop`, etc.) it lists `matcher` expressions (evaluated against `tool` / `tool_input`) and the
`command` to run. Two shapes of command appear:
- Inline `node -e "..."` one-liners for simple checks (e.g. blocking `npm run dev` outside tmux, warning
about stray `.md` file creation).
- Calls into `scripts/hooks/*.js` via `${CLAUDE_PLUGIN_ROOT}/scripts/hooks/<name>.js` for anything
non-trivial (session memory persistence, pre-compact state saving, strategic-compact suggestions,
session evaluation/pattern extraction).

When adding or changing hook behavior, decide which shape fits: trivial and self-contained → inline in
`hooks.json`; stateful, multi-step, or shared logic → a script under `scripts/hooks/` using the shared
helpers in `scripts/lib/utils.js` (cross-platform file/path/system helpers) and
`scripts/lib/package-manager.js` (package-manager detection).

`tests/hooks/hooks.test.js` validates `hooks.json` itself (valid JSON, required event types present, all
commands use `node` — not bash/sh, for Windows compatibility — and script references use the
`${CLAUDE_PLUGIN_ROOT}` variable rather than hardcoded paths). Keep hook scripts Node-only; this repo
explicitly supports Windows/macOS/Linux and previously bash-only hooks were rewritten in Node.js for that
reason.

### Package manager detection

`scripts/lib/package-manager.js` picks npm/pnpm/yarn/bun using a fixed priority order: `CLAUDE_PACKAGE_MANAGER`
env var → `.claude/package-manager.json` (project) → `package.json` `packageManager` field → lock file
detection → `~/.claude/package-manager.json` (global) → first available. `scripts/setup-package-manager.js`
is the interactive/CLI entry point (`--global`, `--project`, `--detect`), also exposed as the `/setup-pm`
slash command. Any hook or script that shells out to a package manager should go through this detection
rather than hardcoding `npm`.

### Authoring conventions (enforced by CONTRIBUTING.md, not by tooling)

- **Agents** (`agents/*.md`): YAML frontmatter with `name`, `description`, `tools`, `model`, followed by the
system prompt.
- **Skills** (`skills/<name>/` or `skills/<name>.md`): sections `## When to Use`, `## How It Works`,
`## Examples`.
- **Commands** (`commands/*.md`): frontmatter with `description`, then the command body.
- **Rules** (`rules/*.md`): one topic per file, kept short and imperative.
- **Hooks**: every entry in `hooks.json` should carry a `description` explaining what it does.
- File naming: lowercase-with-hyphens, descriptive (`tdd-workflow.md`, not `workflow.md`).

### Two audiences for docs

`README.md` is the public/generic install & usage doc for any Claude Code user. `WORLDFLOWAI.md` is a
project-specific quick-reference for this maintainer's own `synapse` (Rust) and `arbiter` (Python/ML)
projects — it documents which agents/commands to reach for in each, and assumes symlink-based installation
from `~/dev/worldflowai/everything-claude-code`. Don't merge these — they serve different readers.