agentleFS
shep-aishep-ai/shep/AGENTS.md

shep

AGENTS.md262 starsChanged 8 months agoMITView on GitHub

Guidance for AI coding agents (Cursor, Windsurf, Copilot, etc.) working in this repository. @shepai/cli — Autonomous AI Native SDLC Platform. Users run shep in a repo to gather requirements via AI, generate plans, and execute implementation autonomously. 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. No component…

The file

We split this AGENTS.md into the rules it gives an agent

12 rules. About 0 are common, 4 are distinctive, and 8 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.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    MANDATORY — TDD: Write failing tests FIRST (RED → GREEN → REFACTOR).

    line 45
  2. Very specific:

    MANDATORY — Agent resolution: No component may hardcode an agent type.

    line 47
  3. Very specific:

    MANDATORY — Storybook stories: Every web UI component MUST have a colocated .stories.tsx file.

    line 48
  4. Very specific:

    MANDATORY — Spec-driven: All features start with /shep-kit:new-feature.

    line 49
  5. Very specific:

    MANDATORY — Actor namespaces: When an agent acts on a user's behalf (e.g., the supervisor closing an approval gate), it MUST use the …

    line 50
  6. Very specific:

    No component may name an agent: Every LLM call resolves the agent from settings, at call time, through IAgentExecutorProvider:

    line 54
  7. Very specific:

    No agent type captured at construction time and reused later — resolve per call, so shep settings agent takes effect without a restart.

    line 81
  8. Very specific:

    When the supervisor closes a gate, it invokes the existing ApproveAgentRunUseCase / RejectAgentRunUseCase with actor.namespace = …

    line 188
  9. Very specific:

    After ANY correction from the user: update LESSONS.md (project root) with the pattern

    line 214
  10. Distinctive:

    Write rules for yourself that prevent the same mistake

    line 215
  11. Distinctive:

    Keep lessons short and concise

    line 218
  12. Distinctive:

    If a fix feels hacky: "Knowing everything I know now, implement the elegant solution"

    line 222

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

Guidance for AI coding agents (Cursor, Windsurf, Copilot, etc.) working in this repository.

Project

@shepai/cli — Autonomous AI Native SDLC Platform. Users run shep in a repo to gather requirements via AI, generate plans, and execute implementation autonomously.

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

CommandPurpose
pnpm buildBuild CLI only (fast, for dev)
pnpm build:releaseBuild CLI + web (CI/packaging)
pnpm testRun all tests (unit + integration + e2e)
pnpm test:unitUnit tests only
pnpm test:intIntegration tests only
pnpm test:e2ePlaywright e2e tests
pnpm lint:fixFix lint issues
pnpm validateLint + format + typecheck + tsp
pnpm dev:cliRun CLI locally (tsx)
pnpm dev:webStart Next.js dev server

Architecture

Clean Architecture — four layers in packages/core/src/ (dependencies point inward):

  • domain/ — Core business logic, no external deps
  • application/ — Use cases, output port interfaces
  • infrastructure/ — External concerns: DB, agents, services
  • presentation/ — 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/. Run pnpm tsp:compile to generate packages/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 agent-system. The supervisor agent (spec 093) follows the same rule — its evaluator LLM is resolved through IAgentExecutorProvider, never a hardcoded provider SDK.
  • MANDATORY — Storybook stories: Every web UI component MUST have a colocated .stories.tsx file. Commits without stories will be rejected.
  • MANDATORY — Spec-driven: All features start with /shep-kit:new-feature. No implementation without a spec.
  • MANDATORY — Actor namespaces: When an agent acts on a user's behalf (e.g., the supervisor closing an approval gate), it MUST use the supervisor:<id> actor namespace. The user namespace user:<id> always wins on conflict — ApproveAgentRunUseCase / RejectAgentRunUseCase enforce this invariant. See supervision.

Settings-Driven Agent Resolution (MANDATORY)

No component may name an agent. Every LLM call resolves the agent from settings, at call time, through IAgentExecutorProvider:

// packages/core/src/application/ports/output/agents/agent-executor-provider.interface.ts
export interface IAgentExecutorProvider {
  getExecutor(): Promise<IAgentExecutor>;
}

The single implementation reads the user's stored choice and asks the factory for that executor — nothing else decides:

// packages/core/src/infrastructure/services/agents/common/agent-executor-provider.service.ts
async getExecutor(): Promise<IAgentExecutor> {
  const settings = await this.settingsRepository.load();
  if (!settings) throw new Error('Settings not found. Please run initialization first.');
  return this.factory.createExecutor(settings.agent.type, settings.agent);
}

What this forbids, concretely:

  • No import { ChatAnthropic } from '@langchain/anthropic' (or any other provider SDK) outside an executor in infrastructure/services/agents/common/executors/.
  • No if (agentType === AgentType.ClaudeCode) branch in a use case, node, command or component.
  • No agent type captured at construction time and reused later — resolve per call, so shep settings agent takes effect without a restart.
  • LangGraph nodes are factories that receive an executor and never choose one. See nodes/analyze.node.ts and how createFeatureAgentGraph() wires them.

