---
name: project-coding-standards
description: Coding style, architectural conventions, and PR review standards for the modern-web-guidance-src (guidance) repository. Use when authoring new code, refactoring features, writing CLI tools, adding server endpoints, or preparing PRs for review.
title: project-coding-standards
canonical_url: https://skilld.dev/gh/googlechrome/modern-web-guidance-src/project-coding-standards
last_updated: 2026-11-13T10:45:29.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install googlechrome/modern-web-guidance-src/project-coding-standards`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/project-coding-standards`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/googlechrome/modern-web-guidance-src/project-coding-standards) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/project-coding-standards`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/project-coding-standards --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/project-coding-standards --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Guidance Repository Coding Standards & Review Guidelines

## Overview
This skill defines the architectural principles, coding conventions, and PR review standards for the `modern-web-guidance-src` repository.

Follow these guidelines whenever authoring TypeScript, JavaScript, CLI commands, harness utilities, server endpoints, or dashboard code.

---

## PR Scope and Modularity

### Keep PRs Focused and Single-Purpose
- **Split multi-component features:** Do not combine backend data models, CLI tools, and frontend UI changes into a single monolithic PR.
- **Logical progression:** Structure larger features into small, stacked, or sequential PRs:
  1. Data layer / core libraries (parsing, normalization, abstractions)
  2. CLI workflows and execution commands
  3. UI / visualization components and dashboard views
- Smaller, well-scoped PRs are easier to review, test, and safely revert if regressions occur.

---

## Architectural Principles

### Use Existing Abstractions & CLI Runners
- **Reuse repository tooling:** When interacting with LLMs or executing agent workflows, use the shared repository abstractions in `config.environment` (such as `config.environment.antigravityCliBin` or `config.environment.jetskiCliBin`) instead of writing custom REST API clients, bespoke fetch loops, or ad-hoc token validators.
- **Environment and flag handling:** Respect standard environment toggles (such as `GD_DEV_USE_JETSKI === '1'`) and omit non-essential flags (e.g., omit `--yolo` for non-interactive or diagnostics tasks).

### Single Source of Truth & Canonical Enums
- **Never hardcode string constants for agents:**
  - Use centralized enums like `Agents` from `src/harness/config.ts` (`Agents.ANTIGRAVITY_CLI`, `Agents.JETSKI_CLI`, `Agents.CLAUDE_CODE`, `Agents.CODEX_CLI`).
- **Extract metadata from source-of-truth files:**
  - Never infer properties (such as `targetFile` or `agent`) using fragile path heuristics or regexes if canonical metadata files (e.g., `evals.json`) exist in the parent hierarchy. Extract canonical properties directly from `evals.json`.

### Modular Prompt & Template Management
- **Separate prompts from execution logic:** Do not embed long prompt templates, system instructions, or markdown synthesizer templates inside runtime runner files.
- Place prompts and instructions into dedicated modules (e.g., `*-prompts.ts`) to maintain clean separation of concerns.

---

## File, Git, & Config Integrity

### Never Weaken Shared Tooling or tsconfig
- **Strict type safety is non-negotiable:** Never modify shared root configurations (`tsconfig.json`, `.oxlintignore`, `package.json`) to bypass typecheck or lint failures.
- Fix types properly with TypeScript interfaces and types, or use targeted JSDoc annotations in `.js` files.

### Targeted Remote I/O & Robust Caching
- **Scope remote storage operations:** When downloading from remote stores (such as Cloud Storage/GCS buckets), scope queries and downloads strictly to the specific prefixes and subdirectories needed for the task. Never fetch entire buckets or unrelated directories.
- **Local caching first:** Always check whether required assets or result files already exist locally before initiating remote downloads, avoiding redundant network traffic.

### Keep Repository Clean of Generated Artifacts
- **Ignore transient outputs:** Never commit test outputs, debug files, local caches, or working directories.
- Store temporary data in standard output locations (e.g., `results/suites/`, `out/`) and ensure `.gitignore` excludes transient files.

---

## Frontend & Dashboard Guidelines

### Dual-Environment Compatibility (Static vs. Local Server)
- **Graceful degradation:** The evaluation dashboard operates in both static hosted mode (e.g., GitHub Pages) and local server mode (`gd dashboard`). Features, actions, or API endpoints requiring a local Node server must detect static mode and gracefully hide or disable themselves.
- **Explicit data sourcing:** When requesting data from local server endpoints, pass the data source context (such as `?source=local`) so the server can distinguish local file operations from remote streaming.

### Disambiguate Multi-Run and Temporal Data
- **Handle multiple runs gracefully:** Do not assume only a single run exists per day or per task. Distinguish runs using explicit run indices and timestamps to prevent datasets from overwriting or collapsing together.
- **Robust query parameter handling:** Ensure URL query parameters are safely parsed with proper fallbacks, preserving dashboard state across navigations.

### Safe URL & Path Construction
- **Avoid protocol-relative URL bugs:** When constructing URLs from path variables, sanitize slashes to avoid accidental leading double slashes (`//...`), which browsers interpret as protocol-relative hostnames.

