AgentSkillsCN

brand

请根据您的项目名称个性化定制此模板。

SKILL.md
--- frontmatter
name: brand
description: Personalize this template with your project name

Brand Skill

One-time personalization: replace template tokens (mysite, My Site, my-site) with your project's name throughout the codebase.

Usage

code
/brand

No subcommands — just run /brand and follow the prompts.

Conversation Flow

Step 1: Ask for the project name

Ask the user for their project's display name (e.g., "Acme Dashboard").

Step 2: Derive variants

From the display name, derive two other variants:

  • kebab: lowercase, spaces → hyphens (e.g., acme-dashboard) — replaces my-site
  • infra: lowercase, strip all non-alphanumeric characters (e.g., acmedashboard) — replaces mysite

Step 3: Confirm with the user

Show all three values and the list of files that will be modified. Let the user confirm or override any value.

code
Display: Acme Dashboard
Kebab:   acme-dashboard
Infra:   acmedashboard

Files that will be modified:
  - .env.example
  - .env (if exists)
  - docker-compose.yml
  - backend/pyproject.toml
  - backend/app/core/config.py
  - backend/app/main.py
  - frontend/package.json
  - frontend/app/layout.tsx
  - frontend/app/page.tsx
  - CLAUDE.md
  - .github/workflows/build_and_deploy_prod.yml

Step 4: Check git status

Run git status --short and warn if the working tree is dirty. Recommend committing or stashing first, but let the user proceed if they choose.

Step 5: Execute replacements

Order matters — replace most-specific tokens first to avoid partial-match corruption (my-site contains parts of mysite):

PassOld tokenNew tokenFiles
1my-site{kebab}backend/pyproject.toml, frontend/package.json
2My Site{display}CLAUDE.md, backend/pyproject.toml, backend/app/main.py, frontend/app/layout.tsx, frontend/app/page.tsx
3mysite{infra}.env.example, .env (if exists), docker-compose.yml, backend/app/core/config.py, backend/app/main.py, CLAUDE.md, .github/workflows/build_and_deploy_prod.yml

For each file in each pass, use the Read tool to read the file, then the Edit tool (with replace_all: true) to replace all occurrences of the old token with the new token. Skip files that don't contain the token.

Step 6: CLAUDE.md special changes

After the token replacements above, make these additional CLAUDE.md edits:

  1. Remove the "Forking This Template" section entirely (the ## Forking This Template heading and all content up to the next ## heading). This section describes the step the user just completed.

  2. Update the Docker Services table container names — they will already be updated by the mysite{infra} replacement in pass 3, so just verify.

  3. Update the psql command — it will already be updated by the mysite{infra} replacement, so just verify.

Step 7: Write brand.json

Write .claude/brand.json with the branding metadata:

json
{
  "display": "<display name>",
  "kebab": "<kebab name>",
  "infra": "<infra name>",
  "brandedFiles": [
    ".env.example",
    "docker-compose.yml",
    "backend/pyproject.toml",
    "backend/app/core/config.py",
    "backend/app/main.py",
    "frontend/package.json",
    "frontend/app/layout.tsx",
    "frontend/app/page.tsx",
    "CLAUDE.md",
    ".github/workflows/build_and_deploy_prod.yml"
  ]
}

Note: .env is intentionally excluded from brandedFiles since it's gitignored.

Step 8: Post-branding tasks

  1. Regenerate the backend lock file:

    bash
    cd backend && uv lock 2>&1 | tail -n 5
    
  2. Handle .env:

    • If .env doesn't exist, copy from the updated .env.example
    • If .env exists, it was already updated in pass 3

Step 9: Report summary

Show a summary of what was done:

code
Branding complete!

  Display: Acme Dashboard
  Kebab:   acme-dashboard
  Infra:   acmedashboard

  Modified X files, wrote .claude/brand.json
  Regenerated backend/uv.lock

Next steps:
  1. Review the changes: git diff
  2. Commit: git add -A && git commit -m "Brand as Acme Dashboard"
  3. If you forked from the template, run /upstream to set up upstream tracking

Important Notes

  • This skill should only be run once. If .claude/brand.json already exists, warn the user and ask if they want to re-brand (which will replace the current branded tokens).
  • Always read files before editing them.
  • Use replace_all: true on Edit calls to replace all occurrences in a file.
  • Protect the context window — use 2>&1 | tail -n 5 on lock file regeneration.