Zum Hauptinhalt springen

Recipe: Discover Project Branding

For AI agents: Find and use project-level branding configuration.

πŸ€– Generated with Claude Code

⚠️ Not yet reviewed

Co-Authored-By: Claude (noreply@anthropic.com)

Goal​

Locate color/branding files in a project to use consistent colors and styles.

Projekt-Strukturen​

Variante A: Minimal (nur Styleguide-Farben)​

docs/
β”œβ”€β”€ _colors.d2 # Styleguide-Farben
└── *.d2 # Diagramme

Variante B: Mit Projekt-Farben​

docs/
β”œβ”€β”€ .branding/
β”‚ β”œβ”€β”€ _colors.d2 # Styleguide-Farben
β”‚ └── _project-colors.d2 # Projekt-spezifisch
└── *.d2

Discovery Script (Bash)​

# Find color files - checks both variants
find_colors() {
local git_root=$(git rev-parse --show-toplevel 2>/dev/null)
[ -z "$git_root" ] && echo "NOT_FOUND" && return 1

# Variante B: .branding/ Ordner
if [ -f "$git_root/docs/.branding/_colors.d2" ]; then
echo "$git_root/docs/.branding"
return 0
fi

# Variante A: flat
if [ -f "$git_root/docs/_colors.d2" ]; then
echo "$git_root/docs"
return 0
fi

echo "NOT_FOUND"
return 1
}

BRANDING=$(find_colors)

What's Inside​

FilePurposeUsed by
_colors.d2System-Farben aus tis-cca.documentation (kopiert)D2 diagrams
_project-colors.d2Projekt-spezifische Komponenten-FarbenD2 diagrams
metadata.yamlPDF branding (title color, fonts, headers)pandoc/pdf-publisher

Setup​

Variante A (minimal):

cp path/to/tis-cca.documentation/assets/colors/_colors.d2 docs/

Variante B (mit Projekt-Farben):

mkdir -p docs/.branding
cp path/to/tis-cca.documentation/assets/colors/_colors.d2 docs/.branding/

Using in D2 Diagrams​

# Variante A: flat (docs/_colors.d2)
...@_colors.d2

# Variante B: .branding/ (Quotes erforderlich!)
...@".branding/_colors.d2"
...@".branding/_project-colors.d2"

my-service: {
style.fill: ${soa-gfx} # defined in _project-colors.d2
}

Hinweis: D2 interpretiert . als Targeting-Operator. Pfade mit Punkt-Ordnern mΓΌssen in Quotes stehen.

Fallback​

If docs/.branding/ doesn't exist:

  • For diagrams: use system colors only, or create the folder
  • For PDFs: build without --meta flag (no branding)

Migration​

If project has docs/templates/metadata.yaml:

mkdir -p docs/.branding
mv docs/templates/metadata.yaml docs/.branding/
# Update any scripts referencing the old path