Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CLAUDE.md 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # CLAUDE.md
  2. This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
  3. ## Project Overview
  4. Dify is an open-source platform for developing LLM applications with an intuitive interface combining agentic AI workflows, RAG pipelines, agent capabilities, and model management.
  5. The codebase consists of:
  6. - **Backend API** (`/api`): Python Flask application with Domain-Driven Design architecture
  7. - **Frontend Web** (`/web`): Next.js 15 application with TypeScript and React 19
  8. - **Docker deployment** (`/docker`): Containerized deployment configurations
  9. ## Development Commands
  10. ### Backend (API)
  11. All Python commands must be prefixed with `uv run --project api`:
  12. ```bash
  13. # Start development servers
  14. ./dev/start-api # Start API server
  15. ./dev/start-worker # Start Celery worker
  16. # Run tests
  17. uv run --project api pytest # Run all tests
  18. uv run --project api pytest tests/unit_tests/ # Unit tests only
  19. uv run --project api pytest tests/integration_tests/ # Integration tests
  20. # Code quality
  21. ./dev/reformat # Run all formatters and linters
  22. uv run --project api ruff check --fix ./ # Fix linting issues
  23. uv run --project api ruff format ./ # Format code
  24. uv run --directory api basedpyright # Type checking
  25. ```
  26. ### Frontend (Web)
  27. ```bash
  28. cd web
  29. pnpm lint # Run ESLint
  30. pnpm eslint-fix # Fix ESLint issues
  31. pnpm test # Run Jest tests
  32. ```
  33. ## Testing Guidelines
  34. ### Backend Testing
  35. - Use `pytest` for all backend tests
  36. - Write tests first (TDD approach)
  37. - Test structure: Arrange-Act-Assert
  38. ## Code Style Requirements
  39. ### Python
  40. - Use type hints for all functions and class attributes
  41. - No `Any` types unless absolutely necessary
  42. - Implement special methods (`__repr__`, `__str__`) appropriately
  43. ### TypeScript/JavaScript
  44. - Strict TypeScript configuration
  45. - ESLint with Prettier integration
  46. - Avoid `any` type
  47. ## Important Notes
  48. - **Environment Variables**: Always use UV for Python commands: `uv run --project api <command>`
  49. - **Comments**: Only write meaningful comments that explain "why", not "what"
  50. - **File Creation**: Always prefer editing existing files over creating new ones
  51. - **Documentation**: Don't create documentation files unless explicitly requested
  52. - **Code Quality**: Always run `./dev/reformat` before committing backend changes
  53. ## Common Development Tasks
  54. ### Adding a New API Endpoint
  55. 1. Create controller in `/api/controllers/`
  56. 1. Add service logic in `/api/services/`
  57. 1. Update routes in controller's `__init__.py`
  58. 1. Write tests in `/api/tests/`
  59. ## Project-Specific Conventions
  60. - All async tasks use Celery with Redis as broker
  61. - **Internationalization**: Frontend supports multiple languages with English (`web/i18n/en-US/`) as the source. All user-facing text must use i18n keys, no hardcoded strings. Edit corresponding module files in `en-US/` directory for translations.