agentleFS
selftune-devselftune-dev/selftune/AGENTS.md

selftune

AGENTS.md17 starsChanged 9 months agoMITView on GitHub

selftune — Self-improving skills for AI agents. Watches real sessions, learns how users actually work, and evolves skill descriptions to match. Supports Claude Code, Codex, OpenCode, OpenClaw, and Pi. Stack: TypeScript on Bun for the CLI, Drizzle over Bun SQLite for operational/product state, a separate DuckDB observability-analytics domain, legacy/export JSONL recovery paths, Effect for owned runtime lifecycles, and a local React/Vite dashboard SPA. selftune is a skill consumed by AI agents, not a CLI tool used by humans directly. The…

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository3 other files it gives its agents.

The file

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

12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Do not edit or import from .repos/effect.

    line 12
  2. Very specific:

    Before writing Effect code, read .repos/effect/LLMS.md and inspect matching source, tests, and API signatures.

    line 13
  3. Very specific:

    When changing one part of selftune, check if dependent files need updating.

    line 116
  4. Distinctive:

    Keep one logical change per commit and use squash merge so the reviewed pull request becomes one attributable source-history event.

    line 157
  5. Very specific:

    Add Co-authored-by trailers only for people who materially contributed to the change.

    line 158
  6. Distinctive:

    Read this file, then follow pointers to relevant docs

    line 162
  7. Distinctive:

    Read PRD.md for product context and the feedback loop model

    line 163
  8. Very specific:

    Run sandbox harness: bun run tests/sandbox/run-sandbox.ts

    line 166
  9. Very specific:

    Run make check (lint + test) or bun test

    line 167
  10. Distinctive:

    Verify JSONL output schema matches appendix in PRD.md

    line 168
  11. Distinctive:

    All knowledge lives in-repo, not in external tools

    line 188
  12. Very specific:

    Keep runtime dependencies explicit and owned at the narrowest package boundary.

    line 190

≈ “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

Repository Overview

selftune — Self-improving skills for AI agents. Watches real sessions, learns how users actually work, and evolves skill descriptions to match. Supports Claude Code, Codex, OpenCode, OpenClaw, and Pi.

Stack: TypeScript on Bun for the CLI, Drizzle over Bun SQLite for operational/product state, a separate DuckDB observability-analytics domain, legacy/export JSONL recovery paths, Effect for owned runtime lifecycles, and a local React/Vite dashboard SPA.

