---
name: skill-authoring
description: Write, audit, and fix agent skills so they load in every harness and survive review. Use when creating a new SKILL.md, when a skill is not being invoked or not discovered, when frontmatter fails validation, or before publishing a skills repo to npm or skills.sh.
license: MIT
compatibility: Requires Node.js 18+ for the validator (npx skills add --list). Everything else is plain file editing and works in any harness.
metadata:
  author: software-factory
  version: "1.1"
allowed-tools: Bash(npx skills *) Bash(node:*) Bash(git:*)
title: skill-authoring
canonical_url: https://skilld.dev/gh/aditya-deokar/software-factory/skill-authoring
last_updated: 2026-10-30T17:45:51.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install aditya-deokar/software-factory/skill-authoring`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/skill-authoring`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/aditya-deokar/software-factory/skill-authoring) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/skill-authoring`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/skill-authoring --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/skill-authoring --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Skill authoring

A skill is a folder with a `SKILL.md` inside it. The folder name and the
frontmatter `name` must match, and the description decides whether the agent
ever loads the file. Most broken skills are broken in the description, not the
body.

## The description is the whole product

The agent sees only `name` and `description` until it decides to load the
skill. The body might be perfect and never get read. Write the description as a
trigger list, not a summary.

Bad, because it describes the skill instead of the moment it applies:

```yaml
description: A comprehensive guide to service layer architecture patterns.
```

Good, because every clause is a situation the agent can recognise:

```yaml
description: >
  Use when multiple workflows duplicate the same operational logic, when
  deciding what belongs in actions vs shared services, or when refactoring
  repeated operational blocks across domain flows.
```

Rules that hold up:

- Lead with "Use when". The agent is pattern-matching on situations.
- Name the words a person would actually type. If someone says "screenshot
  comparison", that phrase belongs in the description verbatim.
- Say what it does not cover, when the boundary is easy to get wrong.
- Keep it under roughly 500 characters. Longer descriptions get skimmed.

## Frontmatter fields

Required by the spec:

| Field | Notes |
|---|---|
| `name` | Lowercase, hyphens. Must equal the folder name. |
| `description` | Trigger-focused. See above. |

Worth adding on anything you publish:

| Field | Notes |
|---|---|
| `license` | SPDX id. Vendored skills keep the upstream id, not yours. |
| `compatibility` | Every binary, runtime, credential, and OS assumption. |
| `metadata.author` | Who owns it. |
| `metadata.version` | Bump on every behaviour change. |
| `allowed-tools` | Narrow the blast radius. Claude Code and most others honour it. |
| `metadata.internal` | `true` hides it from discovery until `INSTALL_INTERNAL_SKILLS=1`. |
| `metadata.signals` | Friction keys this skill owns, as `"[key-a, key-b]"`. Ties the skill to the numbers that say whether it works. |

`compatibility` is the field people skip and then field bug reports about.
Write it as if the reader has none of your tools installed, because they do not.

## Layout that gets discovered

The `skills` CLI walks a fixed set of container directories up to three levels
deep. Put skills in `skills/<name>/SKILL.md` at the repo root. That layout is
discovered by every agent the CLI supports.

```
repo/
  skills/
    my-skill/
      SKILL.md          # required
      LICENSE           # if vendored, or if the skill differs from the repo
      scripts/          # executables the skill calls
      references/       # long material the body links to
```

If no skills turn up in a known container the CLI falls back to a recursive
search. Do not rely on that. It is slower and the fallback has bitten people
who nested skills under `examples/` or `docs/`.

## Keep the body short and link out

The body is loaded into context every time the skill fires. Long bodies cost
tokens on every invocation and get skimmed. Anything over roughly 200 lines
should move to `references/` and be linked from the body.

Good candidates for `references/`: API schemas, GraphQL queries, error-code
tables, long worked examples, provider-specific setup.

Keep in the body: the decision rules, the execution order, the traps.

## Paths inside a skill

Never write `./scripts/foo.sh` in a skill body. Once installed, the skill lives
in `.claude/skills/<name>/` or `~/.claude/skills/<name>/` or one of fifty other
agent directories, and `./` resolves against the user's repo instead. Tell the
agent to resolve the skill directory first, then call scripts through it.

Scripts must be executable and should work on Linux, macOS, and Windows, or say
plainly in `compatibility` which ones they do not support.

## Audit checklist

Run this before publishing a skill or when one is not firing.

1. `npx skills add . --list` from the repo root. Every skill you expect should
   be listed. A missing skill means bad frontmatter or a layout the walker
   never reaches.
2. Folder name equals frontmatter `name`.
3. Frontmatter is valid YAML. A colon inside an unquoted description is the
   usual culprit. Use `>` block scalars for anything with punctuation.
4. Description leads with a trigger and names real user phrasing.
5. `compatibility` lists every external binary, credential, and OS constraint.
6. No bare relative paths to scripts in the body.
7. Body is under ~200 lines, or the overflow lives in `references/`.
8. Scripts referenced from the body actually exist and are executable.
9. `allowed-tools` covers everything the body tells the agent to run, and
   nothing more.
10. Vendored skills keep their upstream `LICENSE` file and name the source in
    `metadata.vendored-from`.

## Skills that measure themselves

In a repo that runs the factory, a skill is not finished when it reads well.
It is finished when the correction it exists to prevent stops recurring.

- **Name what it owns.** Each skill that prevents a failure lists the
  friction keys for that failure in `metadata.signals`, and each key in
  `.factory/friction-patterns.json` names its owner. The linter checks both
  directions.
- **No key, no rule.** Before adding a rule to a skill, find or add the
  friction pattern it should reduce, with `match` and `miss` examples. A
  rule whose effect nobody can count cannot be judged, and it never gets
  removed.
- **Rewrite once, then build a mechanism.** If a rule was already reworded
  once and the count did not move, more words will not help either. Replace
  it with a script, a check, or a hook, and delete the prose in the same
  change.

### Reviewing a proposal from the loop

`skill-feedback-loop` opens PRs labeled `factory:skill-loop`. Review them
like code, with these questions:

1. Do the samples really show the pattern? Regexes misfire. A wrong match is
   a pattern fix, not a skill fix.
2. Does the diagnosis quote the skill text that failed?
3. Is it one skill and the smallest change? Two changes in one PR cannot be
   measured separately.
4. Does it delete what it replaces?
5. Is the expected movement a number with a baseline?

Merge it, or close it with the reason. Either way, set the proposal file's
`status` so the loop's cooldown and follow-up stay accurate.

## When a skill does not fire

Work down this list in order.

- Confirm it is installed where the agent looks: `npx skills list`.
- Confirm the frontmatter parses. Broken YAML makes the skill invisible with no
  error shown to the user.
- Reread the description as the agent sees it. If it describes capability
  instead of a triggering situation, rewrite it and try again.
- Check for a second skill with an overlapping description. Two skills
  competing for the same trigger means neither fires reliably. Narrow one.
- As a last resort, invoke it explicitly by name to confirm the body works.
  That separates a discovery problem from a content problem.
