Skip to content

docs(agent-bases): render one lean AGENTS.md into all templates - #929

Merged
patrikbraborec merged 5 commits into
masterfrom
docs/agent-bases-single-source
Sep 30, 2026
Merged

patrikbraborec merged 5 commits into
masterfrom
docs/agent-bases-single-source

Conversation

@patrikbraborec

@patrikbraborec patrikbraborec commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Every template's AGENTS.md is now rendered from one source instead of three hand-synced copies, and it shrinks from 669 lines to 79.

 agent-bases/
-├── js.AGENTS.md          # 669 lines, 27.9 KB
-├── ts.AGENTS.md          # same file, TS snippets
-├── python.AGENTS.md      # same file, Python snippets
+├── AGENTS.md             # single source, {{placeholders}} for language-specific values
+└── languages.json        # placeholder values per prefix: js, ts, python
 scripts/
 └── copy-agents-md-to-templates.mts   # renders + Prettier-formats per template
 templates/
 ├── js-*/AGENTS.md        # 44 rendered files, 78–79 lines each
 ├── ts-*/AGENTS.md
 └── python-*/AGENTS.md

How it renders

flowchart LR
    S["agent-bases/AGENTS.md"] --> R["copy-agents-md-to-templates.mts<br/>(runs in pnpm run build)"]
    L["agent-bases/languages.json"] --> R
    R -->|"fill {{entry}}, {{logger}}, ..."| F["prettier.format(markdown)"]
    F --> T1["templates/js-*/AGENTS.md"]
    F --> T2["templates/ts-*/AGENTS.md"]
    F --> T3["templates/python-*/AGENTS.md"]
    T1 & T2 & T3 -.->|"@AGENTS.md"| C["CLAUDE.md"]
Loading

The script throws on a placeholder that languages.json does not define, and formats the rendered output so table alignment survives values of different lengths.

Why

AGENTS.md is loaded into the agent's context on every turn. Current guidance (Claude Code docs, agents.md, Red Hat) keeps it to always-true guidance under ~150 lines and pushes task-specific procedures into skills or links. The ETH Zurich evaluation of AGENTS.md found that verbose context files lower task success and raise cost by over 20%.

The old file also duplicated, and had drifted from, the apify-actor-development skill in apify/agent-skills. After agent-skills#87 the two disagreed on dataset schema rules (fields: {} vs. a full superset with nullable), on default vs. prefill for example URLs, and on README section order.

Before After
Source files 3, edited by hand in parallel 1 + a 35-line variables file
Rendered size 669 lines, 27.9 KB 79 lines, 6.6 KB
Schema rules inlined, out of date linked: skill + docs URLs
Rules phrasing 11 "do not" bullets positive statements

What the new file keeps

AGENTS.md
├── Commands        # apify run / validate-schema / push / actors search (+ generate-schema-types for TS)
├── Workflow        # 6 steps, each with a done-condition
├── Rules           # logger, SDK-over-CLI, untrusted content, crawler choice, aborting event, APIFY_TOKEN, standby
├── Ask first       # installs, apify push, proxy, Dockerfile, deleting storages
└── Reference       # install hint for apify-actor-development skill + docs URL table

Corrections that landed on the way:

  • The JS/TS logger rule matches what templates import (import { log } from 'apify', not apify/log).
  • Example URLs go in prefill, not default.
  • Rules name the Python crawler (BeautifulSoupCrawler / ParselCrawler), dataset call (dataset.get_info()), and aborting handler (Actor.on(Event.ABORTING, ...)) instead of the JS ones; languages.json carries them.
  • The apify validate-schema comment says what it checks. CLI 1.10 validates the input, dataset, and key-value store schemas but skips an outputSchema, because it reads only the deprecated output key. Passing it is the output-schema done-condition, and the template's "fields": {} is marked as a placeholder.

What it drops

Inlined input / output / dataset / key-value store specifications, the logging level list, the README section list, the project tree, the Playwright MCP JSON, the Do/Don't lists, and the two Crawlee gotchas (requestHandlerTimeoutMillis, additionalHttpHeaders) that agent-skills#87 flagged as unverifiable.

Verification

  • pnpm run lint passes.
  • pnpm run format:check passes for all tracked files.
  • pnpm run test-without-templates passes (17 tests).
  • No unrendered {{ placeholders in any template.

Follow-up

  • Use inputSchema / outputSchema in actor-json.md and output-schemas.md, done in agent-skills#87 together with the logger, Python entry point, and standby fixes.
  • In apify/agent-skills: align README section order in actor-readme.md with the docs page this file now links to.

Replace the three hand-synced agent-bases/{js,ts,python}.AGENTS.md files
with a single agent-bases/AGENTS.md whose language-specific values come
from agent-bases/languages.json. The copy script renders it per template
prefix and formats the result with Prettier.

The rendered file shrinks from 669 to 77 lines. Inlined schema
specifications, logging level lists, README section lists, the project
tree and the Playwright MCP config are replaced by links to the Apify
docs and a pointer to the apify-actor-development skill, which is now
the single place for the full workflow and schema rules.
@github-actions github-actions Bot added this to the 149th sprint - Builders team milestone Sep 9, 2026
@github-actions github-actions Bot added the t-builders Issues owned by the Builders team. label Sep 9, 2026
@patrikbraborec patrikbraborec added the adhoc Ad-hoc unplanned task added during the sprint. label Sep 23, 2026
- Render the HTTP crawler, dataset info call, and aborting handler per
  language, so Python templates stop naming JS-only CheerioCrawler and
  Dataset.getInfo()
- Say what apify validate-schema checks: input, dataset, and key-value
  store schemas, but not an outputSchema (CLI 1.10 reads only `output`)
- Make it the output-schema done-condition and mark the template's
  `fields: {}` as a placeholder
- Add apify run --purge, and fix the plural logger sentence for Python

@l2ysho l2ysho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really too big to carefully check, I guess lets LGTM (lets gamble this merge) and lets watch how agents like it. We can revert anytime.

@patrikbraborec

Copy link
Copy Markdown
Contributor Author

@l2ysho yes, but before merge I want to run some evals :)

…conditions

In an end-to-end eval the aborting handler was implemented in 1/5 Actors
while it lived only in Rules; workflow done-conditions were followed every
time. Move it into step 1 and keep the why in Rules. Also tell the user the
Standby URL on deploy, which no run did.
@patrikbraborec
patrikbraborec merged commit f52acdb into master Sep 30, 2026
59 checks passed
@patrikbraborec
patrikbraborec deleted the docs/agent-bases-single-source branch September 30, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-builders Issues owned by the Builders team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants