agentleFS
jingsewujingsewu/open-wes/CLAUDE.md

open-wes

CLAUDE.md339 starsChanged 10 days agoMITView on GitHub

Open WES is a Warehouse Execution System. Monorepo structure: - server/ — Java 17, Spring Boot 3.2.2, Gradle, DDD architecture - client/ — React 17, TypeScript, MobX + AMIS framework - Infrastructure: Docker Compose, MySQL 8.0, Redis 7.2, Nacos 2.0, Kafka Read docs/standards/backend.md first — it defines DDD rules, database standards, plugin patterns, and validation rules that all backend code must follow. Script plugins are database-backed Groo

  • Installs packages
  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

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

23 rules. About 0 are common, 5 are distinctive, and 18 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.

  • 18

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Use @Version for optimistic locking

    line 75
  2. Very specific:

    Only find* and save* methods.

    line 79
  3. Distinctive:

    Prefer async domain events over big transactions

    line 85
  4. Very specific:

    Redis: Use RedisUtils, not RedisTemplate

    line 89
  5. Very specific:

    Locking: Use DistributedLock class

    line 90
  6. Very specific:

    POJO: Use @Comment("...") not columnDefinition for column comments

    line 97
  7. Very specific:

    AMIS lint: Run npm run lint:amis in client/ after changing a schema.

    line 114
  8. Very specific:

    HTTP requests: Always use request from @/utils/requestInterceptor.

    line 116
  9. Very specific:

    i18n: Use useTranslation() hook or t() function.

    line 117
  10. Distinctive:

    React keys: Use stable unique IDs, never array indexes.

    line 119
  11. Distinctive:

    SVG IDs: Use namespaced module-scoped constants for gradient/clipPath IDs to prevent duplicates across renders.

    line 123
  12. Very specific:

    Read docs/standards/amis.md: before writing or migrating an AMIS schema.

    line 126
  13. Very specific:

    NEVER: commit secrets, API keys, or passwords.

    line 132
  14. Very specific:

    NEVER: use dangerouslySetInnerHTML without DOMPurify.

    line 133
  15. Very specific:

    NEVER: use .anyRequest().permitAll() in Spring Security.

    line 135
  16. Distinctive:

    Always: use parameterized queries for any user-influenced SQL.

    line 138
  17. Very specific:

    All three servers (WES, Station, Gateway) expose /actuator/prometheus

    line 156
  18. Very specific:

    Create a @Component class in org.openwes.monitoring.metrics

    line 159
  19. Very specific:

    Add @Subscribe methods for the domain events you want to track

    line 160
  20. Very specific:

    Use MeterRegistry to record counters/gauges/timers

    line 161
  21. Very specific:

    All monitoring infrastructure config lives in monitoring/ at the repo root:

    line 170
  22. Distinctive:

    All schema and data changes must use Liquibase changelogs — never ad-hoc SQL files.

    line 215
  23. Very specific:

    Always use preConditions onFail="MARK_RAN" for idempotency

    line 220

≈ “Common” is an estimate: at least 1 in 5 of the 29,248 CLAUDE.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
CLAUDE.md

Open WES - AI Coding Guidelines

Project Overview

Open WES is a Warehouse Execution System. Monorepo structure:

  • server/ — Java 17, Spring Boot 3.2.2, Gradle, DDD architecture
  • client/ — React 17, TypeScript, MobX + AMIS framework
  • Infrastructure: Docker Compose, MySQL 8.0, Redis 7.2, Nacos 2.0, Kafka

Read docs/standards/backend.md first — it defines DDD rules, database standards, plugin patterns, and validation rules that all backend code must follow.

Project Structure

Server Modules (server/)

modules-wes/          # Core domain (inbound, outbound, stock, basic, config, task, stocktake, algo, ems-proxy, printer)
modules-ai/           # AI integration (ai-core, ai-api, ai-plugin — script plugin drafts)
modules-user/         # Auth, user management
modules-station/      # Workstation operations
modules-gateway/      # API gateway
modules-plugin/       # Plugin platform: script-plugin-api/core/runtime, legacy PF4J jar modules, plugin-example sample
modules-search/       # Search functionality
modules-api-platform/ # External API platform
modules-utils/        # Shared utilities (must NOT depend on other modules) — includes monitoring module
server/               # Spring Boot runners (wes-server, station-server, gateway-server)

Client (client/src/)

pages/        # Page components (wms/, api_platform/, data_platform/, user/, monitoring/)
components/   # Shared React components
stores/       # MobX state tree stores
routes/       # React Router config + lazy-loaded route mapping
locales/      # i18n translation files (en/zh/ja/ko)
utils/        # HTTP client, helpers

Architecture Patterns

DDD Layer Flow

Controller -> IEntityApi (interface) -> EntityApiImpl -> Domain Service -> Entity -> Repository -> JPA

Package Convention

org.openwes.[module-group].[module].[domain].[layer]
# Example: org.openwes.wes.outbound.domain.entity.OutboundPlanOrder

Class Naming

