shep
CLAUDE.md262 starsChanged 8 months agoMITView on GitHub
Guidance for Claude Code working in this repository. @shepai/cli — Autonomous AI-native SDLC platform — run parallel AI agents in isolated worktrees to automate the development cycle from idea to deploy. All feature work MUST begin with /shep-kit:new-feature. See spec-driven-workflow. /shep-kit:new-feature → /shep-kit:research → /shep-kit:plan → /shep-kit:implement → /shep-kit:commit-pr Specs live in specs/NNN-feature-name/. Edit YAML only — Markdown is auto-generated. Clean Architecture — four layers in packages/core/src/ (dependencies point inward): See clean-architecture. Conventional Commits: <type>(<scope>): <subject> The scope is optional…
In this repository23 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- packages/CLAUDE.mdCLAUDE.md
- src/CLAUDE.mdCLAUDE.md
- architecture-reviewerSkill
- cross-validate-artifactsSkill
- mermaid-diagramsSkill
- react-flowSkill
- shadcn-uiSkill
- shep-kit:commit-prSkill
- shep-kit:fast-loopSkill
- shep-kit:implementSkill
- shep-kit:mergedSkill
- shep-kit:new-feature-fastSkill
- shep-kit:new-featureSkill
- shep-kit:parallel-taskSkill
- shep-kit:planSkill
- shep-kit:researchSkill
- shep-kit:statusSkill
- shep:ui-componentSkill
- shep-workstreamsSkill
- tsp-modelSkill
- vercel-react-best-practicesSkill
The file
We split this CLAUDE.md into the rules it gives an agent
9 rules. About 0 are common, 4 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 45
MANDATORY — TDD: Write failing tests FIRST (RED → GREEN → REFACTOR).
- Very specific: line 47
MANDATORY — Agent resolution: No component may hardcode an agent type.
- Very specific: line 48
MANDATORY — Storybook stories: Every web UI component MUST have a colocated .stories.tsx file.
- Very specific: line 49
MANDATORY — Spec-driven: All features start with /shep-kit:new-feature.
- Very specific: line 108
Use cases receive their ports via @inject('IPortName') constructor parameters — never by importing an infrastructure module.
- Very specific: line 174
After ANY correction from the user — including bug reports, unexpected behavior reports, and "why didn't X work?" questions — immediately …
- Distinctive: line 176
Write rules for yourself that prevent the same mistake
- Distinctive: line 179
Keep lessons short and concise
- Distinctive: line 183
If a fix feels hacky: "Knowing everything I know now, implement the elegant solution"
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
Guidance for Claude Code working in this repository.
Project
@shepai/cli — Autonomous AI-native SDLC platform — run parallel AI agents in isolated worktrees to automate the development cycle from idea to deploy.
Spec Workflow
All feature work MUST begin with /shep-kit:new-feature. See spec-driven-workflow.
/shep-kit:new-feature → /shep-kit:research → /shep-kit:plan → /shep-kit:implement → /shep-kit:commit-pr
Specs live in specs/NNN-feature-name/. Edit YAML only — Markdown is auto-generated.
Commands
| Command | Purpose |
pnpm build | Build CLI only (fast, for dev) |
pnpm build:release | Build CLI + web (CI/packaging) |
pnpm test | Run all tests (unit + integration + e2e) |
pnpm test:unit | Unit tests only |
pnpm test:int | Integration tests only |
pnpm test:e2e | Playwright e2e tests |
pnpm lint:fix | Fix lint issues |
pnpm validate | Lint + format + typecheck + tsp |
pnpm dev:cli | Run CLI locally (tsx) |
pnpm dev:web | Start Next.js dev server |
Architecture
Clean Architecture — four layers in packages/core/src/ (dependencies point inward):
domain/— Core business logic, no external depsapplication/— Use cases, output port interfacesinfrastructure/— External concerns: DB, agents, servicespresentation/— CLI, TUI, Web UI (src/presentation/)
See clean-architecture.
Mandatory Rules
- MANDATORY — TDD: Write failing tests FIRST (RED → GREEN → REFACTOR). Every plan phase must define explicit TDD cycles. See tdd-guide.
- MANDATORY — TypeSpec-first: Domain models defined in
tsp/. Runpnpm tsp:compileto generatepackages/core/src/domain/generated/output.ts. Never edit generated files. See typespec-guide. - MANDATORY — Agent resolution: No component may hardcode an agent type. All resolution flows through
IAgentExecutorProvider. See AGENTS.md. - MANDATORY — Storybook stories: Every web UI component MUST have a colocated
.stories.tsxfile. Commits without stories will be rejected. - MANDATORY — Spec-driven: All features start with
/shep-kit:new-feature. No implementation without a spec. - MANDATORY — Own every failure: You are the ONLY developer. Every test failure, CI failure, and security scan failure is YOUR responsibility. NEVER use the words "unrelated", "pre-existing", or "not our changes". See integrity rules.
- MANDATORY — Read LESSONS.md: You MUST read
LESSONS.mdat the start of every session before writing any code. It contains hard-won lessons from past mistakes. Ignoring it means repeating failures that have already been solved.
Commit Format
Conventional Commits: <type>(<scope>): <subject>
| Types | feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert | | Scopes | specs, shep-kit, cli, tui, web, api, domain, agents, deployment, tsp, deps, config, dx, release, ci |
The scope is optional — commitlint reports an unknown scope as a warning (severity 1) and
.github/workflows/pr-check.yml sets requireScope: false. Subject case is not enforced
('subject-case': [0]); keep it under 72 characters with no trailing period. docs and build
are types, never scopes. Release impact (release.config.mjs): feat → minor;
fix, perf, revert and refactor → patch; docs, style, test, build, ci,
chore → no release.
TypeSpec Domain Models
Domain types are authored in TypeSpec, never hand-written in TypeScript.
- Source:
tsp/(tsp/common/enums/,tsp/domain/entities/,tsp/agents/, …) - Generated:
packages/core/src/domain/generated/output.ts(+index.ts) — never edit these - Regenerate:
pnpm generate(=tsp compile tsp/ --emit @typespec-tools/emitter-typescriptfollowed byprettier --writeover the generated directory) - Compile-check only:
pnpm tsp:compile; format:pnpm tsp:format; watch:pnpm tsp:watch
The generated file is committed. CI's Type Check job re-runs pnpm generate and fails if the
result differs from what is committed, and the pre-commit hook runs pnpm generate and stages
packages/core/src/domain/generated/ for you.
Any domain concept used for branching — status, phase, mode, agent type — MUST be a TypeSpec enum
rather than a raw string. Adding a member to a total-Record consumer (such as
AGENT_CATALOG in domain/shared/agent-catalog.ts) turns the omission into a compile error,
which is the intended way to discover everything a new member must touch.
Full guide: docs/development/typespec-guide.md.
Dependency Injection
Shep uses tsyringe. reflect-metadata must be imported before anything else — it is the
first import in src/presentation/cli/index.ts.
- Container:
packages/core/src/infrastructure/di/container.ts, exposinginitializeContainer()(opens the database, runs migrations, registers everything) and thecontainersingleton. - Registration modules:
packages/core/src/infrastructure/di/modules/register-*.ts(repositories, services, use cases, agents, tools, security, plugins, ASPM, …). - Ports are registered under string tokens matching the interface name, and resolved the same way:
const featureRepo = container.resolve<IFeatureRepository>('IFeatureRepository');
const showFeature = container.resolve(ShowFeatureUseCase); // concrete classes resolve by typeRules:
- Use cases receive their ports via
@inject('IPortName')constructor parameters — never by importing an infrastructure module. - Presentation code (CLI/TUI/Web) may resolve from the container, but only to reach a use case; business logic never lives in a command or component.
- Module-level singletons and global accessors (
getSettings(),getShepHomeDir()) belong to infrastructure bootstrapping. Do not call them from use cases — inject instead, so tests can substitute a double without patching modules.
See docs/architecture/repository-pattern.md.
Data Storage
Everything Shep knows lives locally. There is no Shep server.
| Path | What |
~/.shep/data | SQLite database (features, agent runs, settings, activity log, …) |
~/.shep/daemon.json | Running daemon's pid/port record |
~/.shep/daemon.log | Daemon log |
~/.shep/logs/ | Feature-agent process logs |
~/.shep/repos/<repo-hash>/wt/<branch> | Per-feature git worktrees |
SHEP_HOME overrides ~/.shep (used for test isolation); DEBUG_SQL makes better-sqlite3 log
every statement; DEBUG (any truthy value — it is a plain truthy check, not a namespace filter)
turns on verbose CLI/deployment logging. The web daemon's port comes from shep start --port /
shep ui --port, not an env var — SHEP_WEB_PORT is written by the server and read only by
the middleware's Host-header check. SHEP_BIND_HOST, SHEP_ALLOW_PUBLIC_BIND,
SHEP_ALLOWED_HOSTS and SHEP_WEB_REQUIRE_TOKEN gate non-localhost access.
- Engine:
better-sqlite3, opened as a process-wide singleton inpackages/core/src/infrastructure/persistence/sqlite/connection.ts. - Migrations:
packages/core/src/infrastructure/persistence/sqlite/migrations/, run by umzug viarunSQLiteMigrations()on container init. Each migration owns one change and is idempotent (CREATE TABLE IF NOT EXISTS/ guardedALTER). - Repositories implementing the
application/ports/output/repositories/interfaces live inpackages/core/src/infrastructure/repositories/; row⇄entity conversion lives inpersistence/sqlite/mappers/.
Per-repository files Shep reads from a target repo: <repo>/.shep/dev.json (dev-server run
config) and <repo>/.shep/ownership.yaml (ASPM ownership import). There is no
.shep/config.json.
Key Docs
| Topic | Doc |
| Architecture overview | docs/architecture/overview.md |
| Domain models + field listings | docs/api/domain-models.md |
| Repository pattern + DI | docs/architecture/repository-pattern.md |
| Agent system | docs/architecture/agent-system.md |
| Settings service | docs/architecture/settings-service.md |
| TypeSpec guide | docs/development/typespec-guide.md |
| Testing guide | docs/development/tdd-guide.md |
| Implementation patterns | docs/development/implementation-guide.md |
| CI/CD + Docker | docs/development/cicd.md |
| Adding an agent provider | docs/development/adding-agent-types.md |
| Adding a LangGraph agent node | docs/development/adding-agent-nodes.md |
| Query-aware agent harness | docs/architecture/query-aware-harness.md |
| Dev server run plans | docs/development/dev-server-run-plan.md |
| CLI architecture | docs/cli/architecture.md |
| TUI architecture | docs/tui/architecture.md |
| Web UI architecture | docs/ui/architecture.md |
| pnpm workspaces + setup | docs/development/setup.md |
General
1. Self-Improvement Loop
- After ANY correction from the user — including bug reports, unexpected behavior reports, and "why didn't X work?" questions — immediately update
LESSONS.md(project root) with the pattern. Do NOT wait to be asked. - This includes: bugs you fix, missing wiring you add, patterns you got wrong, anything the user had to tell you that you should have caught yourself.
- Write rules for yourself that prevent the same mistake
- Ruthlessly iterate on these lessons until mistake rate drops
- Review lessons at session start for relevant project
- Keep lessons short and concise
2. Demand Elegance (Balanced)
- For non-trivial changes: pause and ask "is there a more elegant way?"
- If a fix feels hacky: "Knowing everything I know now, implement the elegant solution"
- Skip this for simple, obvious fixes – don't over-engineer
- Challenge your own work before presenting it
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

