agentleFS
sefaertuncsefaertunc/anthropic-watch/.claude/skills/backend-conventions/SKILL.md

backend-conventions

Skill1 starsChanged 7 months agoMITView on GitHub

Scraper contract, fetch/retry, state persistence, and feed generation conventions for anthropic-watch

6 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use frontend-conventions.

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.
  • CloudflareSkill

    frontend-conventions

    Use for creating, modifying, moving, or reviewing React frontend code anywhere in packages/*, including Workshop pages, gatekeeper management apps, shared UI, components, hooks, forms, interactions, styling, accessibility, and frontend tests.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 1 is distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 1

    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:

    Every scraper is a function with a fixed signature:

    line 18
  2. Very specific:

    IDs must be stable: Don't use timestamps or random values.

    line 28
  3. Very specific:

    date may be null: when the source legitimately has no per-item date (e.g.

    line 29
  4. Very specific:

    All HTTP goes through src/fetch-with-retry.js, accessed via src/fetch-source.js (which adds fixture injection for tests).

    line 34
  5. Very specific:

    Never call fetch directly from a scraper — always route through fetchSource(url, options, fixtureFile) so test fixtures work.

    line 46
  6. Very specific:

    State is append-only: Never delete keys. If a source is removed from sources.js, its state entry stays — the source may come back.

    line 65
  7. Very specific:

    Read existing feed file → extract items array

    line 74
  8. Very specific:

    All results collected via Promise.allSettled — one failure never aborts the others

    line 96

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

Backend Conventions — anthropic-watch

This project is a scraper pipeline, not a web service. There is no HTTP API, no database, no auth. Backend conventions here cover scrapers, fetching, state, and feed generation.

Authoritative deep-dive: docs/ARCHITECTURE.md. This document is the working-memory summary for agents.

Scraper Contract

Every scraper is a function with a fixed signature:

  • Input: source config object from src/sources.js (must include key, category, name, and type-specific fields)
  • Output: Array<Item> on success; throws on failure
  • Item shape: 8 fields — id, title, date, url, snippet, source, sourceCategory, sourceName

Rules:

  1. Never wrap scraper logic in try/catch { return [] }. Let errors propagate. The orchestrator's Promise.allSettled captures them, records the real message, and increments consecutiveFailures. The v1.0.1 silent-failure bug was caused by scrapers catching their own errors.
  2. Empty array return means "no items right now" — it is not a failure signal. Return [] when the source is live but has nothing new.
  3. IDs must be stable. Don't use timestamps or random values. Use source-natural IDs: tag_name, post URL, version string, incident ID, heading text. Use SHA-256 hashes only as a fallback when no natural ID exists.
  4. date may be null when the source legitimately has no per-item date (e.g. the models reference table). Never fake a date.
  5. snippet max 300 chars, may be "". Plain text only — markdown or HTML in snippets breaks RSS consumers.

Fetching

All HTTP goes through src/fetch-with-retry.js, accessed via src/fetch-source.js (which adds fixture injection for tests).

  • Max retries: 2 (3 total attempts)
  • Backoff: linear — 1s, 2s
  • Timeout: 15s per request (AbortSignal.timeout)
  • Retries on: 5xx, network errors, 429
    • On 429, Retry-After header (seconds) overrides linear backoff for that attempt
  • Does not retry: other 4xx — returned immediately
  • Redirects: redirect: "follow" by default; scrapers can override
  • User-Agent: derived from package.json version at module load (anthropic-watch/${version} (…))
  • GitHub rate limit: logGitHubRateLimit(res) warns when remaining quota < 10

Never call fetch directly from a scraper — always route through fetchSource(url, options, fixtureFile) so test fixtures work.

State

State lives in state/last-seen.json and is managed by src/state.js.

Per-source entry:

{
  "knownIds": ["id-1", "id-2"],
  "lastChecked": "2026-04-16T06:00:00.000Z",
  "consecutiveFailures": 0,
  "lastSuccess": "2026-04-16T06:00:00.000Z"
}

Rules:

  • State is append-only. Never delete keys. If a source is removed from sources.js, its state entry stays — the source may come back.
  • loadState() returns {} on ENOENT. Missing file is safe; pipeline treats everything as new. Malformed JSON throws and halts the pipeline.
  • recordFailure() runs unconditionally on rejected scraper promises, including first runs. There is no "first-run heuristic" — that was removed in v1.0.1.
  • Warning threshold: consecutiveFailures >= 3 triggers ::warning annotations in the GitHub Actions job summary.

Feed Generation (src/feed/)

Accumulation model, applied identically to JSON and RSS:

  1. Read existing feed file → extract items array
  2. Prepend new items: [...newItems, ...existingItems]
  3. Dedup by ${id}|${source} — first-seen wins, so the freshly scraped copy overwrites the persisted one
  4. Sort by date descending (nulls last)
  5. Slice: 100 for all.*, 50 for per-source

The new-wins semantics matter for in-place edits like [Unreleased] changelog sections — the latest snippet replaces the stale one.

Error Handling Philosophy

  • No shared error class hierarchy. Plain Error with descriptive messages. Don't introduce ScraperError, FetchError, etc.
  • Two levels:
    1. Scraper level: let errors propagate — no outer try/catch.
    2. Orchestrator level: src/index.js processes Promise.allSettled results. Rejected promises have _source and _durationMs attached via Object.assign(err, { … }); err.message is written to sourceResults[].error.
  • Logging: src/log.js provides log.info / log.warn. Don't use console.* directly in source code — tests capture log output.

Concurrency

runWithConcurrency(tasks, 4) in src/index.js:

  • 4 scrapers in flight at once
  • Set of in-flight promises; Promise.race waits for one to finish before launching the next
  • All results collected via Promise.allSettled — one failure never aborts the others
  • .catch(() => {}) on the race is intentional: it prevents unhandled rejection (the real error is captured by allSettled)

Dependencies Policy

Runtime deps are cheerio + fast-xml-parser only. Dev deps are vitest + yaml. Adding a new dep requires:

  1. A concrete use case existing tools can't cover
  2. A CHANGELOG entry in the same PR explaining why
  3. Preference for Node built-ins first (node:crypto, node:fs/promises, node:path, node:url)

Naming

  • File names: kebab-case (fetch-with-retry.js, github-releases.js)
  • Function names: camelCase (runPipeline, fetchSource, markSeen)
  • Source keys: kebab-case matching the feed filename (blog-engineering, api-sdk-py-releases)
  • Parse modes: kebab-case string literals (nextjs-rsc, intercom-article, model-table)
  • Constants: UPPER_SNAKE_CASE when module-level, otherwise named like the value

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.