clarity
Copilot instructions2.7k starsChanged 9 months agoMITView on GitHub
Clarity is an open-source TypeScript behavioral analytics library for tracking user interactions and session replays. Monorepo with Lerna/Yarn workspaces: Stack: TypeScript, Rollup, TSLint, Playwright, Lerna, Yarn workspaces Critical: clarity-js has two top priorities that must guide all development decisions: Rollup + TypeScript → multiple formats (CJS, ESM, IIFE minified). Build artifacts auto-cleaned to build/ or extension/ (gitignored). Build outputs per package: - clarity-js: clarity.js (CJS), clarity.module.js (ESM), clarity.min.js (minified), plus variants: clarity.extended.js, clarity.insight.js, clarity.performance.js, clarity.livechat.js, and dynamic agent builds (clarity.tidio.js,…
- Installs packages
Trending
Quiet since August.thin dataabout the whole repository
Who's talking about microsoft/clarity
- A Hacker News story“Clarity: Behavioral analytics library tracking DOM mutations, user interaction”Hacker News · Jan 9, 2026 · 1 points
- pudding-toy-5/blinkit-fe“Clarity.identify를 모든 AuthGuard 에서 실행하도록 수정”GitHub · Apr 23, 2025 · 1 reactions
- microsoft/clarity-apps“Clarity support for .NET MAUI”GitHub · Jul 15, 2024 · 1 reactions
- microsoft/clarity-mcp-server“All tools fail with "An error occurred while fetching the data" (query-analytics-dashboard, …”GitHub · Aug 22, 2026
- Kebechet/Maui.MicrosoftClarity“Maui Hybrid - BlazorWebView tracking doesnt work correctly”GitHub · Jul 15, 2024
The biggest 5 of 7 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 7
Talked about on GitHub and Hacker News (7 times).
On GitHub · 6
- Apr 23, 2025Clarity.identify를 모든 AuthGuard 에서 실행하도록 수정 — pudding-toy-5/blinkit-fe1 reaction · 6 comments
- Jul 15, 2024Clarity support for .NET MAUI — microsoft/clarity-apps1 reaction · 6 comments
- Aug 22, 2026All tools fail with "An error occurred while fetching the data" (query-analytics-dashboard, list-session-recordings, query-documentation-resources) — microsoft/clarity-mcp-server0 reactions
- Jul 15, 2024Maui Hybrid - BlazorWebView tracking doesnt work correctly — Kebechet/Maui.MicrosoftClarity0 reactions · 6 comments
- Nov 1, 2023Bug: Microsoft Clarity isn't displaying our map correctly in its recordings — hackforla/food-oasis0 reactions · 1 comment
1 more on GitHub
- Oct 16, 2023build(deps): bump clarity-js from 0.7.8 to 0.7.13 — bbonkr/resume0 reactions · 2 comments
On Hacker News · 1
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this copilot-instructions.md into the rules it gives an agent
10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
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
- Distinctive: line 19
Avoid blocking the main thread
- Very specific: line 63
Test helpers: test/helper.ts (root), packages/clarity-js/test/helper.ts (package-specific)
- Very specific: line 121
Build fails: Run yarn install first after clone/pull
- Very specific: line 122
Test failures: Ensure build artifacts exist with yarn build before running tests
- Very specific: line 124
TSLint errors: Only fix your changes, use yarn tslint:fix for formatting
- Very specific: line 130
If changing clarity-js APIs used by other packages, rebuild all from root
- Very specific: line 131
Follow TSLint rules: typedefs required, max 140 chars, let/const only, as assertions
- Distinctive: line 135
Always prioritize performance and bundle size: - avoid blocking main thread, minimize network requests, keep bundle small
- Distinctive: line 136
Check bundle size impact after changes (CI runs size checks with <2% growth threshold)
- Very specific: line 139
Use @src/<path> aliases for cross-module imports (e.g., from "@src/data/cookie", from "@src/data/metadata")
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Clarity Repository - Copilot Agent Instructions
Repository Overview
Clarity is an open-source TypeScript behavioral analytics library for tracking user interactions and session replays. Monorepo with Lerna/Yarn workspaces:
- clarity-js (packages/clarity-js): Core instrumentation library
- clarity-decode (packages/clarity-decode): Data decoder
- clarity-visualize (packages/clarity-visualize): Session replay visualization
- clarity-devtools (packages/clarity-devtools): Chrome extension (private)
Stack: TypeScript, Rollup, TSLint, Playwright, Lerna, Yarn workspaces
clarity-js Performance & Bundle Size Priorities
Critical: clarity-js has two top priorities that must guide all development decisions:
- Performance - As an analytics library running on diverse websites, clarity-js must not hurt website performance or impact metrics like INP (Interaction to Next Paint) or PLT (Page Load Time). Balance data collection needs with:
- Avoid blocking the main thread
- Minimize network requests
- Reduce payload size
- Bundle Size - Small bundle size is crucial for loading clarity-js quickly and starting data collection as soon as possible. Every byte matters.
Build & Development Commands
Installation
ALWAYS run yarn install before building or testing. (~25s, peer dependency warnings are normal)
Building
yarn build # All packages (~45s, Lerna parallel build)
yarn build:js # clarity-js only (~20s)
yarn build:decode # clarity-decode only
yarn build:visualize # clarity-visualize only
yarn build:devtools # clarity-devtools onlyRollup + TypeScript → multiple formats (CJS, ESM, IIFE minified). Build artifacts auto-cleaned to build/ or extension/ (gitignored).
Build outputs per package:
- clarity-js:
clarity.js(CJS),clarity.module.js(ESM),clarity.min.js(minified), plus variants:clarity.extended.js,clarity.insight.js,clarity.performance.js,clarity.livechat.js, and dynamic agent builds (clarity.tidio.js,clarity.crisp.js) - clarity-decode:
clarity.decode.js(CJS),clarity.decode.module.js(ESM),clarity.decode.min.js(minified) - clarity-visualize:
clarity.visualize.js(CJS),clarity.visualize.module.js(ESM),clarity.visualize.min.js(minified) - clarity-devtools: Output to
extension/directory for Chrome extension
Testing
yarn test # Root: Runs Playwright tests (all projects)
yarn test:ui # Root: Runs Playwright tests in UI mode
yarn workspace clarity-js test # clarity-js only (Playwright with clarity-js project)
yarn workspace clarity-decode test # clarity-decode only (Playwright with clarity-decode project)Tests use Playwright test runner configured in playwright.config.ts at the repo root. Each package has its own Playwright project configuration.
Test structure:
- Per-package tests:
packages/*/test/*.test.ts - Root e2e tests:
test/*.test.ts - Playwright auto-discovers test directories that have both
test/folder andpackage.json - Test helpers:
test/helper.ts(root),packages/clarity-js/test/helper.ts(package-specific)
Linting
cd packages/<package> && yarn tslint # Check linting
cd packages/<package> && yarn tslint:fix # Auto-fixImportant: Existing TSLint errors exist - only fix what you change. Key rules: max 140 chars, typedefs required, no var, use as not <> for assertions.
Project Architecture
Structure
packages/
clarity-js/src/ # Main package
core/ # Config, events, version.ts (source of truth)
layout/ # DOM tracking, mutations
interaction/ # User interactions
performance/ # Metrics
data/, diagnostic/, insight/, dynamic/
clarity-decode/ # Decoder (depends on clarity-js)
clarity-visualize/ # Visualization (depends on clarity-decode)
clarity-devtools/ # DevTools (depends on all three)
scripts/
bump-version.ts # Version bumping (updates version.ts + all package.json)
check-file-size.sh # Bundle size validation
playwright.config.ts # Playwright test configurationPer-package configs: tsconfig.json (ES5 target), tslint.json, rollup.config.ts, package.json
Common file patterns:
encode.tsfiles: Data encoding logic, found in various modules (use relative imports, not @src alias)rollup.config.ts: Per-package build configuration defining output formatshelper.ts: Test utility functions (root test/ and packages/clarity-js/test/)version.ts: Single source of truth for version (packages/clarity-js/src/core/version.ts)
Dependency chain: clarity-js → clarity-decode → clarity-visualize → clarity-devtools. Changes to upstream packages may require rebuilding dependents.
Versioning & Release
yarn bump-version # Patch (default)
yarn bump-version --part=minor # Minor
yarn bump-version --part=major # MajorUpdates version.ts, all package.json, lerna.json, and stages files. Then commit, push, create PR.
Environment
Node.js: 22+ required
Package manager: Yarn only (has yarn.lock, uses workspaces) - install globally: npm i -g yarn
Common Issues
- Build fails: Run
yarn installfirst after clone/pull - Test failures: Ensure build artifacts exist with
yarn buildbefore running tests - Peer dependency warnings: Expected and safe to ignore
- TSLint errors: Only fix your changes, use
yarn tslint:fixfor formatting - clarity-js changes not reflected: Rebuild all with
yarn buildfrom root
Making Changes
Workflow: yarn install → make changes → yarn build → yarn test → lint modified files
- If changing clarity-js APIs used by other packages, rebuild all from root
- Follow TSLint rules: typedefs required, max 140 chars,
let/constonly,asassertions - Build configs in
rollup.config.tsgenerate multiple formats (CJS, ESM, IIFE)
clarity-js specific considerations:
- Always prioritize performance and bundle size - avoid blocking main thread, minimize network requests, keep bundle small
- Check bundle size impact after changes (CI runs size checks with <2% growth threshold)
Import style for clarity-js:
- Use
@src/<path>aliases for cross-module imports (e.g.,from "@src/data/cookie",from "@src/data/metadata") - Exception:
encode.tsfiles use relative imports (e.g.,from "./encode")
Trust these instructions - validated by testing. Only search if you need specifics not covered here or encounter undocumented errors.
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
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.

