xiaohongshu
xiaohongshu
template-mason-brick
Guide for creating, updating, or removing Mason bricks with corresponding tests and CI workflow (project)
Full skill instructions
This skill guides the creation, modification, and removal of Mason bricks, ensuring test coverage and CI workflow integration.
Trigger this skill when:
Bricks are organized in three locations:
bricks/ # Mason template definitions
├── brick_name/
│ ├── brick.yaml # Brick configuration and variables
│ ├── __brick__/ # Template files with Mustache syntax
│ └── hooks/ # Optional pre/post generation hooks
test_bricks/ # Brick tests (one folder per brick)
├── brick_name/
│ └── brick_name_test.dart
.github/workflows/
└── brick-test.yml # Parallel CI jobs for each brick
mkdir -p bricks/new_brick/__brick__
name: new_brick
description: Description of what this brick generates
version: 0.1.0+1
environment:
mason: ^0.1.1
vars:
name:
type: string
description: The name for the generated component
prompt: What is the name?
# Add more variables as needed
optional_var:
type: boolean
description: Optional feature flag
default: true
In __brick__/, create files using Mustache syntax:
__brick__/
├── {{name.snakeCase()}}/
│ ├── lib/
│ │ └── {{name.snakeCase()}}.dart
│ ├── pubspec.yaml
│ └── README.md
Use these Mustache helpers:
{{name}} - raw value{{name.snakeCase()}} - snake_case{{name.pascalCase()}} - PascalCase{{name.camelCase()}} - camelCase{{name.paramCase()}} - param-case{{#flag}}...{{/flag}} - conditional block{{^flag}}...{{/flag}} - inverted conditionalCreate test_bricks/new_brick/new_brick_test.dart:
import 'dart:io';
import 'package:mason/mason.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
void main() {
group('New Brick Tests', () {
late Directory tempDir;
setUp(() async {
tempDir = await Directory.systemTemp.createTemp('new_brick_test_');
});
tearDown(() async {
if (await tempDir.exists()) {
await tempDir.delete(recursive: true);
}
});
test('generates correct structure', () async {
final brick = Brick.path(path.join('..', '..', 'bricks', 'new_brick'));
final generator = await MasonGenerator.fromBrick(brick);
await generator.generate(
DirectoryGeneratorTarget(tempDir),
vars: {'name': 'test_name'},
);
// Verify generated files exist
final file = File(path.join(tempDir.path, 'test_name', 'pubspec.yaml'));
expect(await file.exists(), isTrue);
});
// Add more tests for different variable combinations
});
}
Add a new job to .github/workflows/brick-test.yml:
new-brick:
name: Test new_brick
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: flutter-actions/setup-flutter@v4
- name: Cache dependencies
uses: actions/cache@v5
with:
path: |
~/.pub-cache
.dart_tool
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
restore-keys: ${{ runner.os }}-pub-
- name: Install tools
run: dart pub global activate melos
- name: Prepare project
run: |
melos run prepare
mason get
- name: Test new_brick brick
run: dart run test_bricks/new_brick/new_brick_test.dart
Add to root mason.yaml:
bricks:
new_brick:
path: bricks/new_brick
Then run mason get to register.
When modifying a brick:
brick.yaml if adding/removing variables__brick__/test_bricks/brick_name/ to cover changesdart run test_bricks/brick_name/brick_name_test.dartbrick.yamlWhen removing a brick, update all three locations:
rm -rf bricks/brick_namerm -rf test_bricks/brick_name.github/workflows/brick-test.ymlmason.yaml# Register bricks
mason get
# Test a specific brick
dart run test_bricks/brick_name/brick_name_test.dart
# Test brick generation manually
mason make brick_name -o /tmp/test_output --var1=value1
| Brick | Purpose | Key Variables |
|---|---|---|
screen | Flutter screen with routing | name, folder, has_adaptive_scaffold |
widget | Reusable widget | name, type, folder |
simple_bloc | Basic BLoC package | name |
list_bloc | List management BLoC | name |
form_bloc | Form validation BLoC | name, field_names |
repository | Data repository | name |
api_client | API client package | package_name |
native_federation_plugin | Federated native plugin | name, package_prefix, support_* |
When creating/updating a brick:
brick.yaml has name, description, version, and varstest_bricks/brick_name/brick-test.ymlmason.yamlmason get to verify registrationxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience