agentleFS
Larens94Larens94/codedna/integrations/CLAUDE.md

codedna / integrations

CLAUDE.md151 starsChanged 8 months agoMITView on GitHub

This project uses the CodeDNA in-source communication protocol. Follow these rules on every file operation. For LLM-powered rules: annotations: Why pipx? It creates an isolated venv per tool, so codedna's transitive dependencies (e.g. via [litellm]) don't conflict with packages already installed in your global Python environment (issue #8). uv tool install works identically. If you prefer raw pip, run it inside a project venv. The format adapts to the language. Never use Python docstrings in non-Python files. Python — module…

  • Reads credentials

The file

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

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the module header at the top of every source file before reading any code.

    line 78
  2. Very specific:

    Every new source file must begin with a CodeDNA header in the correct format for the language (see above).

    line 88
  3. Very specific:

    After editing, check used_by: targets (especially [cascade]-tagged ones).

    line 133
  4. Very specific:

    Never remove exports: symbols — they are contracts used by other files.

    line 134
  5. Very specific:

    If you discover a constraint, update rules: immediately.

    line 135
  6. Very specific:

    Append a new agent: line: after editing. Keep only the last 5 entries.

    line 136
  7. Distinctive:

    Commit with AI git trailers:

    line 164

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.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
CLAUDE.md

CodeDNA v0.9 — Protocol for Claude Code

This project uses the CodeDNA in-source communication protocol. Follow these rules on every file operation.

Annotate your project (CLI)

pipx install git+https://github.com/Larens94/codedna.git   # isolated install (avoids global env conflicts)

codedna init .           # annotates all detected languages (auto-detects PHP, TS, Go, etc.)
codedna init . --no-llm  # free — structural only, no API key needed
codedna check .          # coverage report, no changes
codedna doctor --path .  # onboarding health gate
codedna impact FILE --path .  # pre-edit impact gate
codedna verify .         # post-edit structural drift gate

For LLM-powered rules: annotations:

pipx inject codedna anthropic
export ANTHROPIC_API_KEY=sk-...
codedna init . --model claude-haiku-4-5-20251001

# Or with a local model (free, no API key):
pipx inject codedna litellm
codedna init . --model ollama/llama3

Why pipx? It creates an isolated venv per tool, so codedna's transitive dependencies (e.g. via [litellm]) don't conflict with packages already installed in your global Python environment (issue #8). uv tool install works identically. If you prefer raw pip, run it inside a project venv.


Annotation format by language

The format adapts to the language. Never use Python docstrings in non-Python files.

Python — module docstring:

"""revenue.py — Monthly revenue aggregation.

exports: monthly_revenue(year, month) -> dict
used_by: api/reports.py → revenue_route
related: billing/currency.py — shares multi-currency conversion logic
rules:   get_invoices() returns ALL tenants — MUST filter is_suspended() before sum
agent:   claude-sonnet-4-6 | anthropic | 2026-04-15 | s_001 | initial implementation
"""

PHP / TypeScript / JavaScript / Go / Java / Kotlin / Rust / C# / Swift — native line or documentation comments at file top. Ruby uses # comments. See docs/languages.md for the exact syntax:

<?php
// UserController.php — Handles user CRUD endpoints.
//
// exports: UserController::index() -> Response
//          UserController::store(Request) -> JsonResponse
// used_by: routes/web.php -> Route::resource('users', UserController::class)
// rules:   must extend App\Http\Controllers\Controller
// agent:   claude-sonnet-4-6 | anthropic | 2026-04-15 | s_001 | initial scaffold

Blade / Jinja2 / Twig / Volt — {{-- --}} or {# #} block:

{{-- layout.blade.php — Base application layout. --}}
{{--
rules:   @yield('content') is required — child views must define this section
agent:   claude-sonnet-4-6 | anthropic | 2026-04-15 | s_001 | initial layout
--}}

Reading files

  1. Read the module header at the top of every source file before reading any code.
  2. Parse exports: — symbols you must never rename or remove without explicit instruction.
  3. Parse used_by: — callers that depend on this file. Do not follow all blindly. Ask: "does this caller intersect with my current task?" Only explore relevant callers.
  4. Parse related: — files sharing the same logic without importing each other. Same filter: is it relevant to this task?
  5. Parse rules: — hard constraints; read before writing any logic.
  6. Parse agent: — session history; read to understand why the current state exists.
  7. For any function with a Rules: docstring, read and respect those before writing logic.

Writing new files

Every new source file must begin with a CodeDNA header in the correct format for the language (see above).

FieldRequiredRule
First line✅filename — <purpose ≤15 words>
exports:✅Public API with return type
used_by:✅Who calls this file's exports (structural link)
related:⬜Files sharing the same logic without importing each other (semantic link)
wiki:⬜Opt-in pointer to curated context under docs/wiki/
rules:✅Hard constraints — specific and actionable
agent:✅Rolling window of last 5 entries
message:⬜Inter-agent channel — open hypotheses

Writing good rules:

rules: must be specific and actionable — never vague.

# ✅ Good
rules:   get_invoices() returns ALL tenants — caller MUST filter is_suspended() before aggregating
rules:   amount is in cents not euros — divide by 100 before display
rules:   soft-delete via deleted_at — NEVER use DELETE, always SET deleted_at = NOW()

# ❌ Bad
rules:   handle errors gracefully
rules:   follow best practices

Writing critical functions (all programming-language adapters — L2)

Public functions must have a Rules: docstring:

def my_function(arg: type) -> return_type:
    """Short description.

    Rules:   What the agent MUST or MUST NOT do here.
    message: model-id | YYYY-MM-DD | observation for next agent
    """

Editing files

  1. First step: re-read rules:, the agent: history, and any Rules: in the function you are editing.
  2. Apply all file-level constraints before writing.
  3. After editing, check used_by: targets (especially [cascade]-tagged ones).
  4. Never remove exports: symbols — they are contracts used by other files.
  5. If you discover a constraint, update rules: immediately.
  6. Append a new agent: line after editing. Keep only the last 5 entries.

Session end protocol

Append through the canonical writer; never edit agent_sessions: manually:

codedna session append --agent <model-id> --provider <provider> \
  --session-id <s_YYYYMMDD_NNN> --task "<brief task>" \
  --changed <modified files...> --visited <read files...> \
  --message "<what the next agent should know>"

Canonical stored shape:

agent_sessions:
  - agent: <your-model-id>
    provider: <anthropic|google|openai|...>
    date: <YYYY-MM-DD>
    session_id: <s_YYYYMMDD_NNN>
    task: "<brief task description ≤15 words>"
    changed: [list, of, modified, files]
    visited: [all, files, read, during, session]
    message: >
      What you did, what you discovered, what the next agent should know.

Commit with AI git trailers:

<imperative summary>

AI-Agent:    <model-id>
AI-Provider: <provider>
AI-Session:  <session_id>
AI-Visited:  <comma-separated files read>
AI-Message:  <one-line summary>

Semantic naming (Python / Ruby)

Format: <type>_<shape>_<domain>_<origin>

list_dict_users_from_db = get_users()
int_cents_price_from_req = request.json["price"]
bool_is_admin_from_db    = user["role"] == "admin"

Full spec

→ SPEC.md

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.