Auto-Skill Generation
Relevant source files
The following files were used as context for generating this wiki page:
Auto-Skill Generation is a system within the Autohand CLI designed to analyze project structures and automatically create specialized AI agent workflows known as "Skills." By detecting programming languages, frameworks, and architectural patterns, the system generates tailored SKILL.md files that provide high-quality, actionable instructions for AI coding assistants. Sources: src/skills/autoSkill.ts:7-10, README.md:104-106
The system operates by scanning a workspace root, identifying key technical markers (such as package.json for Node.js or requirements.txt for Python), and utilizing a Large Language Model (LLM) to synthesize modular instruction packages. These skills extend the agent's capabilities beyond general coding to project-specific tasks like test generation, API documentation, or refactoring guides. Sources: src/skills/autoSkill.ts:114-118, src/skills/types.ts:10-13
Architecture and Components
The Auto-Skill Generation process relies on three primary components: the ProjectAnalyzer, the LLM-driven generation logic, and the SkillsRegistry for storage and activation. Sources: src/skills/autoSkill.ts:114, src/skills/SkillsRegistry.ts:31
Project Analysis Engine
The ProjectAnalyzer class performs a deep scan of the project root to populate a ProjectAnalysis data structure. It detects environmental factors like the operating system platform, version control status (Git), and CI/CD configurations. Sources: src/skills/autoSkill.ts:114-142
| Component | Description |
|---|---|
| Language Detection | Identifies TypeScript, JavaScript, Python, Rust, and Go based on configuration files (e.g., Cargo.toml, go.mod). |
| Framework Detection | Scans dependencies for specialized libraries like React, Next.js, Flask, or Express. |
| Pattern Recognition | Detects project types such as Monorepos, CLI tools, APIs, and Dockerized environments. |
| Package Managers | Identifies usage of npm, yarn, pnpm, bun, pip, cargo, or go. |
Sources: src/skills/autoSkill.ts:114-263
The Generation Workflow
The following diagram illustrates the sequence from project analysis to skill persistence.
The workflow ensures that generated skills are immediately available for use within the current session. Sources: src/skills/autoSkill.ts:468-525, tests/skills/autoSkill.spec.ts:303-335
Implementation Details
Available Tools Categorization
Skills are generated with an awareness of "Allowed Tools," which restricts or empowers the agent based on the task. These tools are categorized into file operations, git operations, commands, dependencies, memory, and planning. Sources: src/skills/autoSkill.ts:18-77
Sources: src/skills/autoSkill.ts:21-75
Skill Format and Frontmatter
Every generated skill is stored as a Markdown file with a YAML frontmatter block. This metadata is critical for the SkillsRegistry to manage the skill. Sources: src/skills/types.ts:36-50, src/skills/autoSkill.ts:446-455
---
name: typescript-test-generator
description: Generates Vitest suites for TypeScript modules.
allowed-tools: read_file write_file run_command
---
# Typescript Test Generator
...body content...
Sources: src/skills/autoSkill.ts:450-464, src/commands/skills-new.ts:205-225
Validation and Constraints
To maintain registry integrity, skills must adhere to specific validation rules managed by the validateSkillFrontmatter utility. Sources: src/skills/types.ts:106-138
| Constraint | Value | Description |
|---|---|---|
| NAME_MAX_LENGTH | 64 | Maximum characters for skill name. |
| NAME_PATTERN | /^[a-z0-9-]+$/ | Lowercase alphanumeric with hyphens only. |
| DESC_MAX_LENGTH | 1024 | Maximum characters for description. |
| COMPATIBILITY_MAX | 500 | Maximum characters for compatibility notes. |
Sources: src/skills/types.ts:100-105
Interactive Skill Creation
While --auto-skill provides automatic generation, the /skills new command provides an interactive LLM-driven wizard. This process includes a similarity check using Jaccard Similarity to prevent the creation of duplicate skills. Sources: src/commands/skills-new.ts:31-110, src/skills/SkillsRegistry.ts:364-375
Summary
Auto-Skill Generation streamlines the onboarding of the AI agent into new codebases by automatically codifying project-specific standards. By combining static file analysis with LLM reasoning, the system ensures the agent utilizes the correct tools (e.g., bun vs npm) and follows the project's established testing and documentation patterns. Sources: src/skills/autoSkill.ts:468-475, src/skills/autoSkill.ts:522-525