Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0b3f5ae
Apply pushy frontmatter description and Theory of Mind to SKILL.md (l…
paulirish Mar 31, 2026
269abad
Merge remote-tracking branch 'origin/main' into skill-framing-upgrades
paulirish May 9, 2026
242385e
guides: optimize modern-web skill description trigger semantics
paulirish May 9, 2026
38f46c7
manual edits
paulirish May 9, 2026
da6a07b
skills: optimize modern-web frontmatter for triggering efficiency
paulirish May 9, 2026
dbdc4bf
serving: add prompt triggering and embedding validation test script
paulirish May 9, 2026
2812614
serving: expand empirical test with full TPR/FPR dispatching suite
paulirish May 9, 2026
ab37534
guides: apply optimal GOAL+TRIGGER+BYPASS prompt sequencing format
paulirish May 9, 2026
5669693
serving: upgrade empirical test script with high-load selection stres…
paulirish May 9, 2026
1865bce
deps: move @google/genai to devDependencies at root
paulirish May 9, 2026
02c4622
serving: add RAG similarity-floor calibration sweeps tool
paulirish May 9, 2026
a46149d
guides: integrate strict exclusions to prevent simple task over-trigg…
paulirish May 10, 2026
c3bd54e
guides: modernize skill metadata using structured Goal-Trigger-Exclus…
paulirish May 10, 2026
b8bc253
guides: optimize modern-web skill description using agentskills.io pr…
paulirish May 10, 2026
10bed3c
serving: extract tokenizer logging into modular getTokenCountString h…
paulirish May 10, 2026
bec6a85
serving: drop redundant try-catch block from getTokenCountString
paulirish May 10, 2026
41d29d5
serving: restrict tokenizer logging strictly to parsed frontmatter de…
paulirish May 10, 2026
4b5742b
serving: expand empirical stress test with Softball Near-Miss evaluat…
paulirish May 10, 2026
0db72f5
serving: encapsulate frontmatter parsing inside getDescriptionTokenCo…
paulirish May 10, 2026
3df9721
guides: refine modern-web exclusions stanza with explicit trivial-gat…
paulirish May 10, 2026
0a0b187
drop these
paulirish May 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 48 additions & 29 deletions guides/modern-web/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
---
name: modern-web
description: |
IMPORTANT: This is a search tool that will help you find the most modern and recommended way to implement any web development use case.
Use this skill when structure, styling, or interactions for complex components, pages, dashboards, and layout grids need to align with modern browser features.
Trigger this for advanced CSS layouts (container/style queries, `:has()`, `calc-size`, scrollbars, relative colors), native controls (`dialog`, `popover`, anchor positioning), transitions (`@starting-style`, discrete transitions), priority fetches (`fetch-priority`, `fetchlater`), or layout rendering policies (`content-visibility`, `speculation-rules`, scheduler, `move-before`).

MANDATORY: You MUST execute this FIRST for each and every web development use case, even if you're implementing that use case in a framework like React, especially for writing modern web code. No matter the complexity, you MUST call this tool for ALL web development tasks touching HTML, CSS, or JavaScript.
Do NOT invoke this skill for trivial visual tweaks, single-property updates, or standard baseline styles (e.g., basic colors, padding, borders, typography) that are fully ready from general memory.

Do NOT skip this step even if you already know how to implement the use case — web platform APIs evolve rapidly and your training data may recommend outdated approaches. This tool ensures you use the current best practice.
WARNING: Stale training memory relies on obsolete scripts and bloated design patterns. You are strictly forbidden from authoring frontend structures from memory without searching this skill first, except for the basic changes listed above.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Result of description from AGY analysis:

description: |
  IMPORTANT: This is a specialized search and retrieval tool for modern web platform best practices and Chrome-recommended implementation patterns.
  
  MANDATORY: You MUST execute this FIRST at the start of EVERY web development task touching HTML, CSS, or client-side JavaScript (including UI components, layout, styling, animations, performance tuning, or accessibility).
  Do NOT skip this step even if you already know how to implement the use case — web APIs evolve rapidly and your training data contains obsolete patterns. Using this tool is the only way to ensure compliance with Chrome's modern standards.

  Trigger this skill immediately when the user prompt involves:
  - UI Components (modals, dialogs, popovers, dropdowns, tabs, carousels)
  - Layout & Styling (frosted glass/Glassmorphism, backdrop-filter, centering, grid/flexbox, anchor positioning, responsive designs, `:has()`, `:user-valid`)
  - Animations & Scrolling (View Transitions, Scroll-driven animations, scroll-triggered behaviors)
  - Performance & Resource Loading (LCP, INP, Fetch Priority, image optimization, lazy loading)
  - Device & OS Integration (direct local file system access, local directory read/write, WebUSB)
  - High-Performance & Real-Time (WebAssembly data engines, WASM widgets, WebSockets bidirectional syncing)
  - Modern JS APIs (AbortController, field-sizing, native browser APIs)
  - Framework Adaptation (implementing CSS/styling/UI patterns in React, Angular, Vue, etc.)

  DO NOT trigger this skill for:
  - Pure backend tasks (server-side API routing, database SQL queries, ORM setup)
  - CI/CD, deployment, containerization, or build-pipeline scripts (e.g., Docker, GitHub Actions)
  - Non-web programming tasks (command-line tools, system utilities, general Python/Go scripts)
  - Generic project configuration (e.g., setting up git, eslint, package.json scripts)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks great, but isn't it too long? (1875 chars).
At least Claude's cap is no longer 250 characters (!) but it's still 1500.

Though given that the last list is when not to trigger, I guess the truncation doesn't lose us much.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ah, great point. Most of the other frontier models have a hard limit at 1024 characters, I believe. Here is a much more concise version (991 characters):

IMPORTANT: Specialized search/retrieval tool for Chrome guidelines. MANDATORY: Execute FIRST for all HTML/CSS/JS tasks. Do NOT skip — web APIs evolve rapidly and training weights contain obsolete patterns. Using this tool is required to comply with Chrome standards.
  
  Trigger immediately when prompt involves:
  - UI & Layout: Modals, dialogs, popovers, Glassmorphism/backdrop-filters, anchor positioning, container queries, `:has()`, `:user-valid`.
  - Scroll & Motion: View Transitions, Scroll-driven animations, scroll parallax/reveals.
  - Performance: Core Vitals (LCP, INP), content-visibility, Fetch Priority, image optimization, AbortController.
  - System & APIs: Local filesystem access, WebUSB, WebSockets sync, WebAssembly widgets.
  - Frameworks: Adapting layout/styles in React, Vue, Angular.

  DO NOT trigger for:
  - Backend: Database SQL, ORM schemas, Express API routes.
  - Pipelines: CI/CD deployment pipelines, Docker, Actions.
  - Generic: Local scripts (Python/Go tools), ESLint, Git.

This was tested against the same dataset had the same results (0% False Positive rate, 86.7% trigger accuracy).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

---

# Modern Web
# Modern Web Development Guidelines

A skill to search for specific web development use cases and retrieve their corresponding best practice guides.
To locate, retrieve, and execute modern layout, design, and web platform patterns:

## When to use
## Search and Retrieve Protocol

Must use this skill:
- At the **start** of implementing any web feature.
- Before creating a new component, to check if a standardized pattern already exists.
- To avoid implementing ad-hoc solutions or loading large dependencies unnecessarily.
### 1. Search for an implementation pattern
Find the most relevant pattern matching your current task.

## Usage Instructions

### Step 1. Search Use Cases

Search with an action-oriented query summarizing what you want to achieve using the `search` command. Run `modern-web.mjs` directly with `node`.

```sh
```bash
node <modern-web-directory>/modern-web.mjs search "<query>"
```

**Example Output**:
Example:
```bash
node <modern-web-directory>/modern-web.mjs search "defer offscreen layout"
```

Example search output:
```json
[
{
Expand All @@ -41,22 +39,43 @@ node <modern-web-directory>/modern-web.mjs search "<query>"
]
```

### 2. Retrieve standard requirements
Use the identified `id` from search outputs to load full guidelines.

```bash
node <modern-web-directory>/modern-web.mjs retrieve "<id>"
```

Example:
```bash
node <modern-web-directory>/modern-web.mjs retrieve "content-vis"
```

---

### Step 2. Retrieve Best Practices
## Directives

Once you have a relevant `id` from the search results, call this script using the `retrieve` command to get the full guide. You can pass multiple IDs separated by commas.
1. **Search First**: Do not write layout structures, styling properties, or scripting actions without checking for matching use cases.
2. **Prioritize Native Platform Capabilities**: Leverage native browser-supported features (e.g., `:has()`, `<dialog>`, `popover`) and dynamic units over complex JavaScript calculations, design hacks, or dependencies.
3. **Strict Compliance**: Carry out all "DO", "DO NOT", and "MANDATORY" specifications documented in the retrieved guides.
4. **Framework Adaptations**: Framework adaptations (e.g., React, Vue components) must comply with the core standards constraints.
5. **No Hallucinations**: Adhere strictly to locally available web development guidelines retrieved using this tool.

```sh
node <modern-web-directory>/modern-web.mjs retrieve "<id>"
```
---

## Query Reference Examples

### Search query:
```bash
node <modern-web-directory>/modern-web.mjs search "monitor and report core web vitals at the end of a session"
```

**Example Output**:
`The markdown content of the guide describing implementation steps...`
### Retrieve guide:
```bash
node <modern-web-directory>/modern-web.mjs retrieve "full-session-analytics"
```

## Guidelines
Other reference guides available for search:
- `optimize-image-priority` (LCP / Fetch Priority)
- `adapt-scrollbar-to-contrast-preferences` (CSS Scrollbar styling for high-contrast visibility)

- Always search **first** to find the most specific design/performance patterns.
- These guides are usually framework-agnostic; adapt them correctly to your setup.
- Do not hallucinate guides or ignore them; they represent the preferred local standard for the user's project.
8 changes: 4 additions & 4 deletions serving/skills-cli/build-dist.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ describe('processSkills', () => {
fs.rmSync(testOutputDir, { recursive: true, force: true });
});

it('processes macros in SKILL.md', () => {
it('processes macros in SKILL.md', async () => {
const publishRoot = testOutputDir;
const distDir = path.join(publishRoot, 'skills/modern-web');

processSkills(publishRoot, distDir, false);
await processSkills(publishRoot, distDir, false);

const builtSkillPath = path.join(publishRoot, 'skills', dummySkillName, 'SKILL.md');
assert.ok(fs.existsSync(builtSkillPath), 'Built SKILL.md should exist');
Expand All @@ -43,11 +43,11 @@ describe('processSkills', () => {
assert.ok(content.includes('`forms` (via `node <modern-web-directory>/modern-web.mjs retrieve "forms"`)'), 'Should resolve forms skill reference');
});

it('processes GUIDE_REF macros in real CSS SKILL.md', () => {
it('processes GUIDE_REF macros in real CSS SKILL.md', async () => {
const publishRoot = testOutputDir;
const distDir = path.join(publishRoot, 'skills/modern-web');

processSkills(publishRoot, distDir, false);
await processSkills(publishRoot, distDir, false);

const builtSkillPath = path.join(publishRoot, 'skills', 'css', 'SKILL.md');
assert.ok(fs.existsSync(builtSkillPath), 'Built CSS SKILL.md should exist');
Expand Down
25 changes: 22 additions & 3 deletions serving/skills-cli/build-dist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { execSync } from "child_process";
import { fileURLToPath } from "url";
import matter from "gray-matter";
import * as esbuild from "esbuild";
import { AutoTokenizer } from "@huggingface/transformers";
import { scanAllGuides, scanDisciplineSkills } from "../../lib/guide-validation.ts";
import { getFeatureName } from "../lib/baseline.ts";
import { rootDir } from "../../lib/paths.ts";
Expand Down Expand Up @@ -92,10 +93,27 @@ function convertSkillToUseNpx(skillDest: string) {
fs.writeFileSync(skillDest, skillText);
}

export function processSkills(publishRoot: string, distDir: string, npx: boolean) {
async function getDescriptionTokenCount(content: string, tokenizer: any): Promise<string> {
if (!tokenizer || !content) return "";
try {
const parsed = matter(content).data;
if (!parsed.description) return "";
const tokens = await tokenizer(parsed.description, { add_special_tokens: false });
return ` (${tokens.input_ids.data.length} tokens)`;
} catch (err) {
return "";
}
}

export async function processSkills(publishRoot: string, distDir: string, npx: boolean) {
console.log("Scanning for skills (SKILL.md) in guides/...");
const skills = scanDisciplineSkills();

let tokenizer: any = null;
try {
tokenizer = await AutoTokenizer.from_pretrained("Xenova/all-MiniLM-L6-v2");
} catch (e) {}

for (const skill of skills) {
const skillName = skill.name;
const source = path.join(skill.dir, "SKILL.md");
Expand All @@ -107,7 +125,8 @@ export function processSkills(publishRoot: string, distDir: string, npx: boolean
const content = replaceMacros(fs.readFileSync(source, 'utf8'), source, { target });
fs.writeFileSync(path.join(skillDestDir, "SKILL.md"), content);

console.log(`Processed and copied skill ${skillName} (SKILL.md) to ${skillDestDir}`);
const tokenStr = await getDescriptionTokenCount(content, tokenizer);
console.log(`Processed and copied skill ${skillName} (SKILL.md)${tokenStr} to ${skillDestDir}`);
}

if (npx) {
Expand Down Expand Up @@ -255,7 +274,7 @@ async function main(opts: {publishRoot: string, version?: string, npx?: boolean}



const { skillsCount, skillNames } = processSkills(publishRoot, DIST_DIR, !!npx);
const { skillsCount, skillNames } = await processSkills(publishRoot, DIST_DIR, !!npx);

const { featuresCount, useCasesCount } = updateReadmeWithFeaturesAndUseCases(publishRoot);

Expand Down
Loading