スキル一覧に戻る
tarrragon

style-guardian

by tarrragon

1🍴 0📅 2026年1月19日
GitHubで見るManusで実行

SKILL.md


name: style-guardian description: "Style Guardian - Unified Design System Enforcement Tool. Use for: (1) Preventing hardcoded styles (colors, spacing, typography), (2) Preventing hardcoded text (i18n violations), (3) Guiding unified configuration usage, (4) Detecting and fixing style violations"

Style Guardian - Unified Design System Enforcement

Core Principles

Design Philosophy: Flat Design 2.0 + Monochrome System

PrincipleDescriptionSource
MinimalismClean, uncluttered layoutsFlat Design
2D StylingSimple, flat shapes without 3D effectsFlat Design
Subtle ShadowsShadows hint at interactivity (Flat 2.0)Material Design
MonochromePrimarily use different saturations of blueProject Design Spec
Three-Color SystemBlue (primary) + Green (positive) + Orange (negative)Project Design Spec

Key Files

FilePurpose
lib/core/ui/ui_config.dartCore style configuration system
lib/core/ui/flat_design_config.dartFlat design component configuration
lib/core/ui/responsive_config.dartResponsive layout configuration
lib/app/theme.dartApplication theme (uses UIColors)
docs/ui_design_specification.mdUI design specification document

Color System

Primary Color (Blue, 90% usage)

HardcodedUIColorsPurposeHex
Colors.blueUIColors.primaryPrimary buttons#2196F3
Color(0xFF2196F3)UIColors.primaryPrimary buttons#2196F3
Colors.blue[50]UIColors.primaryLightestBackground blocks#E3F2FD
Colors.blue[100]UIColors.primaryLightSecondary blocks#BBDEFB
Colors.blue[300]UIColors.primaryMediumInteractive elements#64B5F6
Colors.blue[700]UIColors.primaryDarkSelected states#1976D2
Colors.blue[900]UIColors.primaryDarkestEmphasis text#0D47A1

Positive Color (Green, 5% usage)

HardcodedUIColorsPurpose
Colors.greenUIColors.positiveSuccess, confirmation
Colors.green[100]UIColors.positiveLightSuccess backgrounds
Colors.green[700]UIColors.positiveDarkSuccess emphasis

Negative Color (Orange, 5% usage)

HardcodedUIColorsPurpose
Colors.orangeUIColors.negativeWarning, error
Colors.amberUIColors.negativeWarning, caution
Colors.redUIColors.negativeProject does NOT use red

Background Colors

HardcodedUIColorsPurpose
Colors.whiteUIColors.surfaceLightCard backgrounds
Colors.grey[50]UIColors.backgroundLightPage backgrounds
Colors.grey[600]UIColors.onSurfaceMutedMuted text

Spacing System (4dp Grid)

SizedBox Spacing

HardcodedUISpacingResponsive
SizedBox(height: 4)SizedBox(height: UISpacing.xxs).h suffix
SizedBox(height: 8)SizedBox(height: UISpacing.xs).h suffix
SizedBox(height: 12)SizedBox(height: UISpacing.sm).h suffix
SizedBox(height: 16)SizedBox(height: UISpacing.md).h suffix
SizedBox(height: 24)SizedBox(height: UISpacing.lg).h suffix
SizedBox(height: 32)SizedBox(height: UISpacing.xl).h suffix
SizedBox(width: 8)SizedBox(width: UISpacing.xs).w suffix

EdgeInsets Padding

HardcodedUISpacing
EdgeInsets.all(4)EdgeInsets.all(UISpacing.xxs)
EdgeInsets.all(8)EdgeInsets.all(UISpacing.xs)
EdgeInsets.all(16)EdgeInsets.all(UISpacing.md)
EdgeInsets.symmetric(horizontal: 16)EdgeInsets.symmetric(horizontal: UISpacing.md)
EdgeInsets.symmetric(vertical: 8)EdgeInsets.symmetric(vertical: UISpacing.xs)

Typography System

Font Sizes

HardcodedUIFontSizesPurpose
fontSize: 10UIFontSizes.overlineOverline text
fontSize: 12UIFontSizes.bodySmallSmall body text
fontSize: 14UIFontSizes.bodyMediumStandard body text
fontSize: 16UIFontSizes.bodyLargeLarge body text
fontSize: 18UIFontSizes.titleMediumMedium titles
fontSize: 20UIFontSizes.titleLargeLarge titles
fontSize: 24UIFontSizes.headline3Headlines

Responsive Font Sizes

Use .rsp suffix for responsive scaling:

// Correct
TextStyle(fontSize: UIFontSizes.bodyMedium)  // Already includes .rsp

