agentleFS
Autocss-comAutocss-com/ai/.agents/skills/javascript/SKILL.md

javascript

Skill1 starsChanged 2 months agoMITView on GitHub

JavaScript rules for projects following the air-gapped, declarative-first architecture. JS is data transport only — it fetches, parses, stores, and injects JSON. It never controls UI state, never manipulates the DOM for presentation, and never uses event listeners. Use whenever writing or reviewing any .js file.

11 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use java and debugging.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • testdino-hqSkill

    java

    Google's official Java style guide. Covers 2-space indentation, 100-char line limit, naming conventions, braces, imports, Javadoc, exception handling, lambdas, and streams. Enforces @Override annotations and specific imports.

    Also in 3 projects that use this

  • BlockSkill

    debugging

    Debugging guidelines and best practices

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

11 rules. 0 are common, 4 are distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No other JavaScript files are added without explicit user instruction.

    line 31
  2. Distinctive:

    No other DOM mutation utilities are added.

    line 59
  3. Very specific:

    Stateless: No module-level mutable state.

    line 63
  4. Very specific:

    Never registers event listeners (addEventListener)

    line 88
  5. Very specific:

    Never reads or writes class, id, or data-* attributes (those don't exist in this architecture's HTML)

    line 89
  6. Very specific:

    Never injects HTML strings (innerHTML = '<div>' etc.)

    line 90
  7. Distinctive:

    Never sets inline styles

    line 91
  8. Very specific:

    Never controls visibility (CSS does that via :empty, :has())

    line 92
  9. Distinctive:

    Never animates (CSS does that)

    line 93
  10. Very specific:

    Never tracks UI state in JS variables (state lives in DOM via native checked, open, attributes)

    line 94
  11. Very specific:

    Never uses eval, Function constructor, or dynamic code generation

    line 95

“Common” is measured: kept by at least 6 in 10 of the 9 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

JavaScript

JavaScript is data transport only. CRUD against an API. Nothing else.

The only permitted JavaScript responsibilities

  1. API transport — fetch() against the configured endpoint base, parsing JSON responses
  2. oninput lifecycle — wiring nav radios and form inputs to data fetches via the input DOM event in oninput.js
  3. Storage — localStorage primary, cookie fallback, in storage.js
  4. Startup wiring — console.clear(), programmatic initial nav click, in app.js
  5. Tour placeholder — tour.js reserved for future onboarding logic

Anything else is forbidden.

Only these files exist in assets/js/

  • assets/js/app.js — entrypoint, startup wiring, console reset
  • assets/js/oninput.js — shared input event lifecycle, binds nav and form inputs, routes API calls
  • assets/js/api.js — fetch(), base URL, endpoint suffix resolution, response parsing
  • assets/js/storage.js — localStorage and cookie utilities
  • assets/js/tour.js — placeholder

No other JavaScript files are added without explicit user instruction.

Only these patterns for DOM access

  • document.querySelector('selector') — the only permitted selector method

Forbidden:

  • document.getElementById()
  • document.getElementsByClassName() (and there are no classes anyway)
  • document.getElementsByTagName()
  • document.querySelectorAll() is permitted only when iterating a known set; prefer querySelector chaining
  • jQuery, $(), any third-party DOM library

Only these patterns for events

  • element.addEventListener('input', handler) is forbidden in markup-driven flows. The input event is bound once in oninput.js via direct property assignment to the discovered nodes.
  • The HTML attribute oninput= and every other on*= attribute is forbidden in markup. See the html skill.
  • addEventListener is forbidden anywhere in the project, including inside JS files. The oninput.js lifecycle uses direct .oninput property assignment, which is idempotent.

The reasoning: every event registration is a piece of UI behavior. UI behavior belongs to CSS. The single exception is data transfer triggered by user input, which is the oninput lifecycle.

Only these utilities for unavoidable DOM mutation

The architecture pulls all UI state into CSS. Two utilities exist for cases where CSS cannot reach a particular browser default:

  • removeInlineStyles(element) — strips any inline style attribute that the browser or a third-party may have inserted
  • clearFieldset(fieldset) — resets a <fieldset> to its empty state for a fresh data render

No other DOM mutation utilities are added. If a need arises, surface it to the user before writing.

Constraints on every function

  • Stateless. No module-level mutable state. No let declarations at module scope.
  • Idempotent. Calling twice produces the same result as calling once.
  • No side effects beyond the explicit responsibility (fetching, parsing, injecting data, writing to storage).
  • No global state. No window.foo. No globals.

Lifecycle conventions

  • The API base URL is declared once, in api.js. Only the endpoint suffix varies per page (shell, home, about, products, events, contact).
  • Initial page load enters the same oninput lifecycle path via a programmatic element.click() on the appropriate nav radio. There is no separate "boot" path.
  • Shell content (header, nav, footer, meta) is fetched and injected once per runtime session, not on every page change.
  • Nav radio index maps to page endpoint suffix; the same DOM targets are reused for content injection.
  • console.clear() runs on startup and on each lifecycle run.

Console policy

  • Success: minimal, timestamped, single line.
  • Failure: verbose, timestamped, full error context.
  • console.clear() on startup and on each lifecycle run.

External service failures

When an API call fails (SSL error, network failure, 4xx, 5xx, rate limit), the JS does not retry against a different endpoint, does not redirect to a local fallback, and does not invent data. It surfaces the error to the user with enough detail for them to resolve it. The architecture is never modified to work around external service issues — the user resolves them at the source.

What JavaScript never does

  • Never registers event listeners (addEventListener)
  • Never reads or writes class, id, or data-* attributes (those don't exist in this architecture's HTML)
  • Never injects HTML strings (innerHTML = '<div>' etc.)
  • Never sets inline styles
  • Never controls visibility (CSS does that via :empty, :has())
  • Never animates (CSS does that)
  • Never tracks UI state in JS variables (state lives in DOM via native checked, open, attributes)
  • Never uses eval, Function constructor, or dynamic code generation

Baseline & support

Checked against MDN as of 2026-07-16.

Canonical rules: https://github.com/Autocss-com/ai/blob/main/AGENTS.md

References

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.