template-mason-brick
Guide for creating, updating, or removing Mason bricks with corresponding tests and CI workflow (project)
Best use case
template-mason-brick is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Guide for creating, updating, or removing Mason bricks with corresponding tests and CI workflow (project)
Teams using template-mason-brick should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/template-mason-brick/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How template-mason-brick Compares
| Feature / Agent | template-mason-brick | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Guide for creating, updating, or removing Mason bricks with corresponding tests and CI workflow (project)
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Mason Brick Development Skill
This skill guides the creation, modification, and removal of Mason bricks, ensuring test coverage and CI workflow integration.
## When to Use
Trigger this skill when:
- Creating a new Mason brick template
- Updating an existing brick's structure or variables
- Removing a brick from the project
- User asks to "create a brick", "add a mason template", "update brick", or "remove brick"
## Project Structure
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
```
## Creating a New Brick
### Step 1: Create Brick Directory
```bash
mkdir -p bricks/new_brick/__brick__
```
### Step 2: Create brick.yaml
```yaml
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
```
### Step 3: Create Template Files
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 conditional
### Step 4: Create Brick Test
Create `test_bricks/new_brick/new_brick_test.dart`:
```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
});
}
```
### Step 5: Add Workflow Job
Add a new job to `.github/workflows/brick-test.yml`:
```yaml
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
```
### Step 6: Register Brick
Add to root `mason.yaml`:
```yaml
bricks:
new_brick:
path: bricks/new_brick
```
Then run `mason get` to register.
## Updating an Existing Brick
When modifying a brick:
1. Update `brick.yaml` if adding/removing variables
2. Update template files in `__brick__/`
3. **Update tests** in `test_bricks/brick_name/` to cover changes
4. Run test locally: `dart run test_bricks/brick_name/brick_name_test.dart`
5. Increment version in `brick.yaml`
## Removing a Brick
When removing a brick, update all three locations:
1. Remove brick directory: `rm -rf bricks/brick_name`
2. Remove test directory: `rm -rf test_bricks/brick_name`
3. Remove workflow job from `.github/workflows/brick-test.yml`
4. Remove from `mason.yaml`
5. Update CLAUDE.md if the brick was documented
## Testing Locally
```bash
# 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
```
## Existing Bricks Reference
| 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_*` |
## Checklist
When creating/updating a brick:
- [ ] `brick.yaml` has name, description, version, and vars
- [ ] Template files use correct Mustache syntax
- [ ] Test file exists in `test_bricks/brick_name/`
- [ ] Tests cover main generation paths
- [ ] Workflow job added/updated in `brick-test.yml`
- [ ] Brick registered in `mason.yaml`
- [ ] Run `mason get` to verify registration
- [ ] Run test locally before committingRelated Skills
templated-automation
Automate Templated tasks via Rube MCP (Composio). Always search tools first for current schemas.
prompt-template-builder
Creates reusable prompt templates with strict output contracts, style rules, few-shot examples, and do/don't guidelines. Provides system/user prompt files, variable placeholders, output formatting instructions, and quality criteria. Use when building "prompt templates", "LLM prompts", "AI system prompts", or "prompt engineering".
make-skill-template
Create new Agent Skills for GitHub Copilot from prompts or by duplicating this template. Use when asked to "create a skill", "make a new skill", "scaffold a skill", or when building specialized AI capabilities with bundled resources for OnoCoro. Generates SKILL.md files with proper frontmatter, directory structure, and optional scripts/references/assets folders.
incident-runbook-templates
Create structured incident response runbooks with step-by-step procedures, escalation paths, and recovery actions. Use when building runbooks, responding to incidents, or establishing incident resp...
defi-protocol-templates
Implement DeFi protocols with production-ready templates for staking, AMMs, governance, and lending systems. Use when building decentralized finance applications or smart contract protocols.
adding-templates
Use when adding new stacks, libraries, or project addons to create-faster CLI tool - covers META entries, template creation, and testing for all addon types
session-template
Apply task-specific templates to AI session plans using ai-update-plan. Use when starting a new task to load appropriate plan structure (feature, bugfix, refactor, documentation, security).
ai-feature-template
Create new AI-powered features using xAI Grok. Use when user mentions "new AI feature", "add Grok", "create prompt", "AI analysis", or "generate with AI".
documentation-templates
Documentation templates and structure guidelines. README, API docs, code comments, and AI-friendly documentation.
acc-troubleshooting-template
Generates troubleshooting guides and FAQ sections for PHP projects. Creates problem-solution documentation.
acc-readme-template
Generates README.md files for PHP projects. Creates structured documentation with badges, installation, usage, and examples.
acc-getting-started-template
Generates Getting Started guides for PHP projects. Creates step-by-step tutorials for first-time users.