跳到正文
cccskills
免费在 GitHub 公开

bmad-init

Set up or update BMad-Method V6 in a project, detect older installations, fix a known output folder issue, and adjust Git ignore rules, with guidance on what to do next.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

Initialize or update BMad-Method (V6) in your project

查看安装方法

适用场景

  • Installing BMad-Method V6 in a project
  • Updating an existing V6 installation
  • Checking for an older V4 installation
  • Fixing output folders and Git ignore rules

包含的文件(1)

  • SKILL.md10.3 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

/bmad-init Command

This command initializes or updates BMad-Method (V6) in your project.

When this command is invoked:

  1. Check if _bmad/ directory exists to determine if BMad V6 is already installed
  2. Check for legacy V4 installations (.bmad-core or .bmad-method directories)
  3. Fresh install executes: npx bmad-method install --directory . --modules bmm --tools claude-code --communication-language English --document-output-language English --yes
  4. Existing install executes: npx bmad-method install --directory . --action quick-update --yes
  5. Fix installer bug: rename {output_folder} to _bmad-output (Beta known issue)
  6. Automatically update .gitignore (remove V4 entries, add V6 entries)
  7. Display installation results and prompt user for next steps

Implementation

const { execSync } = require('node:child_process')
const fs = require('node:fs')
const path = require('node:path')

// Legacy entries to clean from .gitignore
const LEGACY_GITIGNORE_ENTRIES = [
  '.bmad-core',
  '.bmad-method',
  '.claude/commands/BMad',
  '{output_folder}',  // v6.0.0-Beta.8 bug artifact
]

// V6 .gitignore entries
const V6_GITIGNORE_ENTRIES = [
  '_bmad/',
  '_bmad-output/',
]

// Fix installer bug: {output_folder} not resolved to _bmad-output (v6.0.0-Beta.8)
function fixOutputFolderBug(cwd) {
  const buggyPath = path.join(cwd, '{output_folder}')
  const correctPath = path.join(cwd, '_bmad-output')

  if (!fs.existsSync(buggyPath)) return false

  if (!fs.existsSync(correctPath)) {
    // _bmad-output doesn't exist, simply rename
    fs.renameSync(buggyPath, correctPath)
    console.log('   ✅ {output_folder} → _bmad-output/ (renamed)')
  } else {
    // _bmad-output already exists, merge subdirectories then delete
    const entries = fs.readdirSync(buggyPath, { withFileTypes: true })
    for (const entry of entries) {
      const src = path.join(buggyPath, entry.name)
      const dest = path.join(correctPath, entry.name)
      if (!fs.existsSync(dest)) {
        fs.renameSync(src, dest)
        console.log(`   ✅ Moved ${entry.name} → _bmad-output/`)
      }
    }
    fs.rmSync(buggyPath, { recursive: true, force: true })
    console.log('   ✅ Removed redundant {output_folder}/')
  }
  return true
}

function updateGitignore(cwd) {
  const gitignorePath = path.join(cwd, '.gitignore')
  let content = ''
  let exists = false

  if (fs.existsSync(gitignorePath)) {
    content = fs.readFileSync(gitignorePath, 'utf8')
    exists = true
  }

  const lines = content.split('\n')
  let changed = false

  // Remove V4 legacy entries
  const filtered = lines.filter(line => {
    const trimmed = line.trim()
    const isLegacy = LEGACY_GITIGNORE_ENTRIES.some(entry =>
      trimmed === entry || trimmed === entry + '/' || trimmed === '/' + entry
    )
    if (isLegacy) {
      console.log(`   🗑️  Removing legacy entry: ${trimmed}`)
      changed = true
    }
    return !isLegacy
  })

  // Add V6 entries
  const newEntries = []
  for (const entry of V6_GITIGNORE_ENTRIES) {
    const entryBase = entry.replace(/\/$/, '')
    const alreadyExists = filtered.some(line => {
      const trimmed = line.trim()
      return trimmed === entry || trimmed === entryBase || trimmed === '/' + entryBase
    })
    if (!alreadyExists) {
      newEntries.push(entry)
      console.log(`   ✅ Adding new entry: ${entry}`)
      changed = true
    }
  }

  if (!changed) {
    console.log('   ℹ️  .gitignore is up to date, no changes needed')
    return
  }

  // Build new content
  let result = filtered.join('\n')

  if (newEntries.length > 0) {
    // Ensure trailing newline, then add BMad section
    if (result.length > 0 && !result.endsWith('\n')) {
      result += '\n'
    }
    result += '\n# BMad Method V6\n'
    result += newEntries.join('\n') + '\n'
  }

  fs.writeFileSync(gitignorePath, result, 'utf8')
  console.log(`   📝 .gitignore ${exists ? 'updated' : 'created'}`)
}

