agentleFS
RamezHanyRamezHany/payload-cms-skills/skills/agent-guardrails/SKILL.md

agent-guardrails

Skill0 starsChanged 13 days agoMITView on GitHub

Hard operating rules for coding agents on Payload CMS + Next.js projects, especially unattended, overnight, or turbo runs. Use in every session. Prevents scope creep, rebuilding from scratch, throwaway scripts that roam the machine, retry loops that burn tokens, leaked secrets, destructive database commands, "invalidate everything to be safe" cache hooks that exhaust free-tier quotas, and false "done" claims.

  • Pipes a download into a shell
  • Reads credentials
  • Deletes or force-pushes
  • Installs packages

9 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

26 rules. 0 are common, 15 are distinctive, and 11 are very specific to this project.

  • 0

    Common

    Most of the 8 edited versions we read keep these.

  • 15

    Distinctive

    This author's own choices. Worth a look.

  • 11

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Do only the current phase in PROJECT.md.

    line 15
  2. Distinctive:

    Never start from scratch when code exists.

    line 16
  3. Distinctive:

    Never rewrite a working file to change its style.

    line 17
  4. Very specific:

    If the task is unclear, write the question under ## Questions and work on the parts that are clear.

    line 18
  5. Distinctive:

    Never run the same failing command more than twice without changing something relevant.

    line 45
  6. Distinctive:

    If the same error appears after two different fixes, stop fixing.

    line 46
  7. Very specific:

    After three failed attempts on one problem, write an entry under ## Blockers in PROJECT.md with the error output, what you tried, and your …

    line 47
  8. Very specific:

    Run the cheap check first: pnpm tsc --noEmit before pnpm build.

    line 48
  9. Distinctive:

    Start at most one dev server.

    line 49
  10. Distinctive:

    Do not poll or sleep in a loop waiting for something that is not running.

    line 50
  11. Very specific:

    Check the latest stable version with pnpm view <package> version and install that version.

    line 55
  12. Distinctive:

    Do not add a package that duplicates one already installed (a second date library, a second form library, a second icon set).

    line 56
  13. Distinctive:

    Never install a package with no release in the last 12 months unless a skill names it.

    line 57
  14. Distinctive:

    Never print, echo, log, or commit secret values.

    line 61
  15. Very specific:

    Keep secrets in the gitignored env file (.env from the Payload template) for development and in the hosting dashboard for production.

    line 62
  16. Very specific:

    Never run payload migrate:fresh, migrate:reset, migrate:down, or drop tables against any database except a local development file.

    line 63
  17. Distinctive:

    Never delete media, users, or submissions to "clean up" test data in a shared database.

    line 64
  18. Distinctive:

    Never paste real customer data into code, tests, or seed files.

    line 65
  19. Distinctive:

    Never schedule crons, polling, or background work more often than the feature requires.

    line 72
  20. Distinctive:

    Never raise limits or plan-dependent settings (function duration, retries, image sizes, query limits) beyond what the task needs.

    line 73
  21. Very specific:

    When a broader option is chosen deliberately, the code comment states the reason and the expected cost, and PROJECT.md records it under ## …

    line 74
  22. Distinctive:

    Commit after each completed step with a message that names the step.

    line 79
  23. Very specific:

    Never force push, rewrite published history, or commit .env* files other than .env.example.

    line 80
  24. Very specific:

    Do not disable tests, lint rules, or type checks to make a check pass.

    line 86
  25. Very specific:

    Stop the affected task and write a question under ## Questions when any of these is needed:

    line 90
  26. Distinctive:

    Before starting an overnight or turbo run:

    line 102

“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Agent guardrails

These rules override any instinct to improvise. When a rule and a task conflict, follow the rule and record the conflict in PROJECT.md under ## Questions.

1. Scope

  1. Do only the current phase in PROJECT.md. Do not start the next phase, add unrequested features, or "improve" unrelated code.
  2. Never start from scratch when code exists. Never re-scaffold, re-initialize, or replace a working project. Extend it.
  3. Never rewrite a working file to change its style. Change only the lines the task needs.
  4. If the task is unclear, write the question under ## Questions and work on the parts that are clear.

2. Shell use

Allowed commands, run from the project root only:

PurposeCommands
Packagespnpm add, pnpm remove, pnpm install, pnpm view <pkg> version
Payloadpnpm payload <command>, pnpm generate:types, pnpm generate:importmap
Next.jspnpm dev, pnpm build, pnpm start, pnpm lint
Checkspnpm tsc --noEmit, pnpm test, pnpm exec playwright test, pnpm exec vitest run
Gitgit status, git diff, git add, git commit, git switch -c, git log
Scaffoldingnpx create-payload-app, npx degit (only as written in a skill)

