Files
upstream-mattermost/webapp/CLAUDE.OPTIONAL.md
upstream-mirror 240db4e2a7
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
snapshot of https://github.com/mattermost/mattermost.git (master, 2026-09-16; blobs > 131072B omitted)
2026-09-16 00:29:55 +05:00

5.9 KiB
Raw Blame History

CLAUDE.md

Guidance for Claude Code when working inside webapp/.

Project Overview

This is the Mattermost web app codebase, a React-based frontend application for the Mattermost collaboration platform. The repository is structured as an npm workspace monorepo with multiple packages, with the main application code in the channels package and shared platform code in platform/* packages.

  • Primary workspace: channels/ (UI, Redux, routing).
  • Shared packages: platform/*.
  • Scripts: webapp/scripts/ power dev server, builds, and localization flows.
  • Coding Standards: Read webapp/STYLE_GUIDE.md for canonical standards; nested CLAUDE.md files cover directory-specific rules.

Core Commands

Task Command
Install deps npm install (includes postinstall build of platform packages)
Dev server (prod build watch) make run
Dev server (webpack-dev-server) make dev or npm run dev-server --workspace=channels
Build all workspaces make dist or npm run build
Build Channels only npm run build --workspace=channels
Tests make test or npm run test --workspace=channels (use test:watch, test:updatesnapshot as needed)
Lint / Style make check-style, make fix-style, npm run check --workspace=channels, npm run fix --workspace=channels
Type check make check-types
Clean artifacts make clean or npm run clean --workspaces --if-present

Top-Level Directory Map

  • channels/ – Channels workspace. See channels/CLAUDE.md.
    • src/ – App source with further scoped guides (components, actions, selectors, reducers, store, sass, i18n, tests, utils, types, plugins, packages/mattermost-redux).
  • platform/ – Shared packages (client, components, types, eslint-plugin). See platform/CLAUDE.md plus sub-guides.
  • scripts/ – Build/dev automation. See scripts/CLAUDE.md.
  • STYLE_GUIDE.md – Authoritative style + accessibility + testing reference.
  • README.md, config.mk, Makefile – onboarding, env config, and command wiring.

Workspace Architecture

This repository uses npm workspaces:

  • channels (channels/): Main Mattermost web app containing all UI components, Redux logic, and application code
  • @mattermost/types (platform/types/): TypeScript type definitions
  • @mattermost/client (platform/client/): REST and WebSocket client for the Mattermost API
  • @mattermost/components (platform/components/): Shared React components
  • @mattermost/shared (platform/shared/): Cross-product components and utilities used by the web app and plugins (e.g. Button, WithTooltip). Prefer these over hand-rolled equivalents.
  • @mattermost/eslint-plugin (platform/eslint-plugin/): Custom ESLint rules

Importing Packages

Always import packages using their full name, never relative paths:

// Correct
import {Client4} from '@mattermost/client';
import {UserProfile} from '@mattermost/types/users';
import {Button} from '@mattermost/shared/components/button';
import {WithTooltip} from '@mattermost/shared/components/tooltip';
import {getUser} from 'mattermost-redux/selectors/entities/users';

// Incorrect
import Client4 from '../platform/client/src/client4.ts';

Key Dependencies

  • React 18.2: Main UI framework
  • Redux 5.0: State management
  • React Router 5.3: Client-side routing
  • React Intl: Internationalization
  • Floating UI: Tooltips and popovers (prefer WithTooltip from @mattermost/shared/components/tooltip)
  • @mattermost/shared: Shared components and utilities (Button, WithTooltip, etc.) — prefer these over rolling your own
  • @mattermost/compass-icons: Icon library (prefer over font-awesome)
  • Monaco Editor: Code editor integration
  • Styled Components: Limited use (for MUI and some legacy components)

Important Configuration Files

  • channels/webpack.config.js: Webpack configuration with module federation
  • channels/jest.config.js: Jest test configuration
  • channels/tsconfig.json: TypeScript configuration with workspace references
  • channels/.eslintrc.json: ESLint configuration

Cross-Cutting Standards & Common Gotchas

  • Functional Components: Prefer functional React components with hooks; memoize expensive logic.
  • Data Access: Client4/WebSocket access happens via Redux actions only—never directly from components.
  • Internationalization: All UI strings must be translatable via React Intl. Use FormattedMessage unless a raw string is required. When adding or modifying a new translatable string, add or modify ONLY the English main file en.json. DO NOT update the other languages.
  • Styling: Uses SCSS + CSS variables with BEM naming; avoid !important unless migrating legacy code.
  • Testing: RTL + userEvent for tests; no snapshots. Use helpers under channels/src/tests/.
  • Accessibility: Follow guidance in STYLE_GUIDE.md (semantic elements, keyboard support, focus management).
  • Platform Packages: Rebuild automatically on npm install; re-run if types appear stale.
  • Adding Dependencies: Always add dependencies with npm add <pkg> --workspace=channels (or the relevant workspace).
  • Redux State Split: state.entities.* (server data via mattermost-redux) vs state.views.* (UI/persisted). Store new server entities in mattermost-redux first.
  • Client4 Returns: Methods return {response, headers, data} – unwrap accordingly in actions.

Nested CLAUDE Files

  • Channels workspace: channels/CLAUDE.md, channels/src/CLAUDE.md.
  • Channels source subfolders: components/, actions/, selectors/, reducers/, store/, sass/, i18n/, tests/, utils/, types/, plugins/, packages/mattermost-redux/.
  • Platform packages: platform/CLAUDE.md, plus platform/client/, platform/components/, platform/shared/, platform/types/.
  • Tooling: scripts/CLAUDE.md.

Use these nested guides for focused, actionable instructions when working within each directory.