The supervisor agent (spec 093) follows the same rule — its evaluator LLM is resolved through IAgentExecutorProvider, never a hardcoded provider SDK.

Deeper treatment, including the resolution sequence diagram: docs/architecture/agent-system.md.

Current Implementation

packages/core/src/domain/shared/agent-catalog.ts is the single source of truth for every agent fact. It is typed as a total Record<AgentType, AgentDescriptor>, so adding a member to the TypeSpec AgentType enum is a compile error until its row is filled in — the compiler produces the "what do I have to touch" list.

Agent typeLabelKindBinaryTool idStatus
claude-codeClaude CodeCLIclaudeclaude-codeSupported
kimi-codeKimi CodeCLIkimikimiSupported
codex-cliCodex CLICLIcodexcodexSupported
copilot-cliCopilot CLICLIcopilotcopilotSupported
cursorCursor CLICLIcursor-agentcursor-cliSupported
gemini-cliGemini CLICLIgeminigemini-cliSupported
clineClineCLIcline—Supported
openrouterOpenRouterSDK——Supported (API key)
together-aiTogether AISDK——Supported (API key)
ollamaOllamaSDK——Supported
llmproxyLLM ProxySDK——Supported
devDemomock——Supported
aiderAider———Coming soon — no executor
continueContinue———Coming soon — no executor

Two traps the catalog exists to stop repeating: Cursor's binary is cursor-agent, not cursor; and toolId MUST equal the basename of the JSON file under infrastructure/services/tool-installer/tools/, because that is how tool ids are derived.

Executors live in packages/core/src/infrastructure/services/agents/common/executors/ (one file per agent, plus ai-sdk-base-executor.service.ts for the HTTP/SDK agents and process-stream.ts for NDJSON CLI plumbing). AgentExecutorFactory derives its supported set from the catalog, so the picker and the factory cannot disagree.

To add a provider, follow docs/development/adding-agent-types.md.

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] in commitlint.config.mjs); keep it under 72 characters with no trailing period. Note docs and build are types, never scopes.

Key Docs

TopicDoc
Architecture overviewdocs/architecture/overview.md
Domain models + field listingsdocs/api/domain-models.md
Repository pattern + DIdocs/architecture/repository-pattern.md
Agent systemdocs/architecture/agent-system.md
Agent collaboration & supervisiondocs/architecture/supervision.md
Settings servicedocs/architecture/settings-service.md
TypeSpec guidedocs/development/typespec-guide.md
Testing guidedocs/development/tdd-guide.md
Implementation patternsdocs/development/implementation-guide.md
CI/CD + Dockerdocs/development/cicd.md
Adding an agent providerdocs/development/adding-agent-types.md
Adding a LangGraph agent nodedocs/development/adding-agent-nodes.md
CLI architecturedocs/cli/architecture.md
TUI architecturedocs/tui/architecture.md
Web UI architecturedocs/ui/architecture.md
pnpm workspaces + setupdocs/development/setup.md

Supervisor Agent (spec 093)

A delegated supervisor agent can monitor approval gates and agent questions on behalf of the user. The whole surface is gated behind the collaboration feature flag.

ConceptWhere
SupervisorPolicy (config)tsp/agents/supervisor-policy.tsp → supervisor_policies table
SupervisorDecision (audit)tsp/agents/supervisor-decision.tsp → supervisor_decisions + activity_log
ISupervisorAgent portpackages/core/src/application/ports/output/agents/supervisor-agent.interface.ts
Evaluator workflowpackages/core/src/infrastructure/services/agents/supervisor-agent/supervisor-graph.ts
Per-scope workerpackages/core/src/infrastructure/services/agents/supervisor-agent/supervisor-agent-worker.ts

Policy resolution is feature-first then app-fallback, matching every other scoped concept in Shep.

Autonomy ladder

LevelSupervisor authorityUser role
advisory (default)recommend (advise / escalate)always acts on every gate
cosignapprove / reject pre-votealso approves before gate passes
autonomouscloses gates via the existing approve/reject use cases with actor = supervisor:<id>optional override at any time

supervisor:<id> actor namespace

When the supervisor closes a gate, it invokes the existing ApproveAgentRunUseCase / RejectAgentRunUseCase with actor.namespace = "supervisor:<id>". Both use cases enforce the "user always wins" invariant: if a prior user:<id> decision exists for the same gate, the supervisor's call is refused and the rejection is recorded.

This keeps the existing waiting_approval state machine as the single source of truth — no new pause primitive was invented.

Unified question pipeline

AgentQuestion (tsp/agents/agent-question.tsp, table agent_questions) is the single inbox that bridges:

  • The Claude Code SDK V2 canUseTool interception of AskUserQuestion in claude-code-interactive-executor.service.ts (interactive mode), and
  • The parallel AgentQuestion of kind = blocking emitted by feature-agent-worker.ts whenever a run hits waiting_approval (background mode).

Both modes converge on AnswerAgentQuestionUseCase. See docs/architecture/supervision.md for the full design and sequence diagrams.

General

1. Self-Improvement Loop

  • After ANY correction from the user: update LESSONS.md (project root) with the pattern
  • 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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.