agentleFS
BlockKnown publisherblock/coplan/AGENTS.md

coplan

AGENTS.md37 starsChanged 9 months agoApache-2.0View on GitHub

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 in the CoPlan Rails engine (engine/), packaged as the coplan gem (path-based, in…

  • 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,736 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

19 rules. About 0 are common, 9 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

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

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

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

    line 43
  2. Very specific:

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

    line 44
  3. Very specific:

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

    line 47
  4. Very specific:

    Use inclusion: validations against those constants

    line 53
  5. Very specific:

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

    line 54
  6. Distinctive:

    No npm packages — everything through importmaps or inline

    line 62
  7. Distinctive:

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

    line 64
  8. 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 87
  9. Distinctive:

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

    line 94
  10. Distinctive:

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

    line 103
  11. Distinctive:

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

    line 104
  12. Very specific:

    Run the full suite: bundle exec rspec

    line 118
  13. Very specific:

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

    line 120
  14. Distinctive:

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

    line 121
  15. 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 129
  16. Distinctive:

    Run the relevant automated specs.

    line 132
  17. Very specific:

    Start the development server (bin/dev.

    line 137
  18. Very specific:

    Run the code-review skill before considering a session complete

    line 162
  19. Very specific:

    Every thread starts open, regardless of who created it

    line 184

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

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 co_plan: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 *.co_plan.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 themes.
  • 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 themes 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

Code 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
  • 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.