Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 72 additions & 5 deletions docs/skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ For skills **without** scripts (binary-backed skills like `k8s-incident-triage`)
│ LLM Tool Registry │
├─────────────────┬───────────────────────────────┤
│ Builtins │ web_search, http_request │
│ Skill Tools │ tavily_research, ... │ ← auto-registered from scripts
│ Skill Tools │ tavily_research, codegen_* │ ← auto-registered from scripts
│ read_skill │ load any SKILL.md on demand │
│ cli_execute │ run approved binaries │
├─────────────────┴───────────────────────────────┤
Expand Down Expand Up @@ -143,10 +143,18 @@ forge skills list --tags kubernetes,incident-response

## Built-in Skills

| Skill | Description | Scripts |
|-------|-------------|---------|
| `tavily-research` | Deep multi-source research via Tavily API | `tavily-research.sh`, `tavily-research-poll.sh` |
| `k8s-incident-triage` | Read-only Kubernetes incident triage using kubectl | — (binary-backed) |
| Skill | Category | Description | Scripts |
|-------|----------|-------------|---------|
| `github` | — | Create issues, PRs, and query repositories | — (binary-backed) |
| `weather` | — | Get weather data for a location | — (binary-backed) |
| `tavily-search` | — | Search the web using Tavily AI search API | `tavily-search.sh` |
| `tavily-research` | — | Deep multi-source research via Tavily API | `tavily-research.sh`, `tavily-research-poll.sh` |
| `k8s-incident-triage` | sre | Read-only Kubernetes incident triage using kubectl | — (binary-backed) |
| `code-review` | developer | AI-powered code review for diffs and files | `code-review-diff.sh`, `code-review-file.sh` |
| `code-review-standards` | developer | Initialize and manage code review standards | — (template-based) |
| `code-review-github` | developer | Post code review results to GitHub PRs | — (binary-backed) |
| `codegen-react` | developer | Scaffold and iterate on Vite + React apps | `codegen-react-scaffold.sh`, `codegen-react-read.sh`, `codegen-react-write.sh`, `codegen-react-run.sh` |
| `codegen-html` | developer | Scaffold standalone Preact + HTM apps (zero dependencies) | `codegen-html-scaffold.sh`, `codegen-html-read.sh`, `codegen-html-write.sh` |

### Tavily Research Skill

Expand Down Expand Up @@ -210,6 +218,65 @@ The skill accepts two input modes:

Requires: `kubectl`, optional `KUBECONFIG`, `K8S_API_DOMAIN`, `DEFAULT_NAMESPACE` environment variables.

### Codegen React Skill

The `codegen-react` skill scaffolds and iterates on **Vite + React** applications with Tailwind CSS:

```bash
forge skills add codegen-react
```

This registers four tools:

| Tool | Purpose | Behavior |
|------|---------|----------|
| `codegen_react_scaffold` | Create a new project | Generates package.json, Vite config, React components with Tailwind CSS and Forge dark theme |
| `codegen_react_run` | Start the dev server | Runs `npm install` + `npm run dev`, auto-opens browser, returns server URL and PID |
| `codegen_react_read` | Read project files | Returns file content or directory listing (excludes `node_modules/`, `.git/`) |
| `codegen_react_write` | Write/update files | Creates or updates files with path traversal prevention; Vite hot-reloads automatically |

**Iteration workflow:**

1. Scaffold the project with `codegen_react_scaffold`
2. Start the dev server with `codegen_react_run` — installs deps, opens browser
3. Read/write files with `codegen_react_read` / `codegen_react_write` — Vite hot-reloads on save
4. Repeat step 3 to iterate on the UI

**Scaffold output:** `package.json` (React 19, Vite 6), `vite.config.js`, `index.html` (with Tailwind CDN), `src/main.jsx`, `src/App.jsx` (Tailwind utility classes), `src/App.css`, `.gitignore`.

**Safety:** Output directories must be under `$HOME` or `/tmp`. Path traversal (`..`, absolute paths) is rejected. Non-empty directories require `force: true`.