async function initBmad() {
  const cwd = process.cwd()
  const bmadV6Path = path.join(cwd, '_bmad')
  const legacyCorePath = path.join(cwd, '.bmad-core')
  const legacyMethodPath = path.join(cwd, '.bmad-method')

  // Check for legacy V4 installation
  const hasLegacyCore = fs.existsSync(legacyCorePath)
  const hasLegacyMethod = fs.existsSync(legacyMethodPath)

  if (hasLegacyCore || hasLegacyMethod) {
    console.log('⚠️  Legacy BMad V4 installation detected:')
    if (hasLegacyCore) console.log('   • .bmad-core/ (V4 core directory)')
    if (hasLegacyMethod) console.log('   • .bmad-method/ (V4 method directory)')
    console.log('')
    console.log('📌 The V6 installer will handle legacy migration automatically. Follow the prompts during installation.')
    console.log('   Details: https://bmad-code-org.github.io/BMAD-METHOD/docs/how-to/upgrade-to-v6')
    console.log('')
  }

  // Check if V6 is already installed
  const hasV6 = fs.existsSync(bmadV6Path)

  // Build non-interactive install command
  let installCmd
  if (hasV6) {
    console.log('🔄 Existing BMad V6 installation detected, performing quick update...')
    console.log('')
    installCmd = [
      'npx bmad-method install',
      '--directory .',
      '--action quick-update',
      '--yes',
    ].join(' ')
  } else {
    console.log('🚀 Initializing BMad-Method V6...')
    console.log('')
    installCmd = [
      'npx bmad-method install',
      '--directory .',
      '--modules bmm',
      '--tools claude-code',
      '--communication-language English',
      '--document-output-language English',
      '--yes',
    ].join(' ')
  }

  // Execute installation
  try {
    console.log(`📋 Executing: ${installCmd}`)
    console.log('')
    execSync(installCmd, {
      stdio: 'inherit',
      cwd: cwd,
      shell: true
    })

    console.log('')
    console.log('✅ BMad-Method V6 installation/update complete!')
    console.log('')
    console.log('═══════════════════════════════════════════════════════════════')
    console.log('📌 IMPORTANT: Please restart your AI IDE to load BMad extensions')
    console.log('═══════════════════════════════════════════════════════════════')
    console.log('')
    // Fix {output_folder} bug (v6.0.0-Beta.8)
    console.log('🔧 Checking for known installer issues...')
    try {
      const fixed = fixOutputFolderBug(cwd)
      if (!fixed) console.log('   ℹ️  No fixes needed')
    } catch (err) {
      console.log(`   ⚠️  Failed to fix {output_folder}: ${err.message}`)
      console.log('   Please manually rename {output_folder}/ to _bmad-output/')
    }
    console.log('')

    console.log('📂 V6 Directory Structure:')
    console.log('   • _bmad/          — agents, workflows, tasks, and configuration')
    console.log('   • _bmad-output/   — generated artifact output directory')
    console.log('')

    // Automatically update .gitignore
    console.log('🔧 Updating .gitignore...')
    try {
      updateGitignore(cwd)
    } catch (err) {
      console.log('   ⚠️  Failed to automatically update .gitignore, please manually add _bmad/ and _bmad-output/')
    }
    console.log('')
    console.log('🚀 Quick Start:')
    console.log('   1. Restart your AI IDE')
    console.log('   2. Run /bmad-help for guidance and next step suggestions')
    console.log('   3. Type /bmad and use autocomplete to browse available commands')
    console.log('')
    console.log('💡 Common Workflows:')
    console.log('   • /bmad-help                      — Interactive help')
    console.log('   • /bmad-bmm-create-prd             — Create Product Requirements Document')
    console.log('   • /bmad-bmm-create-architecture     — Create Architecture Document')
    console.log('   • /bmad-bmm-create-epics-and-stories — Create Epics and User Stories')
    console.log('   • /bmad-bmm-sprint-planning         — Initialize Sprint Planning')
    console.log('   • /bmad-bmm-dev-story               — Implement User Story')

    // Legacy V4 IDE command cleanup reminder
    const legacyClaudeAgents = path.join(cwd, '.claude', 'commands', 'BMad', 'agents')
    const legacyClaudeTasks = path.join(cwd, '.claude', 'commands', 'BMad', 'tasks')
    if (fs.existsSync(legacyClaudeAgents) || fs.existsSync(legacyClaudeTasks)) {
      console.log('')
      console.log('⚠️  Legacy V4 IDE commands detected, consider removing manually:')
      if (fs.existsSync(legacyClaudeAgents)) console.log('   • .claude/commands/BMad/agents/')
      if (fs.existsSync(legacyClaudeTasks)) console.log('   • .claude/commands/BMad/tasks/')
      console.log('   New V6 commands are installed under .claude/commands/bmad/')
    }
  }
  catch (error) {
    console.error('❌ Installation failed:', error.message)
    console.log('')
    console.log('🛠️  Manual Installation Guide:')
    console.log('   1. Ensure Node.js 20+ is installed')
    console.log('   2. Non-interactive install:')
    console.log('      npx bmad-method install --directory . --modules bmm --tools claude-code --communication-language English --document-output-language English --yes')
    console.log('   3. Quick update existing installation:')
    console.log('      npx bmad-method install --directory . --action quick-update --yes')
    console.log('   4. Or interactive install:')
    console.log('      npx bmad-method install')
    console.log('')
    console.log('📖 Documentation:')
    console.log('   https://bmad-code-org.github.io/BMAD-METHOD/docs/how-to/install-bmad')
  }
}