// Incorrect
TextStyle(fontSize: 14)
TextStyle(fontSize: 14.sp)  // Manual scaling

Border Radius System

HardcodedUIBorderRadius
BorderRadius.circular(4)BorderRadius.circular(UIBorderRadius.xs)
BorderRadius.circular(8)BorderRadius.circular(UIBorderRadius.sm)
BorderRadius.circular(12)BorderRadius.circular(UIBorderRadius.md)
BorderRadius.circular(16)BorderRadius.circular(UIBorderRadius.lg)
BorderRadius.circular(20)BorderRadius.circular(UIBorderRadius.xl)
BorderRadius.circular(999)BorderRadius.circular(UIBorderRadius.circular)

Internationalization (i18n)

Correct Usage

// Correct - use l10n
Text(context.l10n!.libraryTitle)
Text(context.l10n!.selectedCount(count, total))
Text(context.l10n!.errorMessage)

// Incorrect - hardcoded strings
Text('My Library')
Text('$count items selected')
Text('An error occurred')

Adding New Translation Keys

  1. Edit lib/l10n/app_en.arb:

    {
      "newKey": "New text value",
      "@newKey": {
        "description": "Description of the text"
      }
    }
    
  2. Run flutter gen-l10n

  3. Use in code:

    Text(context.l10n!.newKey)
    

Supported Languages

  • en (English)
  • en_US (English - US)
  • zh_TW (Traditional Chinese)
  • zh_CN (Simplified Chinese)
  • zh (Chinese)
  • es (Spanish)
  • fr (French)
  • hi (Hindi)
  • ja (Japanese)
  • ko (Korean)

Common Violations and Fixes

Violation 1: Hardcoded Colors

// Violation
Container(color: Colors.blue)
Container(color: Color(0xFF2196F3))

// Fix
Container(color: UIColors.primary)

Violation 2: Hardcoded Spacing

// Violation
SizedBox(height: 16)
Padding(padding: EdgeInsets.all(8))

// Fix
SizedBox(height: UISpacing.md)
Padding(padding: EdgeInsets.all(UISpacing.xs))

Violation 3: Hardcoded Font Size

// Violation
TextStyle(fontSize: 14)

// Fix
TextStyle(fontSize: UIFontSizes.bodyMedium)

Violation 4: Hardcoded Border Radius

// Violation
BorderRadius.circular(8)

// Fix
BorderRadius.circular(UIBorderRadius.sm)

Violation 5: Hardcoded Text

// Violation
Text('My Library')
AppBar(title: Text('Settings'))

// Fix
Text(context.l10n!.libraryTitle)
AppBar(title: Text(context.l10n!.settingsTitle))

Violation 6: ViewModel Hardcoded User Messages

Scope: lib/presentation/**/viewmodel.dart, lib/presentation/**_viewmodel.dart

Detection Pattern: String literals assigned to error/message state properties

// Violation - Hardcoded user messages in ViewModel
state = state.copyWith(errorMessage: 'Invalid file format');
state = state.copyWith(errorMessage: '網路連線失敗');
_errorMessage = 'Something went wrong';

// Fix - Use i18n or ErrorHandler
state = state.copyWith(errorMessage: context.l10n!.invalidFileFormat);
state = state.copyWith(errorMessage: ErrorHandler.getUserMessage(exception));

Allowed Exceptions:

  • e.toString() for unknown system exceptions
  • String interpolation with i18n: context.l10n!.errorWithCode(code)

Related: FLUTTER.md - ViewModel 層使用者訊息規範


Detection Script Usage

Manual Scan

# Scan entire project
uv run .claude/skills/style-guardian/scripts/style_checker.py scan lib/

# Scan specific directory
uv run .claude/skills/style-guardian/scripts/style_checker.py scan lib/presentation/

# Generate report
uv run .claude/skills/style-guardian/scripts/style_checker.py report

Hook Integration

The style checker is integrated into PostEdit Hook:

  • Automatically scans edited files in lib/presentation/
  • Reports violations in hook output
  • Suggests fixes based on this guide

Project Files

Reference Files (in this SKILL)

External Resources


Quick Reference Card

Import Statement

import 'package:book_overview_app/core/ui/ui_config.dart';

Common Replacements

TypeHardcodedConfiguration
ColorColors.blueUIColors.primary
SuccessColors.greenUIColors.positive
WarningColors.orangeUIColors.negative
Spacing16UISpacing.md
Font14UIFontSizes.bodyMedium
Radius8UIBorderRadius.sm
Text'My Library'context.l10n!.libraryTitle

Responsive Suffixes

SuffixPurposeExample
.wWidth scaling16.w
.hHeight scaling16.h
.rspFont scaling14.rsp
.rRadius scaling8.r

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です