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
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fstack",
"description": "Federico Mastrini's agent skills for everyday software engineering work.",
"version": "0.17.2",
"version": "0.18.0",
"author": {
"name": "Federico Mastrini",
"url": "https://fedemas.dev"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
**A short stack of agent skills for everyday software engineering work.**

[![Claude Code plugin](https://img.shields.io/badge/Claude%20Code-plugin-D97757?style=flat-square)](https://www.fedemas.dev/fstack)
[![Version](https://img.shields.io/badge/version-0.17.2-B4A7E5?style=flat-square)](.claude-plugin/plugin.json)
[![Version](https://img.shields.io/badge/version-0.18.0-B4A7E5?style=flat-square)](.claude-plugin/plugin.json)
[![License: MIT](https://img.shields.io/badge/license-MIT-93D3BB?style=flat-square)](LICENSE)

</div>
Expand All @@ -33,6 +33,7 @@ fstack turns everyday engineering workflows into skills your coding agent runs e
| UX | [ux-brainstorm](skills/ux-brainstorm/SKILL.md) · [ux-stress-test](skills/ux-stress-test/SKILL.md) · [design-system](skills/design-system/SKILL.md) |
| Building | [implement](skills/implement/SKILL.md) · [implement-issue](skills/implement-issue/SKILL.md) · [test-driven-development](skills/test-driven-development/SKILL.md) |
| Code quality | [code-review](skills/code-review/SKILL.md) · [receiving-code-review](skills/receiving-code-review/SKILL.md) · [comment-sweep](skills/comment-sweep/SKILL.md) |
| Agent instructions | [writing-for-agents](skills/writing-for-agents/SKILL.md) |
| Pull requests | [pr-open](skills/pr-open/SKILL.md) · [pr-ship](skills/pr-ship/SKILL.md) · [pr-babysit](skills/pr-babysit/SKILL.md) · [resolve-merge-conflicts](skills/resolve-merge-conflicts/SKILL.md) |

## 📦 Install
Expand Down
2 changes: 1 addition & 1 deletion gemini-extension.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "fstack",
"version": "0.17.2",
"version": "0.18.0",
"description": "Federico Mastrini's agent skills for everyday software engineering work."
}
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "fstack",
"version": "0.17.2",
"version": "0.18.0",
"description": "Federico Mastrini's agent skills for everyday software engineering work.",
"author": {
"name": "Federico Mastrini",
Expand Down
60 changes: 60 additions & 0 deletions skills/writing-for-agents/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
name: writing-for-agents
description: Use when writing, editing, or reviewing text an AI agent will read and act on, such as a SKILL.md, an AGENTS.md or CLAUDE.md, a system prompt, a subagent brief, or a tool description, or when the user asks why an agent ignores its instructions or wants one of those files trimmed or tightened.
---

# Writing for agents

Your reader is a capable model. It already knows most of what you could tell it, it reads every line, and it tries to obey each one. So every line costs twice: the tokens to read it and the effort to follow it. Instructions an agent didn't need still make it reason longer and do worse.

## 1. Keep only lines that change behavior

Test each line: would the agent get this wrong without it? Keep the line only when the answer is yes. Lines that pass:

- facts it can't find on its own: conventions, environment quirks, decisions and the reasons behind them, places where the project departs from the usual default;
- exact commands, names, and limits for fragile steps;
- what done looks like, and when to stop.

Cut the rest:

- What the agent can discover: directory tours, file lists, what the code already says. Point to `src/billing/charge.ts:42` instead of copying code; copies go stale.
- Advice it already follows ("handle errors appropriately", "follow best practices"). Write the specific pattern, edge case, or convention it stood in for, or delete it.
- Anything tied to a date or a passing phase ("until the migration ends"). State the rule as it stands now; move retired guidance into an "Old patterns" section only if agents still meet the old code.

Facts that contradict a reasonable assumption ("tests need `TZ=UTC`", "the staging DB is shared with QA") are usually the most valuable lines in the file. Collect them under a Gotchas heading, and add one each time you correct an agent.

## 2. Phrase each rule

- **Say what to do.** "Write flowing prose paragraphs" works better than "don't use markdown": a prohibition names the thing to avoid and leaves the agent guessing at the alternative. Keep a negative only for a safety rule with no positive form.
- **Give the reason for any rule that isn't obvious.** The agent generalizes from the reason. "No ellipses" covers one case; "no ellipses, because a text-to-speech engine reads this aloud" also covers the cases you didn't list.
- **Write in a calm voice.** Capitals and "CRITICAL: you MUST" make current models apply the rule everywhere, including where it doesn't fit. Write "Use X when Y", and replace blanket fallbacks ("if in doubt, use X") with the real condition.
- **Match strictness to the cost of a mistake.** A fragile or irreversible step gets the exact command, to run as written. A step with many good answers gets the goal and a heuristic. Set the level for each part separately: rigid if-else trees break on the first unlisted case, and vague guidance guides nothing.
- **One term per concept, one default per choice.** Pick "field" and keep it; a switch to "box" reads as a different thing. Name one recommended tool and one fallback for when it fails, rather than a menu.
- **One source of truth.** Rules that contradict each other make the agent spend its reasoning reconciling them, and it may pick the wrong one. Merge duplicates, and when two rules can collide, say which wins.
- **Exact names.** Fully qualified tool names (`server:tool`), forward-slash paths, and the dependencies the text assumes are installed.

## 3. Shape the document

- Put background, instructions, examples, and inputs under separate headings or XML tags, so the agent can tell a rule from data.
- Teach a pattern with 3 to 5 short, varied examples rather than a long list of edge-case rules, each in an `<example>` tag.
- For an output format, give a template and say whether it is strict or a starting point.
- Keep the main file short (a SKILL.md well under 500 lines) and move detail into files linked straight from it, one level deep, each with its trigger: "read `references/api-errors.md` when the API returns a non-200 status". Agents often read only the top of a long file, so a reference over 100 lines opens with a table of contents.
- Put long input documents first and the task or question last.

## 4. Per kind of text

- **Skill description**: the agent picks among many skills from this text alone. It says when to use the skill: the situations and the words users actually type, with specific key terms. How the skill works belongs in the body. Stay under 1,024 characters, and single-quote the value when it contains ` #`, which YAML reads as the start of a comment.
- **Subagent brief**: the subagent knows only what the brief says. Give the goal and why it matters, what is already ruled out, the sources and tools to use, the scope it must stay inside, the return format, and how much effort the task deserves (a lookup takes a few tool calls). Vague briefs produce duplicated work and gaps.
- **AGENTS.md or CLAUDE.md**: write it by hand; generated ones lowered task success and raised cost. Name the commands and tools you want used, since agents reach for whatever the file mentions, and mention only those.
- **Tool description**: write it for a new hire: what the tool does, when to pick it over its siblings, unambiguous parameter names (`user_id`, not `user`), and a shared prefix for related tools. Error messages say what to fix and show a valid input.
- **Anything that lets an agent act**: say when to stop and hand back, which actions run freely (local and reversible), and which wait for confirmation (destructive, or touching shared systems).

## 5. Check before you hand it over

1. Read it as the agent would: two rules that conflict, a step without a done condition, a term used two ways.
2. Search it for capitals used for emphasis, "never" and "don't" rules, generic advice, rules said twice, and dates. Rewrite each as in step 2.
3. Ask of every remaining line whether the agent would get the task wrong without it, and cut each line that fails.

For a skill or prompt that will run often, test it as well. Run the task without it first to see what the agent actually gets wrong, write about three scenarios, and write the least text that fixes them. Then read the agent's step-by-step transcript, not only its final output, to find lines it ignored or over-applied. For a skill description, try about 20 requests, half of them near-misses that should not trigger it.

When you rewrite someone else's text, keep the meaning of every rule you keep. End your reply with a short list of what you cut and why, and of anything you added or loosened, so they can restore a line that mattered or reject one they never asked for.
3 changes: 3 additions & 0 deletions skills/writing-for-agents/agents/openai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface:
display_name: "Writing for Agents"
short_description: "Write prompts, skills, and briefs agents follow"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
schema_version: "1.1"
name: briefs-research-subagent
expected_outcome: |
The run writes a brief and does not do the search itself. The brief states the goal and why
(find every caller of /v1/payments so the endpoint can be switched off), names both sources
(services/ code and logs/gateway/ access logs), says what to return in a set format (each
calling service with the evidence: file and line, or log lines and counts), keeps the subagent
read-only, and says when it is done. It is written in a calm voice without capitals for emphasis.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The brief states the goal and the reason: find every service that still calls /v1/payments so the endpoint can be switched off.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The brief names both sources the subagent should use: the code in services/ and the gateway access logs in logs/gateway/.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The brief specifies a return format, listing per calling service the evidence (such as file and line for code, and matching log lines or request counts for logs).
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The brief sets a scope limit: the subagent only reads and searches, and changes no code, config, or the endpoint itself.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The brief says when the subagent is done or how far to go (for example, once every service in services/ and the 30 days of logs are checked), or how much effort the task deserves.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The brief contains no capital letters for emphasis (IMPORTANT, MUST, NEVER, CRITICAL in capitals).
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
tags: [writing-for-agents]
max_turns: 30
timeout_seconds: 600
allowed_tools: [Read, Glob, Grep, Skill, Write, Edit, Bash]
---

i want to hand this off to a subagent: find out which of our services still call the deprecated /v1/payments endpoint, so we can switch it off at the end of the month. the code is in services/ (about 40 services, mixed go and typescript) and the api gateway access logs for the last 30 days are in logs/gateway/. write the brief i should give it. just the brief, don't run it
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
schema_version: "1.1"
name: drafts-release-skill
expected_outcome: |
The run writes skills/release/SKILL.md. Its frontmatter description says when to use the skill
with the phrases users type (cut a release, ship a version, publish the new version) and leaves
the steps to the body. The body gives the exact commands, stops and reports when pnpm test or
pnpm build fails, and asks the user to confirm before the irreversible steps (pushing the tag and
running pnpm publish), saying why. It is short, written in a calm voice without capitals for
emphasis, and carries no generic advice.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

skills/release/SKILL.md has YAML frontmatter with a name and a description, and the description says when to use the skill using phrases like "cut a release", "ship 2.4.0", or "publish the new version".
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The SKILL.md description gives the trigger situations and phrases only; it does not summarize the release steps (bump, test, tag, publish, post).
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The SKILL.md has the agent ask the user to confirm before running `pnpm publish` and says why (a publish cannot be undone).
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The SKILL.md has the agent stop and report, without tagging or publishing, when `pnpm test` or `pnpm build` fails.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The SKILL.md gives the exact commands for the fragile steps: `pnpm test`, `pnpm build`, the tag (vX.Y.Z), pushing the commit and tag, and `pnpm publish --access public`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The SKILL.md contains no capital letters for emphasis (IMPORTANT, MUST, NEVER, ALWAYS, CRITICAL in capitals).
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The SKILL.md contains no generic advice lines such as "follow best practices", "be careful", or "ensure quality".
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
tags: [writing-for-agents]
max_turns: 30
timeout_seconds: 600
allowed_tools: [Read, Glob, Grep, Skill, Write, Edit, Bash]
---

make a skill so agents can do our npm release. steps: bump the version in package.json and add a CHANGELOG.md entry, run `pnpm test` and `pnpm build`, commit, tag vX.Y.Z, push the commit and the tag, then `pnpm publish --access public` (a publish can't be undone, we got burned once), then post the changelog entry in the #releases channel. people ask for it like "cut a release", "ship 2.4.0", "publish the new version". save it to skills/release/SKILL.md
14 changes: 14 additions & 0 deletions skills/writing-for-agents/evals/trims-bloated-agents-md/case.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
schema_version: "1.1"
name: trims-bloated-agents-md
expected_outcome: |
The run rewrites AGENTS.md in place. It drops the project description and the directory tour
(agents can discover both) and the generic advice (clean code, best practices, handle errors,
readable code, always write tests). It names one package manager, pnpm, which matches
package.json's packageManager, and the npm line is gone. It keeps every fact an agent couldn't
guess: TZ=UTC for the date tests, pnpm db:reset only against the local database on
localhost:5433, the migration command and the rule against editing merged migrations, named
exports, and leaving legacy/ alone with its reason (customers run v1 on their own servers). The
Jest-to-Vitest timeline becomes a plain "use Vitest" rule. Capitals for emphasis are gone. The
final reply says what was cut and why.
context:
scaffold_script: place-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# AGENTS.md

## About this project

Tallybook is a web application for small businesses to track invoices, expenses and payments. It is built with TypeScript, React and Node.js. The frontend uses Vite and the backend uses Express with a PostgreSQL database. We care a lot about quality and we want our code to be clean and easy to read.

## Project structure

```
apps/
web/ # React frontend
api/ # Express backend
packages/
ui/ # shared React components
db/ # database schema and migrations
utils/ # shared helpers
scripts/ # dev scripts
legacy/ # old v1 invoice exporter
```

- `apps/web/src/pages` contains the pages
- `apps/web/src/components` contains the components
- `apps/api/src/routes` contains the API routes
- `packages/db/migrations` contains the migrations

## General rules

IMPORTANT!!! You MUST ALWAYS write clean, maintainable, well-tested code and follow best practices at all times.

- Always handle errors appropriately.
- Make sure the code is readable.
- Use npm to install dependencies.
- Don't use default exports.
- Write meaningful commit messages.

## Testing

- Until the end of Q1 2025 we are migrating from Jest to Vitest. New tests should use Vitest, old Jest tests will be converted.
- Run the tests with `pnpm test`.
- The date-formatting tests fail on machines that are not in UTC, so run them with `TZ=UTC pnpm test`.
- Always write tests for your code.

## Database

- CRITICAL: `pnpm db:reset` drops every table. Only run it against the local docker database (DATABASE_URL pointing at localhost:5433), never against staging.
- Migrations live in `packages/db/migrations`. Create a new one with `pnpm --filter db migrate:new <name>`; never edit a migration that is already merged.

## Packages

- ALWAYS use pnpm. NEVER use npm or yarn.
- Don't use default exports!!!

## Legacy

- NEVER EVER touch anything in `legacy/`. It is the v1 invoice exporter that two enterprise customers still run on their own servers, and any change has to be shipped to them by hand.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "tallybook",
"private": true,
"packageManager": "pnpm@9.12.0",
"scripts": {
"dev": "vite",
"test": "vitest run",
"lint": "eslint .",
"typecheck": "tsc --noEmit",
"db:reset": "tsx scripts/db-reset.ts"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The rewritten AGENTS.md no longer contains the directory tree or the list of which folder holds pages, components, routes and migrations as a tour (a single path inside a rule, such as the migrations folder, is fine).
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The rewritten AGENTS.md no longer contains generic advice: no lines like "write clean, maintainable code", "follow best practices", "handle errors appropriately", "make sure the code is readable", or "always write tests".
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The rewritten AGENTS.md uses no capital letters for emphasis: none of IMPORTANT, MUST, ALWAYS, NEVER, CRITICAL, or NEVER EVER written in capitals, and no "!!!".
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The rewritten AGENTS.md tells agents to use pnpm and contains no instruction to use npm, so the npm-versus-pnpm contradiction is gone.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The rewritten AGENTS.md keeps both gotchas with their exact commands: the date tests need `TZ=UTC pnpm test` (or TZ=UTC), and `pnpm db:reset` drops every table and runs only against the local database on localhost:5433.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The rewritten AGENTS.md keeps the migration rules: create one with `pnpm --filter db migrate:new <name>`, and merged migrations stay unedited.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The rewritten AGENTS.md keeps the legacy/ rule together with its reason (enterprise customers run the v1 exporter on their own servers and changes ship to them by hand).
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
type: llm
focus: trace
weight: 1
---

The rewritten AGENTS.md says to use Vitest for tests without the "until the end of Q1 2025" migration timeline.
Loading