---
description: Create a SmartStack command extension project
argument-hint: <name> [description]
---

# Create Command Extension

Scaffold a complete SmartStack **command** extension project.

## What is a Command?

A command is a slash command that users invoke in Claude Code:
- `/my-command <args>` - Executes the command with arguments
- Defined in markdown with YAML frontmatter
- Contains workflow, rules, and execution logic

## Arguments

Parse from `$ARGUMENTS`:
- **name** (required): Command name in kebab-case
- **description** (optional): What the command does

## Project Structure

```
smartstack-{name}/
├── package.json
├── tsconfig.json
├── tsup.config.ts
├── README.md
├── .gitignore
├── src/
│   └── index.ts
└── templates/
    └── commands/
        └── {name}.md          # Main command template
```

## Generated Command Template

Create `templates/commands/{name}.md`:

```markdown
---
description: {description}
argument-hint: <task-description>
---

# {PascalCaseName}

{description}

## Workflow

### 1. UNDERSTAND
- Parse user arguments: `$ARGUMENTS`
- Identify the task scope
- Gather necessary context

### 2. ANALYZE
- Explore relevant codebase areas
- Identify patterns and constraints
- Document findings

### 3. PLAN
- Design the approach
- Consider edge cases
- Validate against requirements

### 4. EXECUTE
- Implement step by step
- Follow existing patterns
- Write clean code

### 5. VERIFY
- Test the implementation
- Ensure no regressions
- Validate completeness

## Execution Rules

1. **ULTRA THINK** before each phase
2. Use parallel agents when beneficial
3. Document all decisions
4. **MINIMAL CHANGES**: Only what's needed
5. Test before declaring complete

## Agent Usage

For exploration, launch agents:
- `explore-codebase` - Find relevant files
- `websearch` - Research solutions

## Priority

Understanding > Correctness > Speed

---

User: $ARGUMENTS
```

## Generated Files

### package.json

```json
{
  "name": "@smartstack/{name}",
  "version": "1.0.0",
  "description": "{description}",
  "private": false,
  "type": "module",
  "main": "./dist/index.js",
  "files": ["dist", "templates"],
  "scripts": {
    "build": "tsup",
    "dev": "tsup --watch"
  },
  "peerDependencies": {
    "@atlashub/smartstack-cli": ">=1.0.0"
  }
}
```

### src/index.ts

```typescript
import * as path from 'path';
import * as fs from 'fs';

export function getTemplatesPath(): string {
  return path.join(__dirname, '..', 'templates');
}

export async function install(targetDir: string): Promise<void> {
  const src = path.join(getTemplatesPath(), 'commands');
  const dest = path.join(targetDir, 'commands');
  // Copy command templates
}

export const metadata = {
  name: '{name}',
  version: '1.0.0',
  description: '{description}',
  type: 'command'
};
```

## Workflow

1. Parse name and description from `$ARGUMENTS`
2. Validate name is kebab-case
3. Create project directory
4. Generate all files using Write tool
5. Display success message with next steps

## Validation

- Name must match: `^[a-z][a-z0-9-]*$`
- Directory must not exist
- Description should be meaningful

---

User: $ARGUMENTS
