agentleFS
BlockKnown publisherblock/coplan/AGENTS.md

coplan

AGENTS.md46 starsChanged 7 days agoApache-2.0View on GitHub

Use Coplan in product copy and documentation and Coplan:: as the Ruby namespace. A Rails app for engineering design doc review, purpose-built for AI-assisted planning. Plans get better through collaboration — domain experts leave inline feedback, AI agents respond to that feedback and apply edits automatically, and every change is versioned with full provenance. Humans comment, AI agents edit. Local agents interact via the REST API using skills (see coplan skill) and future CLIs. Most of the application logic lives…

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 35,337 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 repositoryOne other file it gives its agents.

The file

Show its rules and text

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

28 rules. About 0 are common, 11 are distinctive, and 17 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 17

    Very specific

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

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

    Use Coplan in product copy and documentation and Coplan:: as the Ruby namespace.

    line 3
  2. Very specific:

    All tables use UUID primary keys (id: :string, limit: 36), assigned in ApplicationRecord#assign_uuid

    line 45
  3. Very specific:

    All multi-tenant tables include organization_id (FK, not null)

    line 46
  4. Very specific:

    No PG-only types (citext, text[], ON CONFLICT ...

    line 49
  5. Very specific:

    Use inclusion: validations against those constants

    line 55
  6. Very specific:

    Use after_initialize for defaults on JSON array columns (e.g., self.tags ||= [])

    line 56
  7. Distinctive:

    No npm packages — everything through importmaps or inline

    line 64
  8. Distinctive:

    Keep it simple: no React, no Vue, no component libraries

    line 66
  9. Distinctive:

    If an interaction scrolls, flashes, reflows, or stalls in a way a native app wouldn't, treat it as a bug — regardless of how idiomatic the …

    line 89
  10. Distinctive:

    Follow the design guidance across document, rich preview, expanded table/diagram, and editing surfaces:

    line 96
  11. Distinctive:

    Never imply an exact item anchor when only a whole-diagram anchor is available.

    line 105
  12. Distinctive:

    Orange means attention: use it only for a task the current viewer must complete or new material they need to review.

    line 106
  13. Very specific:

    Run the full suite: bundle exec rspec

    line 120
  14. Very specific:

    Use FactoryBot (factory_bot_rails) — factories live in spec/factories/

    line 122
  15. Distinctive:

    Every model, service object, and controller action should have specs

    line 123
  16. Distinctive:

    When an agent builds a feature or fixes a bug in a local checkout, finish with a way for the person who requested it to try the changed …

    line 131
  17. Distinctive:

    Run the relevant automated specs.

    line 134
  18. Very specific:

    Start the development server (bin/dev.

    line 139
  19. Very specific:

    Use the shared demo library: bin/rails coplan:demo:seed (or bin/rails db:seed in this host).

    line 162
  20. Very specific:

    Default example-host login: hampton@example.com, no password.

    line 163
  21. Very specific:

    Start with the content galleries in the demo index: diagram variants, single/multiple/mixed decks, table cells, rich text, references, and …

    line 165
  22. Very specific:

    Read docs/DEMO_LIBRARY.md for scenario coverage and database isolation.

    line 166
  23. Very specific:

    Before setting up a separate worktree, select dedicated development and test databases with DATABASE_URL.

    line 167
  24. Very specific:

    Update guides/api.text.erb when you add, remove, or change an endpoint.

    line 176
  25. Distinctive:

    Remove anything that stops being true.

    line 177
  26. Distinctive:

    Write in plain, short sentences, like the existing guides.

    line 178
  27. Very specific:

    Run the code-review skill before considering a session complete

    line 183
  28. Very specific:

    Every thread starts open, regardless of who created it

    line 205

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

Coplan — Agent Guidelines

Use Coplan in product copy and documentation and Coplan:: as the Ruby namespace.

What This Is

A Rails app for engineering design doc review, purpose-built for AI-assisted planning. Plans get better through collaboration — domain experts leave inline feedback, AI agents respond to that feedback and apply edits automatically, and every change is versioned with full provenance. Humans comment, AI agents edit. Local agents interact via the REST API using skills (see coplan skill) and future CLIs.

Architecture: Engine vs Host App

Most of the application logic lives in the Coplan Rails engine (engine/), packaged as the coplan gem (path-based, in Gemfile). The top-level Rails app is a thin host that provides deployment configuration, ActiveAdmin, and app-specific glue.

Engine (engine/) — where the code lives

  • Models — all domain models live in engine/app/models/coplan/ (Plan, PlanVersion, User, Comment, CommentThread, EditLease, EditSession, ApiToken, PlanCollaborator)
  • Controllers — web UI and API controllers in engine/app/controllers/coplan/, including api/v1/ for the REST API
  • Services — all service objects in engine/app/services/coplan/ (Plans::Create, Plans::ApplyOperations, AI providers, etc.)
  • Policies — authorization policies in engine/app/policies/coplan/
  • Jobs — background jobs in engine/app/jobs/coplan/
  • Views, helpers, assets, JS — all Hotwire views and Stimulus controllers
  • Migrations — engine-owned tables go in engine/db/migrate/. Data/backfill migrations supporting engine behavior also belong here (the gem only packages engine/, so host-only migrations don't reach gem consumers); copy them into the host with bin/rails coplan:install:migrations.
  • Routes — engine routes in engine/config/routes.rb, mounted by the host

Host app (top-level) — thin deployment shell

  • ActiveAdmin — optional host setup calls Coplan::Admin.install!; Coplan model registrations live in engine/app/admin/, while host-specific pages can live in the host's app/admin/
  • Auth — SessionsController, User model (legacy, being migrated to Coplan::User)
  • App-specific integrations — SlackClient, SlackNotificationJob
  • Migrations — this app is just the example/demo host, so db/migrate/ mostly holds the *.coplan.rb copies of engine migrations (the engine owns schema for coplan_* tables)
  • Config — database, deployment, environment, seeds

When adding new features, put them in the engine unless they are deployment- or host-specific (host admin extensions, external integrations, auth).

Tech Stack & Philosophy

  • Rails with importmaps — no Node, no bundler, no Webpack, no esbuild
  • Hotwire — Turbo Drive, Turbo Frames, Turbo Streams, Stimulus
  • Plain CSS — no Tailwind, no preprocessors
  • Plain JavaScript — via importmaps and Stimulus controllers only
  • MySQL 8 — but schema must stay portable: hosts may run PostgreSQL, so no adapter-specific column options or SQL outside an adapter check (search is the worked example — see Plan.adapter_search and the AddSearchToCoplanPlans migration); no default: on JSON columns (use after_initialize in the model instead)
  • SolidQueue for background jobs, SolidCable for ActionCable
  • ActiveAdmin 4 beta + activeadmin_assets for admin UI — no node/tailwind needed
  • No Devise, no OmniAuth — auth is hand-rolled (stub OIDC in dev, real OIDC later)

Database Conventions

  • All tables use UUID primary keys (id: :string, limit: 36), assigned in ApplicationRecord#assign_uuid
  • All multi-tenant tables include organization_id (FK, not null)
  • Enums are stored as strings (not integers) — validated with constants and inclusion: validators
  • JSON columns for arrays/hashes (tags, metadata, trigger_statuses, allowed_email_domains)
  • No PG-only types (citext, text[], ON CONFLICT ... WHERE) — use Rails validations and json columns
  • Current.organization and Current.user are set per-request for scoping

Model Conventions

  • Define valid values as frozen constants on the model (e.g., Plan::STATUSES, Comment::AUTHOR_TYPES)
  • Use inclusion: validations against those constants
  • Use after_initialize for defaults on JSON array columns (e.g., self.tags ||= [])
  • Service objects live in app/services/ namespaced by model (e.g., Plans::Create)
  • Service objects use the self.call + new(...).call pattern
  • Authorization uses plain policy objects in app/policies/ — not Pundit

Frontend Conventions

  • JavaScript goes in app/javascript/controllers/ as Stimulus controllers
  • No npm packages — everything through importmaps or inline
  • Views use Turbo Frames for partial page updates, Turbo Streams for realtime broadcasts
  • Keep it simple: no React, no Vue, no component libraries

HARD REQUIREMENT: native feel, secretly HTML

The entire goal of this stack is an app that is plain HTML over the wire but feels indistinguishable from a native app. Server-rendered HTML is the implementation, never the excuse. Concretely, every interaction must meet this bar:

  • No layout jiggle between navigations. Page width and shared chrome must not shift when moving between pages (scrollbar-gutter: stable guards the scrollbar case; keep shared containers dimensionally consistent).
  • No scroll jumps or full-page reloads for in-page actions. Submitting a form, uploading a file, toggling state — the result appears in place (Turbo Streams / fetch + partial swap), with progress feedback during the wait. redirect_to + full reload for something the user did mid-page is a bug, not a fallback.
  • Immediate feedback for every action — optimistic UI, busy/progress states, pulses. Nothing may silently wait on a server round-trip.
  • Instant-feeling navigation. Real navigations use Turbo Drive with hover prefetch; anything that can be preloaded on intent (hover, spring pulses) should be.

If an interaction scrolls, flashes, reflows, or stalls in a way a native app wouldn't, treat it as a bug — regardless of how idiomatic the Rails behind it is.

  • Prefer server-rendered HTML with standard Stimulus bindings (data-controller, data-action, data-*-target) — direct addEventListener is a last resort, only when elements are created dynamically in JS and Stimulus can't bind to them (e.g., inline text highlights wrapping arbitrary DOM ranges). Even these cases should be revisited for server-side alternatives when practical.

Interaction and attention colors

Follow the design guidance across document, rich preview, expanded table/diagram, and editing surfaces:

  • Blue means interaction: subtle blue for hover, blue for keyboard focus, selection, active discussions, and comment-composer quotes, in both modes.
  • Selection supports reading first: clicking table cells or selecting text must not open a composer. Offer Comment and the C shortcut. Intentional comment actions focus the comment or reply field immediately. Diagrams browse by default; C or Comment enters a mode that highlights supported element targets. Never imply an exact item anchor when only a whole-diagram anchor is available.
  • Orange means attention: use it only for a task the current viewer must complete or new material they need to review. Hover, typing, an open panel, and an unresolved thread do not establish an attention state.
  • Opening a discussion acknowledges its unread review attention immediately; clear that orange across every representation and persist the acknowledgement. Reading does not resolve the discussion. Actual tasks remain orange until completed or explicitly acknowledged as appropriate to that task.
  • Unresolved discussions retain small muted badges after reading. Resolved discussions are hidden unless explicitly requested. Never infer unread state from status: open or introduce orange without real viewer-specific state.

Testing

  • RSpec with rspec-rails
  • Run the full suite: bundle exec rspec
  • Spec files mirror app structure: spec/models/, spec/requests/, spec/services/, spec/helpers/
  • Use FactoryBot (factory_bot_rails) — factories live in spec/factories/
  • Every model, service object, and controller action should have specs
  • UUID primary keys are auto-assigned by ApplicationRecord#assign_uuid — do not set id in factories
  • Factories derive associations from parent objects (e.g., organization { plan.organization }) to keep data consistent
  • FactoryBot syntax methods (create, build) are included globally via config.include FactoryBot::Syntax::Methods
  • sign_in_as(user) helper is defined in spec/rails_helper.rb for request specs

Human tryout for local agent work

When an agent builds a feature or fixes a bug in a local checkout, finish with a way for the person who requested it to try the changed behavior:

  • Run the relevant automated specs. Exercise UI behavior in a real browser, using a built-in browser when the agent environment provides one. For UI changes, check light and dark mode and capture screenshots or a short recording of the result. For visual bugs, include before-and-after evidence when useful.
  • Start the development server (bin/dev; use bin/setup --skip-server and bin/rails db:seed first if setup is needed), verify the page loads, and leave it running for the person's tryout when the environment supports a reachable local server. Do not replace an existing server or assume its port is free.
  • In the handoff, give the exact local URL, a short path through the feature or bug reproduction, and what the person should expect to see. Point to the screenshots or recording, then explicitly invite them to try it and report feedback. Keep the server available until they have had that chance or ask you to stop it.
  • For changes without a browser UI, provide the equivalent runnable API or command example and its expected result. If a local server or browser is unavailable, say what prevented the tryout and give the shortest setup steps the person can use instead.

This is a handoff practice for interactive agent work, not a requirement that every open source contributor run or host a server for a reviewer.

Seeds

  • db/seeds.rb must be idempotent — use find_or_create_by! or guard with count checks
  • Seeds should provide enough data to demo features from a fresh checkout
  • A feature that adds a content type, diagram variant, reference type, presentation layout, or other demoable content or workflow state must add or update a named example in the shared demo library in the same PR. Cover its initial state and re-seeding behavior in spec/lib/development_seed_spec.rb; feature work is not complete until the example is browsable from the demo index.
  • Use the shared demo library: bin/rails coplan:demo:seed (or bin/rails db:seed in this host). Do not invent a replacement dataset for each feature.
  • Default example-host login: hampton@example.com, no password. Start at /hampton/demo-library. Use alex@example.com for an approver/admin or noura@example.com for a security approver.
  • Demo definitions live in engine/lib/coplan/development_seed.rb; readable content lives in engine/db/demo/content/. The engine gem packages both. Add named scenarios and assertions in spec/lib/development_seed_spec.rb as features grow.
  • Start with the content galleries in the demo index: diagram variants, single/multiple/mixed decks, table cells, rich text, references, and every shipped plan type. Keep comment-target capability labels accurate when adding examples.
  • Read docs/DEMO_LIBRARY.md for scenario coverage and database isolation. Set COPLAN_DEMO_BASE_URL before the first seed when using a different port or engine mount path.
  • Before setting up a separate worktree, select dedicated development and test databases with DATABASE_URL. Different ports still share the default database; do not seed or reset another chat's database.
  • Re-seeding preserves existing content, titles, approvals, and discussion state. For pristine scenarios use a fresh, isolated development database; never reset a shared database without being asked.

Agent Instructions Stay Current

Agents learn Coplan only from the served instructions, not from this repo. A change that agents can observe is not done until those instructions match it. That includes API endpoints, fields, status codes and error codes, as well as comment, editing, versioning and attribution rules, Markdown features, the live-session protocol, and engine/agent_tools/.

  • The primer is engine/app/views/coplan/agent_instructions/show.text.erb (served at /agent-instructions). Keep it to what every agent needs.
  • Topic guides are in engine/app/views/coplan/agent_instructions/guides/ (served at /agent-instructions/<guide>). Put task-specific detail there. A new guide needs an entry in AgentInstructionsController::GUIDES and a link from the primer; spec/requests/agent_instructions_spec.rb checks both.
  • Update guides/api.text.erb when you add, remove, or change an endpoint.
  • Remove anything that stops being true. Wrong instructions are worse than missing ones.
  • Write in plain, short sentences, like the existing guides. Agents follow the commands literally, so run any new command against a local server before you document it.

Code Review

  • Agents assigned to maintain PRs follow PR stewardship, including automated reviews, conflict resolution, current-head CI, and public cleanup summaries before and after Hampton's review.
  • Run the code-review skill before considering a session complete
  • Address all feedback until the review passes

ActiveAdmin

  • New models get an ActiveAdmin registration in app/admin/
  • Define ransackable_attributes and ransackable_associations on models for ActiveAdmin search

Key Domain Concepts

  • Plan statuses: brainstorm → considering → developing → live (or → abandoned)
  • Brainstorm plans are private; considering+ are published to the org
  • Editing model: humans comment, AI agents apply edits via semantic operations (replace_exact, insert_under_heading, delete_paragraph_containing)
  • Edit leases: one agent edits at a time, enforced by a lease with TTL
  • Versions are immutable — every edit creates a new PlanVersion with full provenance
  • A person's hand edit is a fence, not a merge input — agent-vs-agent staleness gets rebased through intervening versions (OT), but a human version blocks every agent write with a 409 (code: human_edit_pending) carrying the human's diff, until that credential has actually re-read the plan. Proof of reading is a PlanRead receipt, not the caller's base_revision. See Plans::HumanEditGuard.

Comment & Review UX

The comment system is central to the collaboration workflow. Domain experts leave inline feedback anchored to specific text in the plan, and the plan author triages that feedback.

Thread lifecycle

  • Every thread starts open, regardless of who created it
  • Resolve (open → resolved) is the only closing action — no accept/reject mechanics, just done or not done
  • Resolved threads can be Reopened back to open
  • Either the thread creator or the plan author can resolve/reopen (CommentThreadPolicy#resolve?/#reopen?)

Notifications follow the thread

A closed (resolved) thread carries no unread inbox rows — its highlight is hidden in the doc view, so a row pointing at it would send the reader to an apparently empty page.

  • Closing a thread sweeps its unread notifications read (CommentThread after_commit → Notifications::MarkThreadRead)
  • agent_response and status_change don't notify at all on an already-closed thread (Notifications::Create::SILENT_ON_CLOSED_THREAD); human replies and mentions still do
  • Opening a plan clears that plan's unread rows for the viewer (Notifications::MarkPlanRead) — you looked, so the nudge is done. The "you looked" signal is PlanPresenceChannel#subscribed, not the GET: workspace rows prefetch on hover, and Turbo serves the click from its prefetch cache without asking the server again. PlansController#show does it too, but skips X-Sec-Purpose: prefetch requests — which is also what keeps a hover from burning the changed-section highlights
  • The workspace "Needs attention" strip is Notifications::NeedsAttention, and each row has a ✕ that clears the same plan without opening it (NotificationsController#mark_plan_read, same service)

Inline review UI

  • Highlights: anchored text is wrapped in <mark> elements — subtle blue for open, unstyled for resolved; orange is reserved for viewer-specific attention, never thread status
  • Margin dots: colored indicators in the left margin aligned to each highlight's vertical position
  • Collapsed sections: a closed <details> hides its highlights, so it shows a compact blue count badge on its summary instead of margin dots (open threads only, unless resolved threads are shown). Every jump to a thread — ?thread=, j/k, a badge — opens the enclosing sections first (coplan/collapsed_sections.js)
  • Thread popovers: native HTML Popover API (popover="auto") showing the comment thread, reply form, and action buttons; positioned relative to the anchor and tracked on scroll
  • Comment toolbar: fixed bottom bar showing open thread count, j/k navigation, and a "Show resolved" toggle

Keyboard shortcuts

  • j / k — navigate between open threads (scrolls to highlight, opens popover)
  • r — focus the reply textarea in the current popover
  • e — resolve the current open thread
  • Enter — submit reply; Shift+Enter — newline
  • Push-to-talk (hold to dictate a comment) is a per-user setting — Ctrl+Space by default, or Shift / Option / off (Coplan::User::VOICE_HOTKEYS, voice_controller.js). A bare modifier has to be held past a delay to tell talking from typing; a chord records from the press.

How thread data flows

  • Thread data is server-rendered as hidden [data-anchor-text] elements in #plan-threads (via _thread_popover.html.erb)
  • The text_selection_controller reads that data and creates highlight marks + margin dots client-side (text range wrapping requires browser DOM APIs)
  • Status changes broadcast via Turbo Streams → Broadcaster.replace_to replaces the thread data in-place → MutationObserver on #plan-threads re-runs highlightAnchors() to update the visual state

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.