chore: bootstrap Claude setup

Add root CLAUDE.md, docs/architecture.md, LESSONS.md, .env.example,
.claude/settings.json hooks (PostToolUse JS syntax check, Stop hook
validating manifest.json + node --check on all JS), and GitHub
Actions workflows (ci.yml, version.yml) for this plain-JS Chrome
extension with no existing build/lint/test tooling.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Sonnet 5 committed 2026-10-18 15:02:43 +02:00
1 parent c07cbfb614
commit d6598d0b31
9 files changed
+217

No files matched your search

+1
View File
@@ -0,0 +1 @@
2
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Stop hook: quickest meaningful check available in this project.
# No test runner or linter is configured yet, so this validates:
# 1. manifest.json is valid JSON.
# 2. every tracked .js file passes `node --check` (syntax only).
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
node -e "JSON.parse(require('fs').readFileSync('manifest.json', 'utf8'))"
status=0
while IFS= read -r -d '' file; do
node --check "$file" || status=1
done < <(git ls-files -z '*.js')
exit "$status"
+25
View File
@@ -0,0 +1,25 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "file=$(cat | python3 -c 'import json,sys; print(json.load(sys.stdin).get(\"tool_input\",{}).get(\"file_path\",\"\"))'); case \"$file\" in *.js) node --check \"$file\" ;; esac"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/stop-check.sh\""
}
]
}
]
}
}
+2
View File
@@ -0,0 +1,2 @@
# No environment variables are read by this project today.
# This file is kept as a placeholder, in sync with the code, for when one is added.
+24
View File
@@ -0,0 +1,24 @@
name: CI
on:
pull_request:
branches: [development]
push:
branches: [development, main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
# No linter or test suite is configured for this plain-JS browser extension
# (no package.json/bundler). This validates manifest.json and runs a syntax
# check on every JS file, matching the local Stop hook.
- name: Validate manifest.json
run: node -e "JSON.parse(require('fs').readFileSync('manifest.json', 'utf8'))"
- name: Syntax check (node --check)
run: |
find . -name "*.js" -not -path "./.git/*" -print0 | xargs -0 -n1 node --check
+72
View File
@@ -0,0 +1,72 @@
name: Version bump
on:
push:
branches: [development, main]
permissions:
contents: write
jobs:
bump:
if: github.actor != 'github-actions[bot]' && !contains(github.event.head_commit.message, '[skip ci]')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version in manifest.json
id: bump
run: |
set -euo pipefail
current=$(node -p "require('./manifest.json').version")
IFS='.' read -r major minor patch <<< "$current"
if [ "${{ github.ref_name }}" = "development" ]; then
patch=$((patch + 1))
else
# push to main: MINOR bump only when this commit is already part of
# development's history (i.e. an approved development -> main merge
# PR); otherwise treat it as a direct hotfix push (PATCH bump).
if git fetch origin development >/dev/null 2>&1 && \
git merge-base --is-ancestor "$(git rev-parse HEAD)" origin/development; then
minor=$((minor + 1))
patch=0
else
patch=$((patch + 1))
fi
fi
new_version="$major.$minor.$patch"
node -e "
const fs = require('fs');
const m = JSON.parse(fs.readFileSync('manifest.json', 'utf8'));
m.version = '$new_version';
fs.writeFileSync('manifest.json', JSON.stringify(m, null, 2) + '\n');
"
echo "new_version=$new_version" >> "$GITHUB_OUTPUT"
- name: Commit version bump
run: |
git add manifest.json
git commit -m "chore(release): v${{ steps.bump.outputs.new_version }} [skip ci]"
git push origin HEAD:${{ github.ref_name }}
- name: Merge main back into development
if: github.ref_name == 'main'
run: |
if git ls-remote --exit-code --heads origin development >/dev/null 2>&1; then
git fetch origin development
git checkout -B development origin/development
git merge --no-edit origin/main
git push origin development
else
echo "No development branch yet; skipping merge-back."
fi
+41
View File
@@ -0,0 +1,41 @@
# CLAUDE.md
## Overview
Phenocheck is a Manifest V3 Chrome extension that shows estimated human phenotypes
for X.com (Twitter) users based on their declared location. No build step: plain
JS/CSS loaded directly by the browser.
## Commands
- No package manager, build, lint, or test tooling exists yet (no `package.json`).
- Load locally: open `chrome://extensions`, enable Developer mode, "Load unpacked",
select the repo root.
- Quick syntax check: `node --check <file>.js` (used by the Claude hooks below).
- Validate the manifest: `node -e "JSON.parse(require('fs').readFileSync('manifest.json'))"`.
## Architecture
- `manifest.json` — MV3 manifest: permissions, content scripts, icons.
- `background.js` — service worker.
- `content.js` / `content.css` — injected into x.com / twitter.com pages.
- `data/data.js` — phenotype/location dataset loaded before `content.js`.
- `images/` — icons and phenotype images (including `images/phenotypes/custom/`).
- See `docs/` for anything deeper than this overview.
## Conventions
- Plain ES JS (no bundler, no transpiler, no framework). Keep it that way unless asked.
- Keep `manifest.json` the source of truth for the extension version
(`MAJOR.MINOR.PATCH`), bumped only by `.github/workflows/version.yml`.
## Workflow quirks
- Host is Gitea (`git.zenvairo.es`), not GitHub — use `tea`, not `gh`.
- No `development` branch exists yet; work directly against `main` via task branches
until one is created.
## Deployment
- Not applicable: this is a browser extension loaded unpacked / published to a
web store, not a deployed web service.
## Gotchas
- There is no linter, formatter, or test runner configured yet. The Stop hook only
runs `node --check` on the extension's JS files and validates `manifest.json`.
- No environment variables are read by the code today; `.env.example` is a
placeholder for when that changes.
+6
View File
@@ -0,0 +1,6 @@
# LESSONS.md
Recurring mistakes and how to avoid them. Read before starting work; add an entry
whenever the same mistake happens twice.
(No recurring mistakes recorded yet.)
+29
View File
@@ -0,0 +1,29 @@
# Architecture
Phenocheck is a Manifest V3 Chrome extension with no build step.
## Components
- `manifest.json` — declares permissions (`storage`, `cookies`), host permissions
for `x.com` / `twitter.com`, the background service worker, content scripts, and
web-accessible resources (phenotype images).
- `background.js` — the extension's service worker.
- `content.js` + `content.css` — injected into matched pages at `document_idle`;
reads the page DOM and renders phenotype estimates.
- `data/data.js` — static dataset (location → phenotype mapping or similar), loaded
before `content.js` so its globals are available to it.
- `images/icons/` — toolbar/extension icons.
- `images/phenotypes/` (incl. `images/phenotypes/custom/`) — images shown in the
injected UI, exposed via `web_accessible_resources`.
## Data flow
1. `background.js` fetches the profile's declared "Account based in" country via
X's internal `AboutAccountQuery` API (using the `cookies` permission for auth).
2. `content.js` requests that country for the profile being viewed, with an
in-memory cache keyed by handle.
3. It maps the country to an estimate using `data/data.js` (plus hardcoded
per-handle overrides in `content.js`).
4. It renders the result into the page using `content.css` for styling and images
from `images/phenotypes/` (or `images/phenotypes/custom/` for overrides).
No external backend of our own is involved; the only network calls are to X's own
internal API, made from the background service worker.