TypePatternExample
API interfaceI[Entity]ApiIInboundPlanOrderApi
API impl[Entity]ApiImplInboundPlanOrderApiImpl
Service[Entity]Service / [Entity]ServiceImplOutboundWaveService
Repository[Entity]Repository / [Entity]RepositoryImplContainerRepository
DTO[Entity]DTOContainerDTO
Transfer[Entity]TransferInboundPlanOrderTransfer
Error enum[Module]ErrorDescEnumInboundErrorDescEnum

API Implementation Annotations

@Primary
@Service
@Validated
@DubboService
@RequiredArgsConstructor
public class EntityApiImpl implements IEntityApi { }

Domain Entity Rules

  • No setters — use lifecycle methods: initialize(), complete(), cancel(), close()
  • Extend AggregatorRoot for aggregate roots
  • Use @Version for optimistic locking
  • Publish events via addAsynchronousDomainEvents()

Repository Rules

  • Only find* and save* methods. Never update* methods.
  • Load entity -> mutate via lifecycle method -> save entire entity

Transactions

  • @Transaction only on Aggregates and Repositories
  • Pull queries out of transactions for performance
  • Prefer async domain events over big transactions

Backend Conventions

  • Redis: Use RedisUtils, not RedisTemplate
  • Locking: Use DistributedLock class
  • Async (same server): DomainEventPublisher.sendAsyncDomainEvent()
  • Async (cross server): MqClient.sendAsyncMessage()
  • Validation: @Valid on API interface params, @Validated on impl classes
  • Logging: English only, use @Slf4j
  • Config: Environment config in Nacos, business config in database
  • DB columns: Code=64, Name=128, Description=255, Remark=500, Enum=20 chars
  • POJO: Use @Comment("...") not columnDefinition for column comments
  • Plugins: One IPlugin interface per domain with before/after lifecycle hooks

Script Plugin Platform

