agentleFS
topoteretestopoteretes/cognee/AGENTS.md

cognee

AGENTS.md31k starsChanged 2 months agoApache-2.0View on GitHub

This document summarizes how to work with the cognee repository: how it’s organized, how to build, test, lint, and contribute. It mirrors our actual tooling and CI while providing quick commands for local development. Notes: - Co-locate feature-specific helpers under their respective package (modules/, infrastructure/, or tasks/). - Extend the system by adding new tasks, loaders, or retrievers rather than modifying core pipeline mechanisms. Python (root) – requires Python >= 3.10 and < 3.15 (i.e. 3.10–3.14, see pyproject.toml). We recommend…

  • Reads credentials
  • Installs packages

Adopted by

Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data

Week of Sep 27: 0 new projectsWeek of Oct 4: 0 new projectsWeek of Oct 11: 0 new projectsWeek of Oct 18: 0 new projectsWeek of Oct 25: 0 new projectsWeek of Nov 1: 0 new projectsWeek of Nov 8: 0 new projectsWeek of Nov 15: 0 new projects
Sep 2026Oct 2026Nov 2026
New projects taking a version of this file each week, over the 8 weeks our latest run read: only 0 in all, so this is a hint, not a trend.

Who's talking about topoteretes/cognee

The biggest 5 of 70 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 70

Talked about on GitHub, Bluesky and Hacker News (70 times).

On GitHub · 50

45 more on GitHub

On Bluesky · 15

10 more on Bluesky

