Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ This is a Flutter/Dart monorepo managed by Melos with the following structure:
- Command structure in `lib/commands/`
- Includes doctor command for environment validation
- Template bundles are auto-updated via tools scripts
- `example/nonstop_example/` is the committed output of `nonstop create` (all modules). After changing a brick, run `melos run generate:nonstop_example` and commit the diff; never hand-edit the snapshot. It is excluded from root lint/analyze and from pub publish (`.pubignore`)

## README Standardization (readme_sync)

Expand Down
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include: package:flutter_lints/flutter.yaml
analyzer:
exclude:
- packages/nonstop_cli/bricks/**/__brick__/**
# Generated snapshot; verified inside its own workspace.
- packages/nonstop_cli/example/nonstop_example/**
- "**/coverage/**"
- "**/build/**"
linter:
Expand Down
1 change: 0 additions & 1 deletion packages/nonstop_cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ coverage/
# Android studio and IntelliJ
.idea

example/generated/
19 changes: 19 additions & 0 deletions packages/nonstop_cli/.pubignore
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
bricks/
# See https://www.dartlang.org/guides/libraries/private-files

# Files and directories created by pub
.dart_tool/
.packages
build/
pubspec.lock

# Files generated during tests
.test_coverage.dart
coverage/
.test_runner.dart

# Android studio and IntelliJ
.idea

# .pubignore replaces .gitignore for pub: keep the rules above in sync.
# The committed example snapshot is for reviewers, not the published package.
example/nonstop_example/
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# {{ name.titleCase() }}

{{ description }}

The contract for agents working in this app. Read the repository root
`CLAUDE.md` and the area `CLAUDE.md` above this directory (`apps/`)
first, and do not repeat their rules here. Update this file in the same change as the code it
describes.

## Composition

| Path | Responsibility |
|---|---|
| `lib/main.dart` | Entry point: bootstrap, build the router, mount the app |
| `lib/` | Wiring only: bootstrap order, router, app-only screens |
| `test/` | Startup, routing and lifecycle tests |

## Rules

- This app is a composition root: it wires features and packages and owns no
business logic. Move anything reusable into `features/` or `packages/`.
- `di.get` is allowed here; this is the composition edge.
- Environment values are `--dart-define`s declared in
`packages/core/lib/constants/environment.dart`.
- App-only UI follows the `design-system` skill.

## Common changes

_Add two to four recipes for the changes people make here, naming the files to
touch and the test to add._

## Tests

Run `dart run melos exec --scope={{ name.snakeCase() }} -- flutter test`. Keep
`dart run melos run coverage` at 100%: the gate fails a member without tests.

## Gotchas

_None yet. Record real ones as you find them._
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# {{ name.titleCase() }}

{{ description }}

The contract for agents working in this package. Read the repository root
`CLAUDE.md` and the area `CLAUDE.md` above this directory (`packages/` or `features/`)
first, and do not repeat their rules here. Update this file in the same change as the code it
describes.

## Public API

| Symbol | Kind | Use |
|---|---|---|
| _Each exported class, function and `init()`_ | | |

## Layout

| Path | Responsibility |
|---|---|
| `lib/{{ name.snakeCase() }}.dart` | Public barrel: the only import other members use |
| `lib/src/` | Implementation, grouped by role (`client/`, `config/`, `models/`, ...) |
| `test/` | Tests for every public behavior |

## Rules

- Depend only on lower layers (see `packages/CLAUDE.md`); never on an app or
another feature.
- Contracts are `abstract interface class`; implementations take their
dependencies through the constructor.
- User-facing text comes from `localization`; visuals come from
`design_system` (load the `design-system` skill before UI work).
- Register implementations with `di` only from this package's `init()`.

## Common changes

_Add two to four recipes for the changes people make here, naming the files to
touch and the test to add._

## Tests

Run `dart run melos exec --scope={{ name.snakeCase() }} -- flutter test`. Keep
`dart run melos run coverage` at 100%: the gate fails a member without tests.

## Gotchas

_None yet. Record real ones as you find them._
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# {{ name.titleCase() }}

{{ description }}

The contract for agents working in this plugin. Read the repository root
`CLAUDE.md` and the area `CLAUDE.md` above this directory (`plugins/`)
first, and do not repeat their rules here. Update this file in the same change as the code it
describes.

## Public API

| Symbol | Kind | Use |
|---|---|---|
| _The Dart contract other members use_ | | |

## Layout

| Path | Responsibility |
|---|---|
| `lib/` | Dart contract; channel names and argument maps stay private |
| `android/`, `ios/`, ... | Native implementations for each declared platform |
| `test/` | Channel tests with `TestDefaultBinaryMessengerBinding` |

## Rules

- A plugin depends on nothing in `apps/`, `features/` or `packages/`.
- Convert `PlatformException` into typed exceptions at the boundary.
- Every platform declared in `pubspec.yaml` is implemented or throws
`UnimplementedError` with a clear message.
- Never block the platform main thread in native code.

## Common changes

_Add two to four recipes for the changes people make here, naming the files to
touch and the test to add._

## Tests

Run `dart run melos exec --scope={{ name.snakeCase() }} -- flutter test`. Keep
`dart run melos run coverage` at 100%: the gate fails a member without tests.

## Gotchas

_None yet. Record real ones as you find them._
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# PostToolUse(Edit|Write|MultiEdit): format the Dart file that was just written,
# so the lint gate never fails on formatting. Always exits 0.
path=$(sed -n 's/.*"file_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -1)
case "$path" in
*.g.dart|*.freezed.dart|*.i69n.dart) ;;
*.dart) [ -f "$path" ] && dart format "$path" >/dev/null 2>&1 ;;
esac
exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# PreToolUse(Edit|Write|MultiEdit): refuse hand edits to generated files.
# Fails open: anything unexpected exits 0 so a broken hook never blocks work.
path=$(sed -n 's/.*"file_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -1)
case "$path" in
*.g.dart|*.freezed.dart|*.i69n.dart)
echo "Blocked: $path is generated. Edit its source, then run 'dart run melos run generate' (or 'generate:i69n' for localization)." >&2
exit 2 ;;
*/design_system/lib/generated/*)
echo "Blocked: $path comes from Material Theme Builder. Replace the file wholesale with a new export." >&2
exit 2 ;;
*pubspec.lock)
echo "Blocked: pubspec.lock is written by 'dart pub get'. Change pubspec.yaml instead." >&2
exit 2 ;;
esac
exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"permissions": {
"allow": [
"Bash(dart pub get)",
"Bash(dart run melos bootstrap)",
"Bash(dart run melos list:*)",
"Bash(dart run melos run lint)",
"Bash(dart run melos run test)",
"Bash(dart run melos run coverage)",
"Bash(dart run melos run generate)",
"Bash(dart run melos run generate:i69n)",
"Bash(dart run tool/check.dart)",
"Bash(dart run tool/coverage.dart:*)",
"Bash(dart format:*)",
"Bash(dart analyze:*)",
"Bash(flutter test:*)",
"Bash(flutter --version)",
"Bash(flutter doctor:*)"
],
"deny": [
"Read(**/.env)",
"Read(**/*.keystore)",
"Read(**/*.jks)",
"Read(**/key.properties)"
]
},
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write|MultiEdit",
"hooks": [
{ "type": "command", "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/guard_generated.sh\"", "timeout": 5 }
]
}
],
"PostToolUse": [
{
"matcher": "Edit|Write|MultiEdit",
"hooks": [
{ "type": "command", "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/format_dart.sh\"", "timeout": 30 }
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
name: design-system
description: Visual design rules for every screen and widget in this repo - where colors, typography, shapes, icons, feedback (toasts, loaders, errors) and images come from, when a widget belongs in packages/design_system, how to add or change a shared component, theming both brightnesses, and the UI review checklist. Load before building or reviewing any UI in apps, features, packages or plugins.
---

# Design system

`packages/design_system` is the single source of visual truth. Features
compose it; they do not restyle it. Package details and gotchas are in
`packages/design_system/CLAUDE.md`.

## Where every visual value comes from

| Need | Use | Never |
|---|---|---|
| Color | `Theme.of(context).colorScheme.<role>` (`primary`, `onPrimary`, `surface`, `onSurfaceVariant`, `error`, `outlineVariant`, ...) | `Color(0x...)`, `Colors.*`, opacity hacks for meaning |
| Text | `Theme.of(context).textTheme.<style>` (`titleLarge`, `bodyMedium`, `labelSmall`, ...), `copyWith` only for `color` / `fontWeight` | Raw `TextStyle(fontSize: ...)`, new font families |
| Buttons, app bar, nav bar, inputs | Plain Material widgets; styling comes from `DesignSystem._baseTheme` | Per-widget `style:` that restyles shape or typography |
| Icons | `NavigationIcons` for navigation; Material `Icons` otherwise | A second icon set in a feature |
| Feedback | `Toast.success/error/warning/notification`; `Loader.show/hide` for blocking work; `DefaultLoader` inline | `ScaffoldMessenger` snack bars, ad-hoc overlays |
| Errors | `DefaultErrorView` (inline, with retry), `ErrorScreen` (full screen) | Custom error widgets per feature |
| Images | `NetworkUrlImage` (cached, placeholder, error), `AppAssetImage` (raster or SVG with fallback) | `Image.network`, Flutter `AssetImage` directly |
| Copy | `strings.<group>.<key>` from `localization` | String literals |

## Layout and spacing

- Spacing is a 4dp grid (4, 8, 12, 16, 24, 32, 40); every existing screen
stays on it. Prefer 16 for screen padding.
- Corner radius: 4 for buttons and the nav indicator (set in the theme); 8, 12
or 16 for containers, cards and toasts. No other values.
- When the same spacing or size literal repeats across three or more files,
add a named constant to `design_system` instead of copying it again.
- Use `SafeArea`, `LayoutBuilder` / `MediaQuery.sizeOf` for responsive layout.
No hard-coded screen widths. Scrollable content uses `ListView` / slivers.

## Is it a design-system component?

Put a widget in `packages/design_system` only when all of these hold:

1. Two or more features need it (or the app shell does).
2. It knows nothing about a product domain (no "Order", "Patient", "Invoice").
3. It renders only what its parameters give it: no `di`, no repositories, no
navigation, no analytics calls. Callbacks go out (`onRetry`, `onChanged`).

Otherwise keep it in the feature's `lib/ui/components/`.

## Adding or changing a shared component

1. Check the catalog in `packages/design_system/CLAUDE.md`; extend an existing
component with a parameter before creating a sibling.
2. `StatelessWidget`, `const` constructor, `super.key`, required parameters
first. Use a `enum` for variants (see `HeaderType`, `DateFilterType`).
3. Style only through the theme. Take user-visible text as a parameter, or use
`strings.*` for generic defaults (as `ErrorScreen` does).
4. Accessibility: 48x48dp minimum tap targets, a `tooltip` or
`Semantics(label:)` on icon-only controls, no fixed heights around text, and
color is never the only signal.
5. Export it from `lib/components/index.dart` (or the matching barrel).
6. Test it in `packages/design_system/test/` for light and dark themes,
interaction callbacks, empty/error states, and large text scale
(`MediaQuery(data: MediaQueryData(textScaler: TextScaler.linear(2)), ...)`).
7. Changing a public parameter is a breaking change: update every caller in
`apps/` and `features/` in the same change.

## Theming

- Light and dark are both first-class. Check every new screen in both; the
wrapper follows platform brightness.
- Palette: generated by Material Theme Builder into
`lib/generated/theme.dart`. Rebrand by replacing that file, never by editing
individual colors or overriding them in features.
- Fonts: `DesignSystem(context, bodyFont: ..., displayFont: ...)`.
- Component-wide changes (all buttons squarer, all app bars left-aligned) go in
`DesignSystem._baseTheme`, one place.

## UI review checklist

- [ ] No raw colors, font sizes or string literals in the diff.
- [ ] Loading, empty, error and data states are all handled.
- [ ] Works in light and dark, at 2x text scale, on a small phone width.
- [ ] Icon-only controls have labels; tap targets are at least 48dp.
- [ ] Reused design-system components instead of new look-alikes.
- [ ] New shared component: exported, tested, documented in
`packages/design_system/CLAUDE.md`.
Loading
Loading