Forbidden:

  • Writing scripts (Python, Node, PowerShell, Bash) to search code, patch files, rename in bulk, inspect the system, or "explore". Use the editor's search, read, and edit tools instead.
  • Any command that reads or writes outside the project folder, including the home directory, other projects, system folders, and global config.
  • Global installs (npm i -g, pip install), sudo, piping downloads into a shell (curl ... | sh), changing system settings.
  • Installing a language runtime or tool the project does not already use.
  • Deleting files outside node_modules, .next, and test output folders without the task requiring it.

A script is allowed only when a skill ships it in assets/ or scripts/ and tells you to run it.

3. Loop breaker

  1. Never run the same failing command more than twice without changing something relevant.
  2. If the same error appears after two different fixes, stop fixing. Re-read the error, read the relevant skill's diagnosis table, and form a new hypothesis.
  3. After three failed attempts on one problem, write an entry under ## Blockers in PROJECT.md with the error output, what you tried, and your best hypothesis. Then move to the next independent task, or stop if none exists.
  4. Run the cheap check first: pnpm tsc --noEmit before pnpm build. Never loop on pnpm build.
  5. Start at most one dev server. Reuse it. Stop it when the session ends.
  6. Do not poll or sleep in a loop waiting for something that is not running.

4. Dependencies

  1. Install only packages named in a skill or in PROJECT.md.
  2. Check the latest stable version with pnpm view <package> version and install that version.
  3. Do not add a package that duplicates one already installed (a second date library, a second form library, a second icon set).
  4. Never install a package with no release in the last 12 months unless a skill names it.

5. Secrets and data

  1. Never print, echo, log, or commit secret values. Refer to variables by name.
  2. Keep secrets in the gitignored env file (.env from the Payload template) for development and in the hosting dashboard for production. Keep .env.example updated with names and placeholder values only.
  3. Never run payload migrate:fresh, migrate:reset, migrate:down, or drop tables against any database except a local development file.
  4. Never delete media, users, or submissions to "clean up" test data in a shared database.
  5. Never paste real customer data into code, tests, or seed files.

6. Cost and blast radius

"When in doubt, do more" is wrong when "more" is billed or touches every page. Choose the smallest change that is provably correct.

  1. Cache invalidation is metered on Vercel, and when the free allowance runs out, content silently stops updating. Never add a cache tag shared by all content queries. Never call revalidatePath(path, 'layout') except in a hook for a global the layout renders, with a comment naming that data. Revalidate only the routes that render the changed document (payload-performance skill, Step 2).
  2. Never schedule crons, polling, or background work more often than the feature requires.
  3. Never raise limits or plan-dependent settings (function duration, retries, image sizes, query limits) beyond what the task needs.
  4. When a broader option is chosen deliberately, the code comment states the reason and the expected cost, and PROJECT.md records it under ## Decisions.

7. Git

  1. Work on a feature branch. Never commit or push to main or master.
  2. Commit after each completed step with a message that names the step.
  3. Never force push, rewrite published history, or commit .env* files other than .env.example.

8. Verification and honesty

  1. A task is done only when the skill's "Done when" checks have been run and passed.
  2. Report failing checks plainly. Never claim a test passed if you did not run it.
  3. Do not disable tests, lint rules, or type checks to make a check pass. Do not add // @ts-ignore or as any to silence errors.

9. Stop and ask

Stop the affected task and write a question under ## Questions when any of these is needed:

  • a credential, API key, or account login
  • a paid plan or a service outside the fixed stack
  • legal text, prices, or business rules the brief does not state
  • a change that deletes data or breaks an existing URL
  • two requirements that contradict each other

In an interactive session, ask the user directly as well.

10. Unattended runs

Before starting an overnight or turbo run:

  • One phase is selected in PROJECT.md
  • A feature branch is checked out
  • .env exists with the variables the phase needs; if not, skip tasks that need them

During the run, follow sections 1 to 9 strictly. Never wait for input: record questions and continue with independent tasks.

At the end of the run, add a ## Session log entry to PROJECT.md:

### 2026-01-15 - <model name>
- Done: <steps completed, with commit hashes>
- Not done: <steps left>
- Checks: <commands run and their results>
- Blockers: <links to Blockers entries>
- Next step: <the exact next action>

Done when

  • No command ran outside the project folder
  • No throwaway scripts were created
  • Every completed step is committed on a feature branch
  • PROJECT.md has an up-to-date session log entry

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.