Vendored Effect Reference

  • .repos/effect is the pinned Effect 4 source used as read-only reference material.
  • Do not edit or import from .repos/effect; application code must continue importing normal package dependencies.
  • Before writing Effect code, read .repos/effect/LLMS.md and inspect matching source, tests, and API signatures.
  • Editor search, file watching, and auto-imports must remain excluded from .repos/**.

Agent-First Architecture

selftune is a skill consumed by AI agents, not a CLI tool used by humans directly.

The user's interaction model is:

  1. Install the skill: npx skills add selftune-dev/selftune
  2. Tell their agent: "set up selftune" / "improve my skills" / "how are my skills doing?"
  3. The agent reads skill/SKILL.md, routes to the correct workflow, and runs CLI commands

The selftune binary composed in apps/cli/ is the agent's API. The skill definition (skill/SKILL.md) is the product surface. Workflow docs (skill/workflows/) are the agent's instruction manual. Users rarely if ever run selftune commands directly — their coding agent does it for them.

When developing selftune:

  • Changes to CLI behavior must be reflected in the corresponding skill/workflows/*.md doc
  • New CLI commands need a workflow doc and a routing entry in skill/SKILL.md
  • Error messages should guide the agent, not the human (e.g., suggest the next CLI command, not "check the docs")
  • The SKILL.md routing table and trigger keywords are as important as the CLI code itself — they determine whether the agent can find and use the feature
  • skill/SKILL.md and skill/workflows/*.md are shipped product surface for users' agents. Do not put repo-local contributor commands or monorepo workflow there (for example: cd oss/selftune, bun run dev, Vite/HMR details). Put contributor guidance in README.md, AGENTS.md, or internal docs instead.

Project Structure

selftune/
├── apps/
│   ├── cli/                  # Command composition root; owns argument routing
│   ├── local/                # Process composition, Effect operations, HTTP routes, and OS service host
│   ├── local-dashboard/      # Shared React/Vite dashboard client
│   ├── desktop/              # Scoped Effect supervisor plus Electron window, tray, updater, and IPC adapters
│   ├── use-once-helper/      # Separate signed ephemeral shared-skill runner; never installs SelfTune
│   └── selfhost/             # One-container dashboard and Remote Library host
├── packages/
│   ├── api-contract/          # Shared typed HTTP contracts used by optional Cloud handoffs
│   ├── config/               # Persisted config schemas, path resolution, loading, and atomic writes
│   ├── runtime/              # Local filesystem, SQLite/Drizzle, and host adapters
│   ├── library/              # Catalog, Skill Sets, and Remote Library protocol core
│   ├── local-store/          # Effect-managed SQLite lifecycle, Drizzle schema, and migrations
│   ├── observability/        # Effect-owned DuckDB trace analytics and derived signal queries
│   ├── skill-intelligence/   # Pure classification, pattern discovery, validation, and outcomes
│   ├── source-management/    # Source identity, update contracts, and sync service
│   ├── orchestration/        # Setup convergence/onboarding plus sync, improve, run, and scheduling workflows
│   ├── harnesses/
│   │   ├── core/             # Harness-neutral hook protocol, source-adapter contract, and stdin/session utilities
│   │   ├── registry/         # Split descriptor/source registries for all shipped harnesses
│   │   ├── claude-code/      # Claude Code hooks and transcript ingestion
│   │   ├── codex/            # Codex hooks, installer, rollout ingestion, and wrapper
│   │   ├── opencode/         # OpenCode hooks, installer, and ingestion
│   │   ├── cline/            # Cline hooks and installer
│   │   ├── pi/               # Pi hooks, installer, and ingestion
│   │   └── openclaw/         # OpenClaw ingestion and cron adapter
│   ├── control-plane/        # Effect services, domain contracts, programs, and Layers
│   ├── dashboard-core/       # Host-neutral dashboard shell and route contracts
│   ├── telemetry-contract/   # Canonical telemetry contract
│   └── ui/                   # Shared UI primitives and components
├── cli/selftune/             # Backward-compatible CLI and hook shims only
├── bin/selftune.cjs          # npm binary shim into apps/cli
├── skill/                    # Agent-facing routing table, workflows, and references
├── tests/                    # Cross-package behavior and release tests
└── scripts/                  # Release, packaging, and validation tooling

The root selftune package remains the publishable npm compatibility facade. New command implementation belongs in apps/cli; local host behavior belongs in apps/local; reusable behavior belongs in a package. Do not add implementation modules under cli/selftune.

Architecture

See ARCHITECTURE.md for domain map, module layering, and dependency rules.

Documentation Map

TopicLocationStatus
System Overviewdocs/design-docs/system-overview.mdCurrent
Operator Guidedocs/operator-guide.mdCurrent
ArchitectureARCHITECTURE.mdCurrent
Product RequirementsPRD.mdCurrent
Skill Definitionskill/SKILL.mdCurrent
Design Docsdocs/design-docs/index.mdCurrent
Core Beliefsdocs/design-docs/core-beliefs.mdCurrent
Live Dashboard SSEdocs/design-docs/live-dashboard-sse.mdCurrent
SQLite-First Migrationdocs/design-docs/sqlite-first-migration.mdCurrent
Agent CLI Contractdocs/design-docs/agent-cli-contract.mdCurrent
Product Specsdocs/product-specs/index.mdCurrent
Active Plans (~4 epics)docs/exec-plans/active/Current
Completed Plansdocs/exec-plans/completed/Current
Deferred Plansdocs/exec-plans/deferred/Current
Technical Debtdocs/exec-plans/tech-debt-tracker.mdCurrent
Risk Policyrisk-policy.jsonCurrent
Golden Principlesdocs/golden-principles.mdCurrent
Escalation Policydocs/escalation-policy.mdCurrent
Referencesskill/references/Current
Launch Playbookdocs/launch-playbook-tracker.mdCurrent
Security PolicySECURITY.mdCurrent
Contributing GuideCONTRIBUTING.mdCurrent
Code of ConductCODE_OF_CONDUCT.mdCurrent
LicenseLICENSECurrent

Change Propagation Map

When changing one part of selftune, check if dependent files need updating. This prevents stale docs and broken contracts.

If you change...Also update...
CLI commands in apps/cli/src/main.ts (add/rename/remove)skill/SKILL.md Quick Reference + Workflow Routing table, README.md Commands table, AGENTS.md project tree
CLI flags on any commandThe command's skill/workflows/*.md doc (flags table + examples)
Persisted config schema or path policypackages/config/, runtime/local-store compatibility exports, ARCHITECTURE.md ownership and dependency rules
JSONL log schema or new log filepackages/runtime/constants.ts, packages/runtime/types.ts, skill/references/logs.md, local DB writers/queries, ARCHITECTURE.md data architecture
Dashboard contract (packages/runtime/dashboard-contract.ts)apps/local-dashboard/src/types.ts, dashboard components that consume the changed fields
Hook or adapter behavior (packages/harnesses/**)skill/workflows/Initialize.md hook table, skill/settings_snippet.json, skill/workflows/PlatformHooks.md
Orchestration behavior (packages/orchestration/**)Relevant skill/workflows/*.md (for example Initialize or Orchestrate), plus ARCHITECTURE.md operating modes
Agent files (skill/agents/*.md)skill/SKILL.md Specialized Agents table
New workflow fileskill/SKILL.md Workflow Routing table + Resource Index
Evolution pipeline changesskill/workflows/Evolve.md, docs/design-docs/evolution-pipeline.md
Platform adapter (ingestor) changesskill/workflows/Ingest.md, README.md Platforms section
CLI error handling (packages/runtime/utils/cli-error.ts)docs/design-docs/agent-cli-contract.md error codes table, all CLI entry points that import CLIError
Repo org/name changeREADME.md badges + install, llms.txt, SECURITY.md, CONTRIBUTING.md, contribute.ts repo constant, package.json (homepage/repo/bugs)

Mandatory Rules (If/Then)

These rules are non-negotiable. Before performing the action in the "If" column, you MUST complete the "Then" action first.

If you are about to...Then FIRST...
Add, rename, or remove a CLI command in index.tsUpdate skill/SKILL.md Quick Reference and Workflow Routing table
Modify CLI flags on any commandUpdate that command's skill/workflows/*.md doc (flags table + examples)
Edit hook behavior in hooks/*.ts, hooks-shared/*, or adapters/*/hook.tsUpdate skill/workflows/Initialize.md, skill/settings_snippet.json, and skill/workflows/PlatformHooks.md
Change dashboard-contract.ts fieldsUpdate apps/local-dashboard/src/types.ts and consuming dashboard components
Add a new file to evolution/Update ARCHITECTURE.md domain map and module definitions table
Modify the evolution pipeline (evolution/*.ts)Update skill/workflows/Evolve.md
Change error handling patterns (utils/cli-error.ts)Update docs/design-docs/agent-cli-contract.md error codes table
Create a new workflow file in skill/workflows/Add routing entry in skill/SKILL.md Workflow Routing table + Resource Index
Edit orchestrate.ts behaviorUpdate skill/workflows/Orchestrate.md
Commit any changesRun bunx oxlint and bunx oxfmt --check on changed files

Development Workflow

Commit attribution

  • Agent-authored commits must use Daniel's verified GitHub identity: Daniel Petro <45949032+WellDunDun@users.noreply.github.com>.
  • Keep one logical change per commit and use squash merge so the reviewed pull request becomes one attributable source-history event.
  • Add Co-authored-by trailers only for people who materially contributed to the change. Automation must not claim authorship for generated release metadata.
  • Changesets describe release intent. The publish workflow derives the next tag from changesets added since the previous stable tag; it must not create a Version Packages pull request or commit generated version files.
  1. Receive task via prompt
  2. Read this file, then follow pointers to relevant docs
  3. Read PRD.md for product context and the feedback loop model
  4. Implement changes following ARCHITECTURE.md layer rules
  5. Check the Change Propagation Map above — update dependent docs before committing
  6. Run sandbox harness: bun run tests/sandbox/run-sandbox.ts
  7. Run make check (lint + test) or bun test
  8. Verify JSONL output schema matches appendix in PRD.md
  9. Self-review: check log schema compatibility across all platforms
  10. Open PR with concise summary

Key Constraints

  • selftune is agent-first: users interact through their coding agent, not the CLI directly. SKILL.md and workflow docs are the product surface; the CLI is the agent's API.
  • Claude Code is the primary supported platform; Codex, OpenCode, OpenClaw, and Pi adapters are experimental (they exist but are not actively tested). All five write to the same shared log schema
  • Source-truth transcripts/rollouts are authoritative; hooks are low-latency hints, not the canonical record
  • Grading uses the user's existing agent subscription — no separate API key
  • Hooks should be zero-config after installation where the host agent supports them
  • SQLite is the sole operational/product write target. DuckDB is the separate rebuildable observability-analytics store for trace facts, metrics, and cross-trace aggregation; it never owns product lifecycle state. Legacy SelfTune JSONL files on disk are pre-cutover history only, while source-native transcripts, rollouts, and session stores remain authoritative import sources (see docs/design-docs/sqlite-first-migration.md).
  • Evolution proposals require validation against eval set before deploy
  • selftune orchestrate is the primary autonomous loop; selftune cron setup installs OS-level scheduling (selftune schedule is a backward-compatible alias)
  • bun run dev atomically claims a stable worktree-specific port block for the watched dashboard runtime and Vite; use dev:status, dev:open, and conservative dev:reap rather than assuming fixed ports
  • All knowledge lives in-repo, not in external tools
  • packages/config is the canonical owner of persisted config schemas, environment-derived paths, loading, and atomic writes. Runtime and local-store may re-export stable compatibility names but must not redefine that policy.
  • Keep runtime dependencies explicit and owned at the narrowest package boundary. The local database uses drizzle-orm; process and resource lifecycles use Effect; platform I/O should still prefer Bun and Node built-ins.
  • @selftune/telemetry-contract uses workspace:* in the repo; prepack rewrites to file: at publish time. Do NOT hardcode file: (causes bun lockfile duplicates) or remove the prepack/postpack scripts (breaks registry installs). A CI test (tests/trust-floor/publish-deps.test.ts) enforces the full pipeline.

Golden Principles

See docs/golden-principles.md for the full set of mechanical taste rules.

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.