Packmind create command

From PackmindHub/packmind · View interactive version

Packmind create command is an AI agent skill from the GitHub repository PackmindHub/packmind. Guide for creating reusable commands via the Packmind CLI. This skill should be used when users want to create a new command that captures multi-step workflows, recipes, or task automation for distribution to GitLab Duo.

How to use this skill

Skill file

Command Creator

This skill provides a complete walkthrough for creating reusable commands via the Packmind CLI.

About Commands

Commands are structured, multi-step workflows that capture repeatable tasks, recipes, and automation patterns. They help teams standardize common development workflows and enable GitLab Duo to execute complex tasks consistently.

What Commands Provide

  1. Multi-step workflows - Structured sequences of actions to accomplish a task
  2. Context validation - Checkpoints to ensure requirements are met before execution
  3. When-to-use guidance - Clear scenarios describing when the command is applicable
  4. Code snippets - Optional examples demonstrating each step's implementation

Command Structure

Every command is drafted as a markdown file with this structure:

# Command Name

## Summary

What the command does, why it's useful, and when it's relevant.

## When to Use

- Scenario 1 when this command applies
- Scenario 2 when this command applies

## Context Validation Checkpoints

- Question 1 to validate before proceeding?
- Question 2 to ensure context is clear?

## Steps

### Step Name

What this step does and how to implement it.

\`\`\`typescript
// Optional code example
\`\`\`

### Another Step

Description without code.

Naming Guidelines

The # Title heading is the display name shown in indexes and dashboards. The slug is auto-generated from it — never write the slug yourself.

Format: Use Title Case with spaces — natural language, not a slug.

Examples:

Markdown Structure Requirements

The CLI validates the command after conversion. Ensure the markdown file meets these requirements:

Prerequisites

Before creating a command, verify that packmind-cli is available:

Check if packmind-cli is installed:

packmind-cli --version

If not available, install it:

npm install -g @packmind/cli

Then login to Packmind:

packmind-cli login

Command Creation Process

Step 1: Understanding the Command's Purpose

Skip this step only when the command's workflow and steps are already clearly defined.

To create an effective command, clearly understand:

  1. What workflow does this command automate?
  1. When should this command be triggered?

Example clarifying questions:

Step 2: Design Command in Markdown

Transform the understanding from Step 1 into a complete markdown draft with steps and validation checkpoints.

Draft Creation
  1. Create a draft markdown file in .packmind/commands/_drafts/ (create the folder if missing) using filename <slug>.md (lowercase with hyphens)
  2. Draft structure:

This draft file is the only file created during drafting — no separate files are needed.

Step Writing Guidelines
  1. Clear name - Use a concise title (e.g., "Setup Dependencies", "Create Test File")
  2. Actionable description - Explain what to do and how to implement it
  3. One concept per step - Focus on a single action
  4. Optional code snippet - Include when it clarifies the implementation

Good descriptions:

Bad descriptions:

Context Validation Checkpoints

Questions that verify requirements before execution:

Good checkpoints:

Bad checkpoints:

When-To-Use Scenarios

Define specific, actionable scenarios:

Good scenarios:

Bad scenarios:

Step 3: Review Before Submission

Before running the CLI command, you MUST get explicit user approval:

  1. Show the user the complete command content in a formatted preview:
  1. Provide the file path to the markdown file (.packmind/commands/_drafts/<slug>.md) so users can open and edit it directly if needed.
  1. Ask: "Here is the command that will be created on Packmind. The draft file is at \<path>\ if you want to review or edit it. Do you approve?"
  1. Wait for explicit user confirmation before proceeding to Step 4.
  1. If the user requests changes, go back to earlier steps to make adjustments.

Step 4: Confirm and Submit

  1. Re-read the markdown file from disk to capture any user edits.
  1. Compare with the original content you created in Step 2.
  1. If changes were detected:
  1. If no changes: Proceed directly to submission.
  1. Convert the markdown to JSON using these conversion rules:
  1. Pipe the JSON directly to the CLI via stdin using a heredoc (no intermediate file needed):
packmind-cli commands create --origin-skill packmind-create-command <<'EOF'
{"name":"...","summary":"...","whenToUse":[...],"contextValidationCheckpoints":[...],"steps":[...]}
EOF

Expected output on success:

packmind-cli Command "Your Command Name" created successfully (ID: <uuid>)
View it in the webapp: <url>
Troubleshooting

"Not logged in" error:

packmind-cli login

"Failed to resolve global space" error:

Validation errors:

Step 5: Cleanup

After the command is successfully created, delete the draft markdown file in .packmind/commands/_drafts/.

Only clean up on success - if the CLI command fails, keep the files so the user can retry.

Step 6: Offer to Add to Package

After successful creation, check if the command fits an existing package:

  1. Run packmind-cli install --list to get available packages
  2. If no packages exist, skip this step silently and end the workflow
  3. Analyze the created command's name and summary against each package's name and description
  4. If a package is a clear semantic fit (the command's domain/technology aligns with the package's purpose):
  1. If no clear fit is found, skip silently (do not mention packages)
  2. If user chooses to add:

Complete Example

Here's a complete example creating a command for setting up a new API endpoint:

File: .packmind/commands/_drafts/create-api-endpoint.md

# Create API Endpoint

## Summary

Set up a new REST API endpoint with controller, service, and tests following the hexagonal architecture pattern.

## When to Use

- When adding a new REST endpoint to the API
- When implementing a new backend feature that exposes HTTP endpoints

## Context Validation Checkpoints

- Is the HTTP method and path defined (e.g., POST /users)?
- Is the request/response payload structure specified?
- Is the associated use case or business logic identified?

## Steps

### Create Controller

Create the controller file in the \`infra/http/controllers/\` directory with the endpoint handler and input validation.

\`\`\`typescript
@Controller('users')
export class UsersController {
  @Post()
  async create(@Body() dto: CreateUserDTO) {
    return this.useCase.execute(dto);
  }
}
\`\`\`

### Create Use Case

Create the use case in the \`application/useCases/\` directory implementing the business logic.

### Create Tests

Create unit tests for the controller and use case in their respective \`.spec.ts\` files following the Arrange-Act-Assert pattern.

### Register in Module

Add the controller and use case to the appropriate NestJS module's \`controllers\` and \`providers\` arrays.

Creating the command (piped via stdin):

packmind-cli commands create --origin-skill packmind-create-command <<'EOF'
{"name":"Create API Endpoint","summary":"Set up a new REST API endpoint...","whenToUse":[...],"contextValidationCheckpoints":[...],"steps":[...]}
EOF

Quick Reference

| Section | Required | Description |

|---|---|---|

| # Title | Yes | Title Case, action-verb prefix, 2–5 words |

| ## Summary | Yes | What, why, and when (one sentence) |

| ## When to Use | Yes | Bullet list, at least one scenario |

| ## Context Validation Checkpoints | Yes | Bullet list, at least one checkpoint |

| ## Steps | Yes | Contains step subsections |

| ### Step Name | Yes (≥1) | Step title |

| Step body (paragraph) | Yes | Implementation details |

| Step body (code block) | No | Markdown code block with language |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.