### UI Precision & Alignment
- **Mathematical centering:** Ensure chart markers, badges, indicators, and tooltips are centered horizontally and vertically over their target elements so visual associations are unmistakable.

---

## Verification & Testing Gates

### Tiered Preflight Gates
All changes must pass linting, typechecking, and tests before PR submission:
- **Fast dev check (lint & typecheck):**
  ```bash
  pnpm typecheck && pnpm lint
  ```
- **Full preflight gate (all PRs):** Bundles build, typecheck, lint, and parallel unit tests across all workspaces:
  ```bash
  pnpm run preflight
  ```
- **Browser E2E gate (dashboard / UI changes):** Playwright browser tests are not included in `pnpm run preflight` and must be executed when touching frontend visualizers, dashboard code, or server endpoints in `src/dashboard/`:
  ```bash
  pnpm run test:e2e
  ```
  *(Run `pnpm run setup:playwright` first if browser binaries are not installed).*

### Domain-Specific Validation
- **Serving & Skills:** When modifying skills packaging, verify with `pnpm run publish-skills --dry-run`.
- **Guides & Graders:** When authoring or updating evaluation capsules, verify grader calibration via `gd dev <guide> --test-grader`.
- **Clean Git Tree:** The build must produce zero uncommitted side effects or untracked artifacts (`git status` must remain clean).

### Code Hygiene
- **Safe data parsing:** Never use `eval()` to parse data or JSON; use `JSON.parse()` or dedicated parsers.
- **Clean regular expressions:** Avoid raw or unescaped control characters in regular expressions; use explicit Unicode escapes (e.g., `[\u001b\u009b]`).

---

## Quick Reference Checklist Before Submitting PRs

1. [ ] **PR Scope:** Focused on a single feature, library, or UI component (no monolithic multi-component PRs).
2. [ ] **Abstractions:** Reuses repository CLI runners (`config.environment`) and avoids custom API clients.
3. [ ] **Enums:** Uses the `Agents` enum from `src/harness/config.ts` rather than raw string constants.
4. [ ] **Metadata:** Reads properties from canonical metadata files (`evals.json`) instead of path heuristics.
5. [ ] **Prompts:** Extracted into dedicated `*-prompts.ts` or constants modules.
6. [ ] **Configs:** Root `tsconfig.json`, `package.json`, and `.oxlintignore` are untouched unless explicitly intended.
7. [ ] **Remote I/O & Git:** Remote fetches are strictly scoped and cached; no transient debug artifacts committed.
8. [ ] **Dashboard/UI:** Handles static vs. local server modes; URL parameters safely parsed and sanitized.
9. [ ] **Verification:** `pnpm run preflight` (and `pnpm run test:e2e` for `src/dashboard/` changes) passes with 0 errors.
