Synthèse automatique
Ce guide permet de créer, modifier ou supprimer des briques Mason avec des tests associés et une intégration CI.
Points forts
- Structure claire avec séparation entre briques, tests et CI.
- Utilisation de variables Mustache pour la génération dynamique.
- Processus complet incluant la création de tests unitaires.
- Ajout automatisé aux workflows CI parallélisés.
Limites
- Nécessite une connaissance préalable de Mason et de son écosystème.
- La configuration CI est spécifique à GitHub Actions.
- Les tests dépendent de la structure exacte des fichiers générés.
Utilisez cette compétence lorsque vous devez créer ou maintenir des briques Mason dans un projet Dart/Flutter structuré.
Évitez cette compétence si vous ne travaillez pas avec Mason ou si le projet n'a pas de structure de briques standardisée.
Analyse de sécurité
SûrThe skill provides a guide for developing Mason bricks, including file system commands like mkdir and rm. The commands are specific to project directories and not destructive in a malicious sense. No external network calls, no exfiltration, no obfuscated payloads.
Aucun point d'attention détecté
Comment cette analyse est faiteExemples
Create a new Mason brick named 'my_widget' that generates a Flutter widget with a customizable name and optional styling.Update the 'my_widget' brick to add a new variable 'color' of type string and regenerate the template files accordingly.Add a test for the 'my_widget' brick that checks the generated structure and variables.name: template-mason-brick description: Guide for creating, updating, or removing Mason bricks with corresponding tests and CI workflow (project)
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
mkdir -p bricks/new_brick/__brick__
Step 2: Create brick.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:
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:
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:
bricks:
new_brick:
path: bricks/new_brick
Then run mason get to register.
Updating an Existing Brick
When modifying a brick:
- Update
brick.yamlif adding/removing variables - Update template files in
__brick__/ - Update tests in
test_bricks/brick_name/to cover changes - Run test locally:
dart run test_bricks/brick_name/brick_name_test.dart - Increment version in
brick.yaml
Removing a Brick
When removing a brick, update all three locations:
- Remove brick directory:
rm -rf bricks/brick_name - Remove test directory:
rm -rf test_bricks/brick_name - Remove workflow job from
.github/workflows/brick-test.yml - Remove from
mason.yaml - Update CLAUDE.md if the brick was documented
Testing Locally
# 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.yamlhas 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 getto verify registration - [ ] Run test locally before committing
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/mason-brick-development-mm5t8adt/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/mason-brick-development-mm5t8adt' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/mason-brick-development-mm5t8adt/download' --output '.skill-downloads/mason-brick-development-mm5t8adt/SKILL.md.part' && mv '.skill-downloads/mason-brick-development-mm5t8adt/SKILL.md.part' '.skill-downloads/mason-brick-development-mm5t8adt/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.
Claude Code
test -f '.skill-downloads/mason-brick-development-mm5t8adt/SKILL.md' && test -s '.skill-downloads/mason-brick-development-mm5t8adt/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/template-mason-brick' && cp -R '.skill-downloads/mason-brick-development-mm5t8adt' '.claude/skills/template-mason-brick'OpenSkills
OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.
Installation officielle d’OpenSkillsopenskills install './.skill-downloads/mason-brick-development-mm5t8adt'openskills read 'mason-brick-development-mm5t8adt'La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.
Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.
openskills syncMode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/mason-brick-development-mm5t8adt/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Bonnes pratiques React Hook Form
Developpement
Maîtrisez React Hook Form : évitez les anti-patterns, gérez les abonnements, et traitez correctement reset, dirty state et entrées contrôlées.
Migration Emotion vers Mantine
Developpement
Migrer les styled-components Emotion vers des composants Mantine avec style props et modules CSS. Pour convertir .styled.tsx ou supprimer les imports @emotion.
Détecteur de dérive de périmètre
Developpement
Analyse les diffs git par rapport à une intention pour détecter la dérive de périmètre, fichiers non liés et PR trop larges, puis suggère de garder, diviser ou justifier.