agentleFS
infiniflowinfiniflow/ragflow/web/AGENTS.md

ragflow / web

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

This file provides guidance to Claude Code (claude.ai/code) when working with the RAGFlow frontend (web/). RAGFlow frontend is a React/TypeScript application built with Vite: When tests are grouped in a dedicated directory, that directory is always named __tests__/ — never tests/. Example: src/pages/agent/utils/__tests__/extractor-transform.test.ts for src/pages/agent/utils/extractor-transform.ts. Co-located foo.test.ts(x) files next to the source file are also fine. When you find an existing test under a tests/ directory, move it into __tests__/ (keep git history via git mv) rather than adding new…

  • 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 infiniflow/ragflow

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

See all 101

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

On GitHub · 50

45 more on GitHub

On Bluesky · 46

41 more on Bluesky
  • 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,773 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 repository3 other files it gives its agents.

The file

Show its rules and text

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

17 rules. About 0 are common, 5 are distinctive, and 12 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 12

    Very specific

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

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

    Do not reintroduce backend-variant primitives or detection helpers (e.g.

    line 36
  2. Very specific:

    When fixing CSS/layout issues (especially flex truncation, ellipsis, or element sizing), always inspect the full parent hierarchy for …

    line 40
  3. Distinctive:

    Before editing, explain: (1) the full flex/container hierarchy from the target element up to the nearest non-flex ancestor, (2) what …

    line 42
  4. Very specific:

    Never write raw queryKey arrays inline: Always use a query key factory object that returns as const tuples.

    line 66
  5. Very specific:

    Place the factory in the same file as the hooks, named {Domain}Keys (e.g., LlmKeys, DatasetKeys).

    line 85
  6. Very specific:

    Every useQuery and every invalidateQueries must reference the same factory function.

    line 86
  7. Very specific:

    Use as const on each factory return value for type-safe readonly tuples.

    line 87
  8. Distinctive:

    Do not hoist child-view queries into the page component — it fires requests the user may never need (e.g., fetching the skill tree on page …

    line 99
  9. Very specific:

    Do not thread enabled flags or view-mode props through hooks to gate a hoisted query.

    line 100
  10. Very specific:

    If a component does not meet requirements, wrap or compose it in a new component outside src/components/ui/ (e.g., under src/components/ or …

    line 123
  11. Distinctive:

    Use PascalCase for constants and component names.

    line 133
  12. Very specific:

    Avoid camelCase or SCREAMING_SNAKE_CASE for components and top-level constants.

    line 136
  13. Distinctive:

    Avoid duplicating component structures in JSX.

    line 138
  14. Very specific:

    Time/date handling: Use dayjs for all date/time formatting, parsing, and manipulation.

    line 142
  15. Very specific:

    Utility hooks: Prefer ahooks for common reusable hooks (e.g., useDebounce, useSetState).

    line 143
  16. Distinctive:

    Project utilities first: Before reaching for a third-party library, check if the project already has an existing utility or hook that …

    line 145
  17. Very specific:

    Extract and share: If repeated logic cannot be satisfied by an existing project utility or a third-party library, extract it into an …

    line 146

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

AGENTS.md

This file provides guidance to Claude Code (claude.ai/code) when working with the RAGFlow frontend (web/).

Project Overview

RAGFlow frontend is a React/TypeScript application built with Vite:

  • Components: shadcn/ui
  • Styling: Tailwind CSS
  • State: Zustand
  • Data Fetching: TanStack Query (React Query)
  • i18n: react-i18next

Common Commands

npm install
npm run dev        # Development server
npm run build      # Production build
npm run lint       # oxlint
npm run format     # oxfmt
npm run test       # Jest tests

Development Conventions

Test File Placement

When tests are grouped in a dedicated directory, that directory is always named __tests__/ — never tests/. Example: src/pages/agent/utils/__tests__/extractor-transform.test.ts for src/pages/agent/utils/extractor-transform.ts. Co-located foo.test.ts(x) files next to the source file are also fine. When you find an existing test under a tests/ directory, move it into __tests__/ (keep git history via git mv) rather than adding new tests there.

Backend Conventions

The frontend serves only the Go backend. There is no runtime backend detection and no per-backend branching in app code; the dev server proxies /api and /v1 to the Go API (vite.config.ts).

Do not reintroduce backend-variant primitives or detection helpers (e.g. a useIsGoBackend hook, pickByBackend, <BackendVariant>, or an /api/v1/language probe) and do not create go/-vs-python/ variant directories or files.

CSS and Layout Debugging

When fixing CSS/layout issues (especially flex truncation, ellipsis, or element sizing), always inspect the full parent hierarchy for flex-shrink, min-width, and overflow constraints before applying fixes like min-w-0. Do not repeatedly apply the same fix without verifying the root cause.

  • Before editing, explain: (1) the full flex/container hierarchy from the target element up to the nearest non-flex ancestor, (2) what constraint is actually causing the bug, and (3) how the proposed fix addresses that root cause.

Color Tokens

When writing or modifying styles, use the project-defined color tokens from src/tailwind.css (e.g., bg-bg-base, text-text-primary, text-text-secondary, text-text-disabled, border-border-button, bg-bg-card). Do not use arbitrary hex/RGB values or Tailwind's default palette colors (e.g., emerald-500, blue-400) directly in component class names. These tokens are defined for both light and dark modes and keep the UI consistent with the design system.

Scope and Boundaries

Respect explicit boundaries from the user. If the user says "only fix the selected line" or "do not touch shared types/files", follow that instruction exactly. Do not investigate unrelated errors, modify shared schemas (e.g., LlmSettingFieldSchema), or refactor other files without confirmation. If a change outside the described scope seems necessary, ask for permission first.

Internationalization (i18n)

For translation tasks, add keys only to the explicitly requested language files (commonly src/locales/zh.ts and src/locales/en.ts). Do not auto-propagate changes to all language files unless the user explicitly asks.

  • Style for en.ts: Sentence case — first word capitalized, rest lowercase (e.g., referenceAnswer: 'Reference answer'). Proper nouns remain as-is.

React Component Refactoring

When refactoring or extracting components, verify layout behavior after each structural change (especially flex-1, conditional rendering, or flex direction changes). Check that existing buttons, alignment, and responsive behavior remain intact. After extraction, verify: (1) all original props and behavior are preserved, (2) layout in parent contexts is identical, and (3) no syntax or type errors were introduced.

State Management and Data Fetching

Query Key Factory (Mandatory)

Never write raw queryKey arrays inline. Always use a query key factory object that returns as const tuples. Raw arrays duplicated across useQuery and invalidateQueries are brittle, unreadable, and cause stale-cache bugs when key structures drift.

// ❌ Bad — raw array, hard to match with useQuery
queryClient.invalidateQueries({
  queryKey: [
    LLMApiAction.AddedProviders,
    params.provider_name,
    params.instance_name,
    'models',
  ],
});

// ✅ Good — factory reference, self-documenting
queryClient.invalidateQueries({
  queryKey: LlmKeys.instanceModels(params.provider_name, params.instance_name),
});
  • Place the factory in the same file as the hooks, named {Domain}Keys (e.g., LlmKeys, DatasetKeys).
  • Every useQuery and every invalidateQueries must reference the same factory function.
  • Use as const on each factory return value for type-safe readonly tuples.

Cache Debugging

For React Query / cache invalidation bugs, carefully compare query keys across all consuming components and mutation hooks. Mismatched keys (e.g., with/without refreshCount) are a common root cause of stale data or duplicate requests.

  • Systematically: (1) list every component/hook that calls useQuery for this data, (2) compare their query keys character-for-character, (3) check every mutation's onSuccess for cache invalidation, and (4) verify no parent re-renders are remounting the observer.

Colocate Queries with the Consuming View

Fire a query in the component that renders its data — not in a parent page. When a page switches between mutually exclusive views (tabs, view modes), extract each view into its own component that issues its own requests on mount. Conditional rendering then provides lazy loading for free.

  • Do not hoist child-view queries into the page component — it fires requests the user may never need (e.g., fetching the skill tree on page entry while the default view is the LLM wiki).
  • Do not thread enabled flags or view-mode props through hooks to gate a hoisted query; that is a sign the query lives at the wrong level. Split the view instead.
  • Remember the trade-off: with gcTime: 0, unmounting a view drops its cache, so switching back refetches. That is usually desirable for always-fresh data — do not reintroduce eager hoisting just to avoid the refetch.

Network Request Layering

HTTP requests are organized in three layers. Never import @/utils/request, @/utils/next-request, or @/utils/api directly inside a hook:

  1. src/hooks/use-xx-request.ts(x) — React Query hooks; only call the service layer.
  2. src/services/xx-service.ts — Register endpoints via registerNextServer, all going through @/utils/next-request.
  3. src/utils/next-request.ts — The single axios instance; handles token, 401 redirects, and error notifications.

Interface types are split between two folders:

  • Response/data shape → src/interfaces/database/xx.ts
  • Request params/body → src/interfaces/request/xx.ts

Model-related endpoints (LLM provider / factory / my LLM, etc.) are consolidated in src/services/llm-service.ts rather than scattered across hooks. For GET endpoints, register with method: 'get' in the service, and on the call site pass true as the second argument to use the native axios config (e.g., service.listProviders({ params: { available: true } }, true)).

Shared UI Component Lock

The folder src/components/ui/ is the project's shared UI library — it contains both official shadcn/ui primitives and project-authored common components built on top of shadcn. Both kinds are intended to be reused across the app and must not be modified casually.

  • Do not modify, refactor, restyle, or "improve" any file under src/components/ui/ (including subfolders), even if it seems like the most direct fix.
  • If a component does not meet requirements, wrap or compose it in a new component outside src/components/ui/ (e.g., under src/components/ or a feature folder), and customize via className, props, or composition.
  • Exceptions require explicit user approval in the same conversation. When in doubt, ask first and propose a wrapper-based alternative.
  • Adding a new shared component to src/components/ui/, or upgrading a shadcn primitive via the official shadcn CLI, is allowed only when the user explicitly requests it.

React Patterns and Conventions

  • Avoid inline event handlers. Do not define arrow functions directly on JSX event props like onClick={() => ...} or onChange={(e) => ...}. Instead, extract the handler and reference it by name (e.g., onClick={handleClick}). Inline handlers are recreated on every render, which can break React.memo optimizations and make stack traces harder to read.
  • Prefer requestAnimationFrame or useLayoutEffect over setTimeout(..., 0) for focus or DOM measurement operations.
  • Prefer useTranslation from react-i18next over project-wrapped utilities like useTranslate.
  • Extract complex logic into hooks or utils; keep components lean.
  • Use PascalCase for constants and component names.
    • Components: EditableTextarea, RAGFlowFormItem
    • Constants: InitialMockData, DefaultPlaceholder
  • Avoid camelCase or SCREAMING_SNAKE_CASE for components and top-level constants.
  • Name things semantically, not generically. A name should say what the value holds or what the callback does, so call sites read naturally. Don't leak a generic underlying-primitive API into your own component's public props — rename at the wrapper boundary (e.g., a tabs wrapper exposes activeTab / onTabChange, mapped internally to Radix's value / onValueChange), and align with what callers already name the state. Same for variables and functions: hiddenNodeIds over nodeIdSet, pickByBackend over resolveVariant.
  • Avoid duplicating component structures in JSX; favor render props or reusable components.

Utility Libraries and Reuse

  • Time/date handling: Use dayjs for all date/time formatting, parsing, and manipulation.
  • Utility hooks: Prefer ahooks for common reusable hooks (e.g., useDebounce, useSetState).
  • General utilities: Lodash is available for utility functions when needed.
  • Project utilities first: Before reaching for a third-party library, check if the project already has an existing utility or hook that covers the need.
  • Extract and share: If repeated logic cannot be satisfied by an existing project utility or a third-party library, extract it into an appropriate shared hook (src/hooks/) or utility file (src/utils/).
  • Check for duplicate patterns before adding: When asked to add logic (validation, existence checks, API calls, etc.), first search for existing hooks/functions that do the same or similar thing — especially in the same file or sibling hooks. If a hook already does X, call it instead of re-implementing X inline. This applies to mutations calling mutations, utility wrappers, and boilerplate around API calls.

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.