Skip to content
Agentmart
Submit a tool

AGENTS.md · kepano/defuddle

AGENTS.md from kepano/defuddle: 42 lines covering Security, Build and test, Runtime compatibility, Debugging extraction and more.

Template by kepano

IndexedMIT★ 9,778
Write a review

Install

Works with Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Claude Code. Read the repository before you give any tool access to your data.

curl -fsSL https://raw.githubusercontent.com/kepano/defuddle/main/AGENTS.md -o AGENTS.md

Read it and adapt it to your project before use.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

The AGENTS.md file that kepano/defuddle (9,778 stars) keeps for coding agents. It has 42 lines in 5 sections: Security; Build and test; Runtime compatibility; Debugging extraction; Common pitfalls. Use it as a model for your own project's instructions.

Use cases: prompt-engineering

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

What's in it

An AGENTS.md file: instructions coding agents (Codex, Cursor, Copilot, Gemini CLI and others) read before working in a repo.

For
Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Claude Code
Length
42 lines
File
AGENTS.md

Sections

  1. Security
  2. Build and test
  3. Runtime compatibility
  4. Debugging extraction
  5. Common pitfalls

First lines (shown under the repo's MIT license)

# Defuddle

Extracts main content from web pages as clean HTML.

## Security

- Never use `innerHTML` directly. Use `parseHTML()` from `src/utils/dom.ts` (template-based parsing without script execution or resource loading).
- Escape every page-derived value interpolated into HTML with `escapeHtml()`, or build nodes with `createElement`/`setAttribute` and `serializeHTML()`. Downstream sanitization does not replace escaping at the point of interpolation.
- Strip `javascript:`, `blob:`, and non-image `data:` URLs from `href`/`src`. Allow `data:image/*` except as an iframe `src`. Strip iframe `srcdoc` and all `on*` event handlers.
- Preserve sanitization regardless of pipeline options. See `isDangerousUrl()` in `src/utils/dom.ts` and `_stripUnsafeElements()` in `src/defuddle.ts`.
- Cover new extractors with a poisoned-attribute case in `tests/extractor-xss.test.ts`.

## Build and test

- `npm run build` — build all bundles.
- `npm test` — run Vitest.
- For extraction fixes, add a minimal HTML fixture in `tests/fixtures/` with correct expected output in `tests/expected/`. Verify the same fixture fails before the fix and passes afterward; do not change expectations to match buggy behavior.
- Anonymize fixtures: replace real names, emails, URLs, and identifying content with generic placeholders.
- Always use `curl` to test the Worker or defuddle.md; never open those URLs in a browser.
- Local Worker: run `cd website && npx wrangler dev`, then `curl http://localhost:8787/https://stephango.com/saw`.
- Production: `curl https://defuddle.md/https://stephango.com/saw`.

## Runtime compatibility

Changes must work across these environments:

- Browser (`defuddle`, `defuddle/full`): native DOM.
- Node.js (`defuddle/node`): async API accepting any DOM `Document`, including linkedom, JSDOM, and happy-dom.
- CLI (`src/cli.ts`) and Cloudflare Worker (`website/src/convert.ts`): linkedom; the Worker is the most constrained environment.

## Debugging extraction

- Start with `{ debug: true }` and inspect `result.debug.removals` and `result.debug.contentSelector`. Debug mode preserves class/id/data attributes and skips div flattening.
- Disable removal steps individually to isolate content loss. Use `contentSelector` to bypass incorrect main-content detection.
- For selector issues, inspect `EXACT_SELECTORS` and `PARTIAL_SELECTORS` in `src/constants.ts`. Elements inside `<pre>` or `<code>` are protected from selector removal.
- Standardize footnotes and callouts before removals: CSS sidenotes may use `display:none`, and callout classes such as `.alert` otherwise match clutter selectors.

## Common pitfalls

- UMD bundles use webpack `export: 'default'`; expose named exports as static properties on the default class (see `src/index.full.ts`).
- `getElementsByTagName` returns live HTMLCollections. Use `Array.from()` before mutating the DOM.

Signals

Stars
9,778
Forks
444
Open issues
60
Last commit (this folder)
Sep 20, 2026 (1 month ago)
Last release
Oct 24, 2026 (4 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from kepano

Cite this page

AGENTS.md · kepano/defuddle. Agent Mart. https://agentmart.dev/templates/kepano-defuddle-agents-md (last updated 2026-10-24)