Describe the repository structure and development workflow

Created on 11 August 2025, 4 days ago

Problem/Motivation

The CLAUDE.md included with this module lacks some of the detail of the CLAUDE.md generated by Claude Code's /init command.

Steps to reproduce

I checked out Drupal's 11.x branch, entered the root directory, and did claude /init. This is the CLAUDE.md Claude Code generated:

# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

This is the Drupal 11 core development repository. Drupal is an open source content management platform. This repository contains the complete Drupal core codebase including:

- Core modules and subsystems
- Core themes (Claro, Olivero, Stark, Starterkit)  
- Installation profiles (Standard, Minimal, Demo Umami)
- Recipes for common configurations
- Testing infrastructure
- Build and development tools

**Important**: This is the core development repository, not intended for production sites. See https://www.drupal.org/node/3082474 for production-ready distributions.

## Development Commands

### Testing
- **Run all tests**: `vendor/bin/phpunit` (from core/ directory)
- **Run specific test suite**: `vendor/bin/phpunit --testsuite=unit`
  - Available suites: `unit`, `unit-component`, `kernel`, `functional`, `functional-javascript`, `build`
- **Run single test**: `vendor/bin/phpunit path/to/TestFile.php`
- **Test configuration**: `core/phpunit.xml.dist`
- **Legacy test runner**: `core/scripts/run-tests.sh` (for DrupalCI compatibility)

### Code Quality
- **PHP CodeSniffer**: `composer phpcs` (uses `core/phpcs.xml.dist`)
- **PHP Code Beautifier**: `composer phpcbf` 
- **PHPStan static analysis**: Available in `core/phpstan.neon.dist`

### Frontend Development (from core/ directory)
- **Build all assets**: `yarn build`
- **Watch for changes**: `yarn watch`
- **Build CSS**: `yarn build:css` / `yarn watch:css`
- **Build CKEditor5**: `yarn build:ckeditor5` / `yarn watch:ckeditor5`
- **Lint JavaScript**: `yarn lint:core-js`
- **Lint CSS**: `yarn lint:css`
- **Lint YAML**: `yarn lint:yaml`
- **Spellcheck**: `yarn spellcheck`

### Database Operations
- **Install Drupal**: `core/scripts/drupal install`
- **Quick development server**: `core/scripts/drupal quick-start`
- **Database tools**: `core/scripts/db-tools.php`

## Architecture Overview

### Core Structure
- **`core/lib/Drupal.php`**: Static service container wrapper for legacy code
- **`core/lib/Drupal/Core/`**: Main core classes organized by subsystem
- **`core/lib/Drupal/Component/`**: Standalone components that can be used independently
- **`core/modules/`**: Core modules providing essential functionality
- **`core/themes/`**: Core themes
- **`core/profiles/`**: Installation profiles
- **`core/recipes/`**: Configuration recipes for common setups

### Key Subsystems (core/lib/Drupal/Core/)
- **Entity**: Content/configuration entity system (`Entity/`)
- **Database**: Database abstraction layer (`Database/`)
- **Cache**: Caching system with multiple backends (`Cache/`)
- **Config**: Configuration management system (`Config/`)
- **Form**: Form API (`Form/`)
- **Routing**: URL routing system (`Routing/`)
- **Access**: Access control system (`Access/`)
- **Field**: Field API for content types (`Field/`)
- **Plugin**: Plugin system for extensible functionality (`Plugin/`)
- **Asset**: CSS/JS asset management (`Asset/`)

### Dependency Injection
- Drupal uses Symfony's DependencyInjection component
- Services defined in `*.services.yml` files
- Use `\Drupal::service('service.name')` for legacy code or inject services in OOP code
- Container built by `DrupalKernel`

### Module Development
- **Contrib modules**: Place in `modules/contrib/`
- **Custom modules**: Place in `modules/custom/`
- **Module structure**: `module_name/src/` for main classes, tests in `module_name/tests/`
- **Module definition**: `module_name.info.yml`
- **Hook implementations**: `module_name.module`

### Theme Development  
- **Contrib themes**: Place in `themes/contrib/`
- **Custom themes**: Place in `themes/custom/`
- **Base starter theme**: Use `core/themes/starterkit_theme/` as starting point
- **Twig templating**: Templates in `templates/` directory

### Testing Strategy
- **Unit tests**: Fast, isolated tests (`tests/src/Unit/`)
- **Kernel tests**: Tests with minimal Drupal bootstrap (`tests/src/Kernel/`)
- **Functional tests**: Full HTTP tests (`tests/src/Functional/`)
- **JavaScript tests**: Browser-based tests (`tests/src/FunctionalJavascript/`)
- **Build tests**: Composer/build process tests (`tests/src/Build/`)

## Environment Setup

### Requirements
- PHP 8.3+ (configured in composer.json platform)
- Database: MySQL 5.7.8+, MariaDB 10.6+, PostgreSQL 16+, or SQLite 3
- Web server: Apache, Nginx, or built-in PHP server
- Node.js 20+ and Yarn 4.1.1+ for frontend development

### Local Development
- Use `sites/default/settings.local.php` for local overrides
- Copy from `sites/example.settings.local.php` 
- Enable development services with `sites/development.services.yml`
- Configure database in `sites/default/settings.php` or `settings.local.php`

### Installation
- Standard web install: Point browser to `/core/install.php`
- Command line: Use `core/scripts/drupal install` 
- Quick development: `core/scripts/drupal quick-start`

## Key Files
- **`composer.json`**: Main project dependencies and scripts
- **`core/composer.json`**: Core-specific dependencies 
- **`core/package.json`**: Frontend build dependencies and scripts
- **`autoload.php`**: Composer autoloader entry point
- **`index.php`**: Main web entry point
- **`core/install.php`**: Installation entry point
- **`update.php`**: Database update entry point

## Development Workflow
1. Install dependencies: `composer install` and `yarn install` (in core/)
2. Set up local settings and database
3. Install Drupal via web or CLI
4. Enable development settings
5. Make changes and test with appropriate test suite
6. Run code quality checks before committing
7. Frontend changes require rebuilding assets with yarn commands

Proposed resolution

I think it would be useful to have the "Project Overview", "Key Subsystems", and "Dependency Injection" sections, and it would also be good to have a statement like "Run code quality checks before committing".

I'm happy to make a PR but I'd like to hear from the maintainers if they are comfortable with this kind of change.

Feature request
Status

Active

Version

1.0

Component

CLAUDE.md

Created by

🇯🇵Japan ptmkenny

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024