Script plugins are database-backed Groovy bundles — no jar packaging and no restart. The legacy PF4J jar-plugin path is frozen.

  • Modules: script-plugin-api — contract catalog, DTOs and static validation; script-plugin-core — persistence, management services and /plugin-platform/**; script-plugin-runtime — materialization, invocation, dispatchers and registry; plugin-api/plugin-core/plugin-sdk/plugin-extension — legacy jar path; plugin-example — non-built sample (not in settings.gradle).
  • Hosts: wes-server hosts management + runtime (script-plugin.registry.mode: local); station-server hosts runtime only (mode: remote).
  • Lookup: PluginSdkUtils.getExtractObject(Class<T>) merges jar extensions with materialized script proxies, sorts by priority descending; an empty list means "use the built-in behavior".
  • Workbench: /plugin-platform/plugins, /plugin-platform/plugin-workbench?mode=new (or ?pluginKey=<key>), /plugin-platform/audit; client code lives in client/src/pages/plugin_platform/.
  • Tests: cd server && ./gradlew :modules-plugin:script-plugin-api:test
  • Rules: docs/standards/backend.md §Script Plugin Rules; the archetype table is generated from PluginContractCatalog and checked by PluginDocumentationConsistencyTest.

Frontend Conventions

  • AMIS pages: Most CRUD/form pages are JSON schema definitions using schema2component(). Prefer this pattern for standard pages. Compose @/utils/amis/presets (crudPage, formDrawer, column helpers) instead of copying schema boilerplate.
  • AMIS lint: Run npm run lint:amis in client/ after changing a schema; errors block a merge.
  • State management: MobX + mobx-state-tree (src/stores/). Use @inject @observer decorators.
  • HTTP requests: Always use request from @/utils/requestInterceptor. Never use raw fetch or axios.
  • i18n: Use useTranslation() hook or t() function. All user-facing strings must be translated.
  • TypeScript: Define proper interfaces. Avoid any types. Use Record<string, unknown> if type is truly unknown.
  • React keys: Use stable unique IDs, never array indexes.
  • Styling: Ant Design components + CSS classes. AMIS pages use AMIS built-in styling.
  • Logging: All console.* and toast messages must be in English. Never commit debug console.log calls. Never suppress console.error globally.
  • React props: Props are read-only — never mutate them. renderSchema() (AMIS) returns a ReactElement, not a class instance; do not call destroy()/dispose() on it.
  • SVG IDs: Use namespaced module-scoped constants for gradient/clipPath IDs to prevent duplicates across renders.

Read docs/standards/frontend.md for detailed rules, anti-patterns, and examples. Read docs/standards/amis.md before writing or migrating an AMIS schema.

Security Guidelines

These rules are non-negotiable:

  1. NEVER commit secrets, API keys, or passwords. Use ${ENV_VAR} placeholders.
  2. NEVER use dangerouslySetInnerHTML without DOMPurify. Prefer ReactMarkdown with rehype-sanitize.
  3. NEVER execute dynamically generated SQL directly. Validate with SQL parser, use read-only DB user.
  4. NEVER use .anyRequest().permitAll() in Spring Security. Define explicit authorization rules.
  5. NEVER hardcode credentials (including as default form values).
  6. Always validate DTO inputs with Bean Validation annotations (@Valid, @NotNull, @NotEmpty, @Size).
  7. Always use parameterized queries for any user-influenced SQL.
  8. Store tokens with expiry handling. Prefer httpOnly cookies over localStorage for sensitive tokens.

Monitoring & Observability

The project uses Prometheus + Grafana + Loki for monitoring, alerting, and log aggregation.

Architecture

  • Metrics: Application (Micrometer) → /actuator/prometheus → Prometheus scrape → Grafana
  • Logs: Application log files → Promtail → Loki → Grafana
  • Alerts: Prometheus/Loki alert rules → AlertManager → Webhook
  • Infrastructure: MySQL/Redis/Node/Kafka Exporters → Prometheus

Monitoring Module (modules-utils/monitoring/)

  • Auto-configured via MonitoringAutoConfiguration (Spring Boot auto-config)
  • Business metrics use Guava @Subscribe on domain events — zero invasion of business code
  • DomainEventProcessor (BeanPostProcessor) auto-registers any bean with @Subscribe methods
  • One *MetricsSubscriber per domain: Inbound, Outbound, Task, Stock
  • All three servers (WES, Station, Gateway) expose /actuator/prometheus

Adding New Business Metrics

  1. Create a @Component class in org.openwes.monitoring.metrics
  2. Add @Subscribe methods for the domain events you want to track
  3. Use MeterRegistry to record counters/gauges/timers
  4. The subscriber is auto-registered with EventBus — no manual wiring needed

Frontend Monitoring App

  • Top-level app (system_code='monitoring') with menu entries in u_menu table
  • Pages embed Grafana dashboards via iframe (?kiosk mode)
  • Grafana configured for anonymous Viewer access + iframe embedding

Monitoring Config Files

All monitoring infrastructure config lives in monitoring/ at the repo root:

monitoring/
├── prometheus/          # Scrape targets + alert rules
├── grafana/             # Dashboards + datasource provisioning
├── loki/                # Log storage config
├── promtail/            # Log collection config
└── alertmanager/        # Alert routing + notification

Monitoring Ports

ServicePort
Prometheus9090
Grafana3000
Loki3100
AlertManager9093

Build and Run

# Backend (Java 17 required)
cd server && ./gradlew build

# Frontend
cd client && npm install && npm run dev

# Full stack (Docker)
HOST_IP=$(hostname -I | awk '{print $1}') docker-compose up -d

Server Ports

ServicePort
Gateway8090
WES Server9010
Station Server9040
Frontend80
Prometheus9090
Grafana3000
Loki3100
AlertManager9093

Database Migrations

All schema and data changes must use Liquibase changelogs — never ad-hoc SQL files.

  • Changelogs live in server/server/wes-server/src/main/resources/db/changelog/
  • Naming: db.changelog-YYYYMMDD.xml; register in db.changelog-master.xml
  • Never edit any SQL file already referenced by an existing changeset (init_dictionary.sql etc.) — Liquibase checksums them and will refuse to start if they change
  • Always use preConditions onFail="MARK_RAN" for idempotency
  • Split ADD + MIGRATE + DROP into 3 separate changesets (Hibernate auto-DDL may create the new columns before Liquibase runs)
  • Adding or modifying an IEnum enum value requires a changeset in the same commit to sync the dictionary — POST /config/dictionary/refresh is a dev-only helper, not a substitute

Read docs/standards/liquibase.md for full rules, templates, and the ADD+MIGRATE+DROP pattern.

Repository Hygiene

Never commit AI tooling artifacts: .superpowers/, .claude/settings.local.json. These are covered by .gitignore — if you add new tooling, update .gitignore before the first commit.

Read docs/standards/repository.md for full rules on gitignore management and CI/GitHub Actions standards.

Key File Locations

PurposePath
Backend coding standardsdocs/standards/backend.md
Frontend standards (detailed)docs/standards/frontend.md
AMIS schema standardsdocs/standards/amis.md
Repository hygiene standardsdocs/standards/repository.md
Database migration standardsdocs/standards/liquibase.md
Gradle build configserver/build.gradle, server/settings.gradle
Backend entry pointsserver/server/wes-server/, station-server/, gateway-server/
App config (Nacos)initdb.d/nacos_config.sql
Dockerdocker-compose.yml
DB init scriptsinitdb.d/
Frontend entryclient/src/index.tsx
Route definitionsclient/src/routes/path2Compoment.tsx
Monitoring moduleserver/modules-utils/monitoring/
Monitoring infra configmonitoring/
Monitoring design specdocs/superpowers/specs/2026-05-23-monitoring-alerting-framework-design.md
Domain event systemserver/modules-utils/domain-event/
Script plugin AI pipelineserver/modules-ai/ai-plugin/
Script plugin contract catalogserver/modules-plugin/script-plugin-api/src/main/java/org/openwes/script/plugin/api/contract/PluginContractCatalog.java
Script plugin management planeserver/modules-plugin/script-plugin-core/
Script plugin runtimeserver/modules-plugin/script-plugin-runtime/
Script plugin sampleserver/modules-plugin/plugin-example/
Script plugin workbench (client)client/src/pages/plugin_platform/
Script plugin rules chapterdocs/standards/backend.md (§Script Plugin Rules)

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.