Requires: `node`, `npx`, `jq`. Egress: `registry.npmjs.org`, `cdn.jsdelivr.net`, `cdn.tailwindcss.com`.

### Codegen HTML Skill

The `codegen-html` skill scaffolds standalone **Preact + HTM** applications with zero local dependencies:

```bash
forge skills add codegen-html
```

This registers three tools:

| Tool | Purpose | Behavior |
|------|---------|----------|
| `codegen_html_scaffold` | Create a new project | Generates HTML with Preact + HTM via CDN and Tailwind CSS; supports single-file and multi-file modes |
| `codegen_html_read` | Read project files | Returns file content or directory listing |
| `codegen_html_write` | Write/update files | Creates or updates files with path traversal prevention |

**Two scaffold modes:**

| Mode | Files | Use Case |
|------|-------|----------|
| `single-file` | One `index.html` with inline JS | Quick prototypes, shareable demos |
| `multi-file` | `index.html`, `app.js`, `components/Counter.js` | Larger apps with component separation |

**Key differences from codegen-react:** No Node.js required. No build step. No `npm install`. Just open `index.html` in a browser. Uses `class` (not `className`) since HTM maps directly to DOM attributes.

**Safety:** Same restrictions as codegen-react — output under `$HOME` or `/tmp`, path traversal prevention, `force: true` for non-empty directories.

Requires: `jq`. Egress: `cdn.tailwindcss.com`, `esm.sh`.

## Skill Instructions in System Prompt

Forge injects the **full body** of each skill's SKILL.md into the LLM system prompt. This means all detailed operational instructions — triage steps, detection heuristics, output structure, safety constraints — are directly available in the LLM's context without requiring an extra `read_skill` tool call.
Expand Down
2 changes: 1 addition & 1 deletion forge-skills/local/embedded/code-review-github/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: code-review-github
category: dev
category: developer
tags:
- code-review
- github
Expand Down
2 changes: 1 addition & 1 deletion forge-skills/local/embedded/code-review-standards/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: code-review-standards
category: dev
category: developer
tags:
- code-review
- standards
Expand Down
2 changes: 1 addition & 1 deletion forge-skills/local/embedded/code-review/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: code-review
category: dev
category: developer
tags:
- code-review
- diff
Expand Down
190 changes: 190 additions & 0 deletions forge-skills/local/embedded/codegen-html/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
---
name: codegen-html
category: developer
tags:
- code-generation
- frontend
- html
- preact
- ui
- zero-dependency
description: Scaffold and iterate on standalone Preact + HTM applications with zero build dependencies
metadata:
forge:
requires:
bins:
- jq
env:
required: []
one_of: []
optional: []
egress_domains:
- cdn.tailwindcss.com
- esm.sh
timeout_hint: 60
---

# Codegen HTML Skill

Scaffold and iteratively build standalone HTML applications using Preact + HTM via CDN. Zero local dependencies — no Node.js, no npm, no build step. Just open the HTML file in a browser.

## Quick Start

```bash
# Scaffold a single-file app
./scripts/codegen-html-scaffold.sh '{"project_name": "my-app", "output_dir": "/tmp/my-app", "mode": "single-file"}'

# Scaffold a multi-file app
./scripts/codegen-html-scaffold.sh '{"project_name": "my-app", "output_dir": "/tmp/my-app", "mode": "multi-file"}'

# Read a file or list the project
./scripts/codegen-html-read.sh '{"project_dir": "/tmp/my-app", "file_path": "."}'

# Write/update a file
./scripts/codegen-html-write.sh '{"project_dir": "/tmp/my-app", "file_path": "index.html", "content": "..."}'
```

## CRITICAL: Scaffold Conventions (DO NOT VIOLATE)

These rules prevent runtime errors:

1. **Use `class` (not `className`)** — HTM maps directly to DOM attributes
2. **Use Tailwind CSS utility classes** for all styling (loaded via CDN in `index.html`)
3. **Do NOT create `<style>` blocks or `.css` files** — use Tailwind classes instead
4. **Keep Preact/HTM imports unchanged** — do not change CDN URLs or versions
5. **Use named exports** for components: `export function ComponentName() {}`

