feat: add create command for scaffolding new skills

- Add skillkit create command to scaffold new skills with proper structure
- Generate SKILL.md template with frontmatter following Agent Skills spec
- Support optional directories (references, scripts, assets)
- Validate skill names (lowercase alphanumeric with hyphens)
- Update README with create command documentation
This commit is contained in:
Rohit Ghumare
2026-01-21 11:59:54 +00:00
parent acec136e81
commit eaeb7ef221
4 changed files with 151 additions and 0 deletions
+18
View File
@@ -65,6 +65,9 @@ skillkit install gitlab:owner/repo
# Install specific skills (CI/CD friendly)
skillkit install owner/repo --skills=pdf,xlsx,docx
# Create a new skill
skillkit create my-skill
# Sync skills to your agent config
skillkit sync
@@ -201,6 +204,19 @@ skillkit validate ./my-skill # Validate single skill
skillkit validate ./skills --all # Validate all skills in directory
```
### `skillkit create <skill-name>`
Create a new skill with proper structure and template.
```bash
skillkit create my-skill # Basic skill
skillkit create my-skill --full # Include all directories (references, scripts, assets)
skillkit create my-skill --scripts # Include scripts directory
skillkit create my-skill --references # Include references directory
skillkit create my-skill --assets # Include assets directory
skillkit create my-skill --dir ./skills # Create in specific directory
```
## Supported Agents
| Agent | Config File | Project Path | Global Path |
@@ -225,6 +241,8 @@ skillkit validate ./skills --all # Validate all skills in directory
## Creating Skills
Use `skillkit create <name>` to scaffold a new skill, or create manually:
A skill is a directory with a `SKILL.md` file:
```
+2
View File
@@ -11,6 +11,7 @@ import {
RemoveCommand,
InitCommand,
ValidateCommand,
CreateCommand,
} from './commands/index.js';
const cli = new Cli({
@@ -32,5 +33,6 @@ cli.register(UpdateCommand);
cli.register(RemoveCommand);
cli.register(InitCommand);
cli.register(ValidateCommand);
cli.register(CreateCommand);
cli.runExit(process.argv.slice(2));
+130
View File
@@ -0,0 +1,130 @@
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import chalk from 'chalk';
import { Command, Option } from 'clipanion';
export class CreateCommand extends Command {
static override paths = [['create'], ['new']];
static override usage = Command.Usage({
description: 'Create a new skill with proper structure',
examples: [
['Create a new skill', '$0 create my-skill'],
['Create with all optional directories', '$0 create my-skill --full'],
['Create with scripts directory', '$0 create my-skill --scripts'],
],
});
name = Option.String({ required: true, name: 'skill-name' });
full = Option.Boolean('--full,-f', false, {
description: 'Include all optional directories (references, scripts, assets)',
});
scripts = Option.Boolean('--scripts', false, {
description: 'Include scripts directory',
});
references = Option.Boolean('--references', false, {
description: 'Include references directory',
});
assets = Option.Boolean('--assets', false, {
description: 'Include assets directory',
});
directory = Option.String('--dir,-d', {
description: 'Parent directory to create skill in (default: current directory)',
});
async execute(): Promise<number> {
const skillName = this.name.toLowerCase();
if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(skillName)) {
console.error(chalk.red('Invalid skill name'));
console.error(chalk.dim('Must be lowercase alphanumeric with hyphens (e.g., my-skill)'));
return 1;
}
const parentDir = this.directory || process.cwd();
const skillDir = join(parentDir, skillName);
if (existsSync(skillDir)) {
console.error(chalk.red(`Directory already exists: ${skillDir}`));
return 1;
}
try {
mkdirSync(skillDir, { recursive: true });
const skillMd = generateSkillMd(skillName);
writeFileSync(join(skillDir, 'SKILL.md'), skillMd);
if (this.full || this.references) {
const refsDir = join(skillDir, 'references');
mkdirSync(refsDir);
writeFileSync(join(refsDir, '.gitkeep'), '');
}
if (this.full || this.scripts) {
const scriptsDir = join(skillDir, 'scripts');
mkdirSync(scriptsDir);
writeFileSync(join(scriptsDir, '.gitkeep'), '');
}
if (this.full || this.assets) {
const assetsDir = join(skillDir, 'assets');
mkdirSync(assetsDir);
writeFileSync(join(assetsDir, '.gitkeep'), '');
}
console.log(chalk.green(`Created skill: ${skillName}`));
console.log();
console.log(chalk.dim('Structure:'));
console.log(chalk.dim(` ${skillDir}/`));
console.log(chalk.dim(' ├── SKILL.md'));
if (this.full || this.references) console.log(chalk.dim(' ├── references/'));
if (this.full || this.scripts) console.log(chalk.dim(' ├── scripts/'));
if (this.full || this.assets) console.log(chalk.dim(' └── assets/'));
console.log();
console.log(chalk.cyan('Next steps:'));
console.log(chalk.dim(' 1. Edit SKILL.md with your instructions'));
console.log(chalk.dim(' 2. Validate: skillkit validate ' + skillDir));
console.log(chalk.dim(' 3. Test: skillkit read ' + skillName));
return 0;
} catch (error) {
console.error(chalk.red('Failed to create skill'));
console.error(chalk.dim(error instanceof Error ? error.message : String(error)));
return 1;
}
}
}
function generateSkillMd(name: string): string {
const title = name
.split('-')
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
return `---
name: ${name}
description: Describe what this skill does and when to use it. Include trigger keywords.
---
# ${title}
Instructions for the AI agent on how to use this skill.
## When to Use
- Scenario 1
- Scenario 2
## Steps
1. First step
2. Second step
3. Third step
`;
}
+1
View File
@@ -7,3 +7,4 @@ export { UpdateCommand } from './update.js';
export { RemoveCommand } from './remove.js';
export { InitCommand } from './init.js';
export { ValidateCommand } from './validate.js';
export { CreateCommand } from './create.js';