The file

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

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create/refresh env and install dev deps:

    line 34
  2. Very specific:

    Run the CLI (examples). The memory commands are the primary surface.

    line 39
  3. Distinctive:

    Start the FastAPI server directly:

    line 49
  4. Distinctive:

    Run tests (CI mirrors these commands):

    line 54
  5. Very specific:

    Use ruff format before committing.

    line 151
  6. Very specific:

    Prefer explicit, structured error handling.

    line 152
  7. Very specific:

    Follow the local README.md and ESLint/TypeScript configuration in cognee-frontend/.

    line 155
  8. Very specific:

    Place Python tests under cognee/tests/.

    line 159
  9. Very specific:

    Avoid external state; rely on test fixtures and the CI-provided env vars when LLM/embedding providers are required.

    line 164
  10. Very specific:

    When adding public APIs, provide/update a targeted example under examples/guides/ and list it in examples/README.md (see its "Contributing …

    line 165
  11. Very specific:

    Use clear, imperative subjects (≤ 72 chars) and conventional commit styling in PR titles.

    line 169

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

Repository Guidelines

This document summarizes how to work with the cognee repository: how it’s organized, how to build, test, lint, and contribute. It mirrors our actual tooling and CI while providing quick commands for local development.

Project Structure & Module Organization

  • cognee/: Core Python library and API.
    • api/: FastAPI application and versioned routers under api/v1/ — memory API (remember, recall, improve, forget), low-level operations (add, cognify, memify, search, delete, update), and supporting routers (datasets, users, permissions, settings, sync, visualize, health, skills, sessions, …). Each router package has a routers/ folder; api/client.py registers them.
    • cli/: CLI entry points and subcommands invoked via cognee / cognee-cli.
    • infrastructure/: Databases, LLM providers, embeddings, loaders, and storage adapters.
    • modules/: Domain logic (graph, retrieval, ontology, users, processing, observability, etc.).
    • tasks/: Reusable tasks (e.g., code graph, web scraping, storage). Extend with new tasks here.
    • eval_framework/: Evaluation utilities and adapters.
    • shared/: Cross-cutting helpers (logging, settings, utils).
    • tests/: Unit, integration, CLI, and end-to-end tests organized by feature.
    • __main__.py: Entrypoint to route to CLI.
  • cognee-mcp/: Model Context Protocol server exposing cognee as MCP tools (SSE/HTTP/stdio). Contains its own README and Dockerfile.
  • cognee-frontend/: Next.js UI for local development and demos.
  • distributed/deploy/: One-click deployment templates (Modal, Fly.io, Railway, Render, Daytona).
  • examples/: Example scripts demonstrating the public APIs and features (graph, code graph, multimodal, permissions, etc.).
  • notebooks/: Jupyter notebooks for demos and tutorials.
  • .agents/skills/: Task-specific agent skills. This is the only copy; add and edit skills here (Codex reads this folder directly).
  • .claude/skills/: Symlink to ../.agents/skills so Claude Code finds the same skills. On Windows clones without symlink support, the SessionStart hook in .claude/settings.json (.claude/hooks/link-skills.sh) replaces it with a directory junction automatically; no manual step is needed. That hook marks the path skip-worktree, so on those clones only, a later change to the .claude/skills entry itself makes git refuse to update it — run git update-index --no-skip-worktree .claude/skills && git checkout -- .claude/skills, then start a new session.
  • cognee/alembic/: Relational (Alembic) schema migrations; alembic.ini is in cognee/. Graph/vector data migrations live in cognee/modules/migrations/.

Notes:

  • Co-locate feature-specific helpers under their respective package (modules/, infrastructure/, or tasks/).
  • Extend the system by adding new tasks, loaders, or retrievers rather than modifying core pipeline mechanisms.

Build, Test, and Development Commands

Python (root) – requires Python >= 3.10 and < 3.15 (i.e. 3.10–3.14, see pyproject.toml). We recommend uv for speed and reproducibility.

  • Create/refresh env and install dev deps:
uv sync --dev --all-extras --reinstall
  • Run the CLI (examples). The memory commands are the primary surface; add/cognify/search are the low-level stages they call underneath:
uv run cognee-cli remember "Cognee turns documents into AI memory."   # add + cognify (+ improve)
uv run cognee-cli recall "What does cognee do?"
uv run cognee-cli improve -d main_dataset   # enrich / index the graph
uv run cognee-cli forget --all              # NOTE: no confirmation prompt
uv run cognee-cli add "..." && uv run cognee-cli cognify && uv run cognee-cli search "..."   # low level
uv run cognee-cli -ui   # Launches UI, backend API, and MCP server together
  • Start the FastAPI server directly:
uv run python -m cognee.api.client
  • Run tests (CI mirrors these commands):
uv run pytest cognee/tests/unit/ -v
uv run pytest cognee/tests/integration/ -v
  • Lint and format (ruff):
uv run ruff check .
uv run ruff format .
  • Optional static type checks (ty):
uv run ty check .

MCP Server (cognee-mcp/):

  • Install and run locally:
cd cognee-mcp
uv sync --dev --all-extras --reinstall
uv run python src/server.py               # stdio (default)
uv run python src/server.py --transport sse
uv run python src/server.py --transport http --host 127.0.0.1 --port 8000 --path /mcp
  • API Mode (connect to a running Cognee API):
uv run python src/server.py --transport sse --api-url http://localhost:8000 --api-token YOUR_TOKEN
  • Docker quickstart (examples): see cognee-mcp/README.md for full details
docker run -e TRANSPORT_MODE=http --env-file ./.env -p 8000:8000 --rm -it cognee/cognee-mcp:main

Frontend (cognee-frontend/):

cd cognee-frontend
npm install
npm run dev     # Next.js dev server
npm run lint    # ESLint
npm run build && npm start

Runtime Flags Worth Knowing

Three env flags trade memory features for speed; know what each disables before flipping it:

  • CACHING (default true) — master switch for the session-memory layer. When false, remember(session_id=...) raises, recall() loses session history, agent_memory session options error out, and AUTO_FEEDBACK is implicitly disabled. Never benchmark cognee with this off — that measures cognee with its memory layer removed.
  • AUTO_FEEDBACK (default true) — one structured-output LLM call per answered turn that detects implicit feedback and lets memory self-tune. Disable for low-latency, lower-cost reads; session store/recall itself keeps working.
  • DATASET_QUEUE_ENABLED (default true) — per-process cap on concurrent datasets (DATASET_QUEUE_MAX_CONCURRENT, default 6); also tears down subprocess DB engines on scope exit and pins in-use engines against cache eviction. Only engages when ENABLE_BACKEND_ACCESS_CONTROL is on (its default) — with access control off the flag is a no-op, so flipping it cannot affect performance there. Disable only for single-dataset scripts — under parallel multi-dataset load, turning it off risks file-lock leaks and unbounded embedded engines.

Multi-Tenancy Support by Backend

With ENABLE_BACKEND_ACCESS_CONTROL=true (the default) each user+dataset gets isolated graph and vector databases. Backend support (source of truth: cognee/infrastructure/databases/dataset_database_handler/supported_dataset_database_handlers.py):

  • Graph — supported: Ladybug/Kuzu (default), Neo4j (needs multi-database, i.e. Enterprise/Aura), Postgres (demo), Turso. Unsupported: Neptune, ladybug-remote.
  • Vector — supported: LanceDB (default), PGVector, Turso. Unsupported: Neptune Analytics and community adapters (unless they register a handler via use_dataset_database_handler()).
  • Relational (SQLite/Postgres) is always a single shared DB (users, ACLs, registry).

Each provider has a default handler derived from it, so no handler setting is needed normally. Setting GRAPH_DATASET_DATABASE_HANDLER / VECTOR_DATASET_DATABASE_HANDLER explicitly is never overwritten by that derivation, and is how you select the alternates: neo4j_community (one Docker container per dataset, for Community edition, which serves one database per server), neo4j_aura_dev (one Aura instance per dataset; dev/PoC only), postgres_graph_shared and pgvector_shared (a schema per dataset in cognee's main Postgres database, so no CREATE DATABASE privilege is needed). Each requires its matching provider. See CLAUDE.md for the full matrix.

Both graph and vector must be supported, or cognee raises EnvironmentError — an unsupported backend with the flag on is a hard error, not a fallback to shared DBs; set ENABLE_BACKEND_ACCESS_CONTROL=false to run such backends single-tenant.

Coding Style & Naming Conventions

Python:

  • 4-space indentation, modules and functions in snake_case, classes in PascalCase.
  • Public APIs should be type-annotated where practical. Make sure type defined in API signature will be properly displayed in Swagger UI docs. For example this definition: content_type: Optional[str] = Form(default=None) maps to "string" as the default in Swagger docs for content_type, but it should be None/null instead.
  • Use ruff format before committing; ruff check enforces import hygiene and style (line-length 100 configured in pyproject.toml).
  • Prefer explicit, structured error handling. Use shared logging utilities in cognee.shared.logging_utils.

MCP server and Frontend:

  • Follow the local README.md and ESLint/TypeScript configuration in cognee-frontend/.

Testing Guidelines

  • Place Python tests under cognee/tests/.
    • Unit tests: cognee/tests/unit/
    • Integration tests: cognee/tests/integration/
    • CLI tests: cognee/tests/cli_tests/
  • Name test files test_*.py. Use pytest.mark.asyncio for async tests.
  • Avoid external state; rely on test fixtures and the CI-provided env vars when LLM/embedding providers are required. See CI workflows under .github/workflows/ for expected environment variables.
  • When adding public APIs, provide/update a targeted example under examples/guides/ and list it in examples/README.md (see its "Contributing a new example" section).

Commit & Pull Request Guidelines

  • Use clear, imperative subjects (≤ 72 chars) and conventional commit styling in PR titles. Our CI validates semantic PR titles (see .github/workflows/pr_lint). Examples:
    • feat(graph): add temporal edge weighting
    • fix(api): handle missing auth cookie
    • docs: update installation instructions
  • Reference related issues/discussions in the PR body and provide brief context.
  • PRs should describe scope, list local test commands run, and mention any impacts on MCP server or UI if applicable.
  • Sign commits and affirm the DCO (see CONTRIBUTING.md).

CI Mirrors Local Commands

Our GitHub Actions run the same ruff checks and pytest suites shown above (.github/workflows/basic_tests.yml and related workflows). Use the commands in this document locally to minimize CI surprises.

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.