## Code Style Guide

- Use **Preact** with **HTM** (tagged template literals instead of JSX)
- Use `class` (not `className`) — HTM maps directly to DOM attributes
- Template literal syntax: `` html`<div class="app">${content}</div>` ``
- Use `useState`, `useEffect`, `useRef` from Preact hooks
- Components are plain functions returning `` html`...` `` template literals
- All imports via CDN (`esm.sh`), pinned to specific versions
- Use **Tailwind CSS utility classes** — the CDN is pre-loaded in `index.html`
- Forge dark theme colors: `bg-zinc-950` (bg), `bg-zinc-900` (cards), `border-zinc-800` (borders), `text-zinc-200` (text), `text-zinc-400` (muted), `bg-indigo-500` (accent)

## Tailwind CSS Reference

Tailwind is loaded via CDN. Use utility classes directly in `class` attributes:

- **Layout:** `flex`, `grid`, `gap-4`, `max-w-4xl`, `mx-auto`, `px-6`, `py-12`
- **Colors:** `bg-zinc-950`, `bg-zinc-900`, `text-zinc-200`, `text-zinc-400`, `bg-indigo-500`
- **Borders:** `border`, `border-zinc-800`, `rounded-lg`, `shadow-lg`
- **Typography:** `text-3xl`, `font-bold`, `text-center`, `font-mono`
- **Interactive:** `hover:bg-indigo-400`, `transition-colors`, `cursor-pointer`

Do NOT write custom CSS when Tailwind utilities exist.

## Safety Constraints

- Output directory must be under `$HOME` or `/tmp`
- Non-empty directories require `force: true` to overwrite
- Path traversal (`..`, absolute paths) is rejected in read/write operations
- No local tooling required — files can be opened directly in a browser

## Iteration Workflow

1. **Scaffold** the project with `codegen_html_scaffold`
2. **Read** files to understand current state with `codegen_html_read`
3. **Write** updated files with `codegen_html_write`
4. Repeat steps 2-3 to iterate on the UI

After scaffolding, the user can simply open `index.html` in a browser. No install or build step needed.

## When to Use

Use `codegen-html` when the user wants:
- A quick UI prototype with no setup
- A single HTML file they can share or open directly
- Zero-dependency frontend (no Node.js required)
- Simple interactive apps, dashboards, or demos

For full React apps with build tooling and npm packages, use `codegen-react` instead.

## Tool: codegen_html_scaffold

Create a new Preact + HTM project with Forge-themed dark UI.

**Input:**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| project_name | string | yes | Name for the project |
| output_dir | string | yes | Absolute path for the project directory |
| title | string | no | Page title. Default: project_name |
| mode | string | no | `single-file` (one index.html) or `multi-file` (separate JS/CSS). Default: `single-file` |
| force | boolean | no | Overwrite non-empty directory. Default: false |

**Output:** JSON object with status, output_dir, mode, and list of files created.

### Response Format

```json
{
"status": "created",
"output_dir": "/tmp/my-app",
"project_name": "my-app",
"mode": "single-file",
"files": ["index.html"]
}
```

## Tool: codegen_html_read

Read a file or list the project directory.

**Input:**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| project_dir | string | yes | Absolute path to the project directory |
| file_path | string | yes | Relative path to read, or `"."` for directory listing |

**Output:** JSON object with path, content (or listing), size, and modified timestamp.

### Response Format (file)

```json
{
"path": "index.html",
"content": "<!DOCTYPE html>...",
"size": 2048,
"modified": "2025-01-15T10:30:00Z"
}
```

### Response Format (directory listing)

```json
{
"path": ".",
"type": "directory",
"files": ["index.html", "app.js", "styles.css"]
}
```

## Tool: codegen_html_write

Write or update a file in the project.

**Input:**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| project_dir | string | yes | Absolute path to the project directory |
| file_path | string | yes | Relative path to write |
| content | string | yes | Complete file content |

**Output:** JSON object with path, action (created/updated), and size.

### Response Format

```json
{
"path": "index.html",
"action": "updated",
"size": 2150
}
```
Loading
Loading