選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

CLAUDE.md 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 --project api mypy . # 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