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.
- releasing-coplanSkill
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
- Very specific: line 43
All tables use UUID primary keys (id: :string, limit: 36), assigned in ApplicationRecord#assign_uuid
- Very specific: line 44
All multi-tenant tables include organization_id (FK, not null)
- Very specific: line 47
No PG-only types (citext, text[], ON CONFLICT ...
- Very specific: line 53
Use inclusion: validations against those constants
- Very specific: line 54
Use after_initialize for defaults on JSON array columns (e.g., self.tags ||= [])
- Distinctive: line 62
No npm packages — everything through importmaps or inline
- Distinctive: line 64
Keep it simple: no React, no Vue, no component libraries
- Distinctive: line 87
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 …
- Distinctive: line 94
Follow the design guidance across document, rich preview, expanded table/diagram, and editing surfaces:
- Distinctive: line 103
Never imply an exact item anchor when only a whole-diagram anchor is available.
- Distinctive: line 104
Orange means attention: use it only for a task the current viewer must complete or new material they need to review.
- Very specific: line 118
Run the full suite: bundle exec rspec
- Very specific: line 120
Use FactoryBot (factory_bot_rails) — factories live in spec/factories/
- Distinctive: line 121
Every model, service object, and controller action should have specs
- Distinctive: line 129
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 …
- Distinctive: line 132
Run the relevant automated specs.
- Very specific: line 137
Start the development server (bin/dev.
- Very specific: line 162
Run the code-review skill before considering a session complete
- Very specific: line 184
Every thread starts open, regardless of who created it
≈ “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.
Files
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/, includingapi/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 packagesengine/, so host-only migrations don't reach gem consumers); copy them into the host withbin/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 inengine/app/admin/, while host-specific pages can live in the host'sapp/admin/ - Auth —
SessionsController,Usermodel (legacy, being migrated toCoPlan::User) - App-specific integrations —
SlackClient,SlackNotificationJob - Migrations — this app is just the example/demo host, so
db/migrate/mostly holds the*.co_plan.rbcopies of engine migrations (the engine owns schema forcoplan_*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_searchand the AddSearchToCoplanPlans migration); nodefault:on JSON columns (useafter_initializein the model instead) - SolidQueue for background jobs, SolidCable for ActionCable
- ActiveAdmin 4 beta +
activeadmin_assetsfor 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 inApplicationRecord#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 andjsoncolumns Current.organizationandCurrent.userare 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_initializefor 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(...).callpattern - 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: stableguards 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) — directaddEventListeneris 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: openor 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 inspec/factories/ - Every model, service object, and controller action should have specs
- UUID primary keys are auto-assigned by
ApplicationRecord#assign_uuid— do not setidin factories - Factories derive associations from parent objects (e.g.,
organization { plan.organization }) to keep data consistent - FactoryBot syntax methods (
create,build) are included globally viaconfig.include FactoryBot::Syntax::Methods sign_in_as(user)helper is defined inspec/rails_helper.rbfor 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; usebin/setup --skip-serverandbin/rails db:seedfirst 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.rbmust be idempotent — usefind_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-reviewskill before considering a session complete - Address all feedback until the review passes
ActiveAdmin
- New models get an ActiveAdmin registration in
app/admin/ - Define
ransackable_attributesandransackable_associationson 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
humanversion 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 aPlanReadreceipt, not the caller'sbase_revision. SeePlans::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 (
CommentThreadafter_commit→Notifications::MarkThreadRead) agent_responseandstatus_changedon'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 isPlanPresenceChannel#subscribed, not the GET: workspace rows prefetch on hover, and Turbo serves the click from its prefetch cache without asking the server again.PlansController#showdoes it too, but skipsX-Sec-Purpose: prefetchrequests — 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 foropen, unstyled forresolved; 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 popovere— resolve the current open threadEnter— submit reply;Shift+Enter— newline- Push-to-talk (hold to dictate a comment) is a per-user setting —
Ctrl+Spaceby 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_controllerreads 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_toreplaces the thread data in-place →MutationObserveron#plan-threadsre-runshighlightAnchors()to update the visual state
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.