// Execute initialization
initBmad()

Usage

Simply type in Claude Code:

/bmad-init

This command will:

  1. Detect current installation status (V6 / V4 legacy / not installed)
  2. Fresh install: non-interactively execute npx bmad-method install --directory . --modules bmm --tools claude-code --communication-language English --document-output-language English --yes
  3. Existing install: execute npx bmad-method install --directory . --action quick-update --yes
  4. Fix {output_folder} → _bmad-output installer bug
  5. Automatically update .gitignore (clean up legacy entries, add V6 entries)
  6. Provide next step suggestions

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

bmad-init

免费

Install or update BMad-Method (V6) in a project after checking existing installations. The skill also fixes a known output-folder issue, updates Git ignore rules, and provides next steps for using the installed workflows.

中文简介正在准备中。当前显示英语简介。

  • Set up BMad-Method (V6) for Claude Code
  • Run a quick update on an existing V6 installation
  • Check for an older V4 installation before setup
UfoMiao/zcf60812026年8月31日 更新

feat

免费

Guide new feature work from requirements and planning through revisions and implementation. Create Markdown plans with acceptance criteria, track progress, and ensure frontend tasks have a UI design before development begins.

中文简介正在准备中。当前显示英语简介。

  • Turn a feature idea into an implementation plan
  • Revise a plan based on feedback
  • Start implementation from an agreed plan
UfoMiao/zcf60812026年8月31日 更新

feat

免费

Turn feature requests into documented plans, revise them through discussion, and carry out implementation with progress tracking. Frontend work includes checking for a UI design and arranging design work when needed.

中文简介正在准备中。当前显示英语简介。

  • Turning a feature idea into a development plan
  • Revising a plan after feedback
  • Implementing tasks from an agreed plan
UfoMiao/zcf60812026年8月31日 更新

Find Git branches that have been merged or inactive for a chosen period. Preview cleanup candidates, exclude protected branches, and delete local or remote branches using a selected base branch and confirmation options.

中文简介正在准备中。当前显示英语简介。

  • Find merged branches to clean up
  • Review branches with no recent commits
  • Clean up branches merged into a release
UfoMiao/zcf60812026年8月31日 更新

Find merged or inactive Git branches, preview cleanup candidates, and delete selected branches after confirmation. Choose a comparison branch, protect important branches with configurable rules, and optionally include remote branches.

中文简介正在准备中。当前显示英语简介。

  • Previewing branch cleanup candidates
  • Removing branches already merged into a release branch
  • Finding branches with no recent commits
UfoMiao/zcf60812026年8月31日 更新

Use Git changes to generate Conventional Commits messages, a format that labels each change by type, and create commits. The skill suggests splitting unrelated changes and supports explicit scope, type, sign-off, and amendments to the previous commit.

中文简介正在准备中。当前显示英语简介。

  • Generate a commit message from staged changes
  • Split unrelated changes into separate commits
  • Specify a commit type and scope
UfoMiao/zcf60812026年8月31日 更新

查看 UfoMiao 的全部技能

报告此技能的问题