agentleFS
neilberkmanneilberkman/ccrider/AGENTS.md

ccrider

AGENTS.md137 starsChanged 14 days agoMITView on GitHub

This codebase follows strict Core/Interface separation based on Saša Jurić's "Towards Maintainable Elixir: The Core and the Interface". The core contains business logic that applies REGARDLESS of which interface uses it: Test: "Would this be different for CLI vs TUI vs MCP?" Interfaces translate between protocols and core: This logic must be in core - it's a business rule that applies to ALL interfaces. Move to core. Interface should call db.ListSessions(projectFilter). If date filtering is a business requirement (applies to…

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. james-norm/ccrider★ 0100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • 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

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

8 rules. About 0 are common, 8 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Data Retrieval: All database queries, FTS searches, external API calls

    line 11
  2. Distinctive:

    No SQL queries: - All database access through core functions

    line 53
  3. Distinctive:

    No business logic: - Don't decide what's "valid" or "meaningful"

    line 54
  4. Distinctive:

    No direct database imports: - Use core types and functions

    line 56
  5. Distinctive:

    If date filtering is a business requirement (applies to all interfaces), move to core.

    line 99
  6. Distinctive:

    If it's MCP-specific (other interfaces don't need it), it can stay but only if clearly protocol-specific.

    line 100
  7. Distinctive:

    Before adding logic to interface layer, ask:

    line 128
  8. Distinctive:

    When to truncate (pagination limits)

    line 180

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

Core/Interface Separation Philosophy

This codebase follows strict Core/Interface separation based on Saša Jurić's "Towards Maintainable Elixir: The Core and the Interface".

Principles

CORE Layer (internal/core/)

The core contains business logic that applies REGARDLESS of which interface uses it:

  1. Data Retrieval: All database queries, FTS searches, external API calls
  2. Business Rules: Filtering out warmup sessions, summary fallback logic, validation
  3. Data Transformation: Converting raw database rows into domain types
  4. Domain Types: Structs that represent business concepts (Session, SessionDetail, SearchResult, Stats)
  5. Pure Business Operations: Logic that would be identical whether you have CLI, TUI, MCP, or web API

Test: "Would this be different for CLI vs TUI vs MCP?"

  • NO → Core
  • YES → Interface

Examples:

  • ✅ CORE: "Get all sessions, excluding those with no meaningful content"
  • ✅ CORE: "Search messages using FTS5"
  • ✅ CORE: "Calculate last working directory from message history"
  • ❌ NOT CORE: "Show 20 sessions" (that's pagination - interface concern)
  • ❌ NOT CORE: "Format timestamp as 'Jan 2, 2006'" (that's presentation - interface concern)

INTERFACE Layer (internal/interface/, cmd/ccrider/mcp/)

Interfaces translate between protocols and core:

  1. Protocol Translation: HTTP, CLI flags, MCP JSON, TUI key bindings
  2. Input Normalization: Parse project:foo after:yesterday into filter structs
  3. Output Formatting: Convert time.Time to "Jan 2" or RFC3339 or "2 hours ago"
  4. Pagination/Limits: Decide to show 20 vs 50 vs 10 results
  5. Presentation: Colors, tables, progress bars, JSON structure
  6. Grouping: "Show 3 matches per session" (core returns ALL matches)

Examples:

  • ✅ INTERFACE: Strip quotes from user's search query
  • ✅ INTERFACE: Apply limit of 50 sessions to display
  • ✅ INTERFACE: Group search results by session for display
  • ✅ INTERFACE: Format date as "2 days ago" for terminal
  • ✅ INTERFACE: Parse after:2024-01-01 from search string

Rules

❌ NEVER in Interface Layers:

  1. No SQL queries - All database access through core functions
  2. No business logic - Don't decide what's "valid" or "meaningful"
  3. No filtering by business rules - Core decides if warmup sessions are excluded
  4. No direct database imports - Use core types and functions

✅ DO in Interface Layers:

  1. Call core functions - db.ListSessions(), search.Search()
  2. Transform for display - Format dates, truncate text, add colors
  3. Apply presentation limits - Pagination, "show 3 matches per session"
  4. Parse user input - Convert CLI flags/TUI keys/MCP params into core function calls
  5. Handle protocol concerns - JSON marshaling, terminal rendering, progress bars

Common Violations to Avoid

🚨 Filtering in Interface

// ❌ WRONG - business logic in interface
for _, session := range sessions {
    if session.Summary != "" && !strings.Contains(session.Summary, "warmup") {
        // Only show non-warmup sessions
    }
}

This logic must be in core - it's a business rule that applies to ALL interfaces.

🚨 Database Queries in Interface

// ❌ WRONG - SQL in interface layer
rows, err := database.Query("SELECT * FROM sessions WHERE project_path LIKE ?", filter)

Move to core. Interface should call db.ListSessions(projectFilter).

🚨 Date Filtering in Interface

// ❌ WRONG - business logic about date ranges
if args.AfterDate != "" && coreResult.Timestamp < args.AfterDate {
    continue
}

If date filtering is a business requirement (applies to all interfaces), move to core. If it's MCP-specific (other interfaces don't need it), it can stay but only if clearly protocol-specific.

✅ Correct Separation

// ✅ CORE - business logic
func (db *DB) ListSessions(projectPath string) ([]Session, error) {
    // SQL query with business rules:
    // - Exclude sessions with no meaningful content
    // - Fallback summary to first user message
    // - Order by updated_at DESC
}

// ✅ INTERFACE - presentation
func runList(cmd *cobra.Command, args []string) error {
    sessions, err := database.ListSessions(projectFilter) // Call core
    if len(sessions) > listLimit {
        sessions = sessions[:listLimit] // Apply display limit
    }
    for _, s := range sessions {
        fmt.Printf("[%d] %s\n", i, s.SessionID)
        fmt.Printf("    Updated: %s\n", formatTimestamp(s.UpdatedAt)) // Format for display
    }
}

When Working on Code

Before adding logic to interface layer, ask:

  1. "Would CLI and TUI and MCP all need this same logic?"

    • YES → Move to core
    • NO → Keep in interface
  2. "Is this about WHAT data to get or HOW to display it?"

    • WHAT → Core
    • HOW → Interface
  3. "Does this involve a database query or business rule?"
    • YES → Core
    • NO → Probably interface

File Organization

internal/core/
├── db/           # Database operations, domain types
│   ├── db.go     # Connection, base types
│   ├── sessions.go  # Session queries: ListSessions, GetSessionDetail, GetSessionLaunchInfo
│   └── stats.go     # Stats queries: GetStats
└── search/       # Search operations
    └── search.go # FTS5 search: Search, SearchCode

internal/interface/
├── cli/          # Command-line interface
│   ├── list.go   # Calls db.ListSessions(), formats as table
│   ├── stats.go  # Calls db.GetStats(), formats as table
│   └── debug_prompt.go  # Calls db.GetSessionLaunchInfo(), formats prompt
└── tui/          # Terminal UI
    └── messages.go  # Calls search.Search(), formats as colored list

cmd/ccrider/mcp/
└── server.go     # MCP server
    # Calls search.Search(), db.GetSessionDetail(), db.ListSessions()
    # Formats as JSON for MCP protocol

Summary

Core = What and Why

  • What data to retrieve
  • Why certain sessions are excluded
  • What constitutes "valid" data

Interface = How and When

  • How to display data (colors, format, structure)
  • When to truncate (pagination limits)
  • How user specifies what they want (CLI flags, TUI keys, MCP params)

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.