agentleFS
aker-devaker-dev/microfolio/CLAUDE.md

microfolio

CLAUDE.md144 starsChanged 3 months agoMITView on GitHub

.mcp.json declares the official Svelte MCP server (@sveltejs/mcp): live documentation and a svelte-autofixer that validates Svelte source. Prefer it over recalling Svelte 5 semantics from memory. It replaced svelte-complete.txt, an 810 KB documentation dump that had been frozen since July 2025. .claude/settings.json allowlists this project's own scripts so pnpm lint, pnpm build and friends run without a prompt. microfolio is a static portfolio generator built with SvelteKit 2, Svelte 5, and Tailwind CSS 4. It uses a file-based CMS (Markdown…

  • Reads credentials
  • Deletes or force-pushes

The file

We split this CLAUDE.md into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All routes use server-side loading (+page.server.js) that reads content from the filesystem at build time:

    line 81
  2. Very specific:

    All custom components use Ak prefix (e.g., AkHeader, AkFooter, AkProjectCard, AkProjectSummary, AkFilters, AkLightbox, AkOptimizedImage).

    line 113
  3. Very specific:

    Default locale set in $lib/config.js (siteConfig.locale)

    line 151

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

.mcp.json declares the official Svelte MCP server (@sveltejs/mcp): live documentation and a svelte-autofixer that validates Svelte source. Prefer it over recalling Svelte 5 semantics from memory. It replaced svelte-complete.txt, an 810 KB documentation dump that had been frozen since July 2025.

.claude/settings.json allowlists this project's own scripts so pnpm lint, pnpm build and friends run without a prompt.

Project Overview

microfolio is a static portfolio generator built with SvelteKit 2, Svelte 5, and Tailwind CSS 4. It uses a file-based CMS (Markdown + YAML frontmatter) for content. Developed by AKER.

The 1.0 stability promise (README › Stability) freezes until 2.0: the content layout and frontmatter keys, the keys of config.js (add-only), the commands, and the files update-microfolio never touches. A change to any of those is a major version, not a minor.

Development Commands

pnpm dev              # Development server (port 5555)
pnpm build            # Production build (via build.js → vite build)
pnpm deploy           # Build with NODE_ENV=production (sets /microfolio base path)
pnpm preview          # Preview production build (port 2001)
pnpm lint             # Prettier check + ESLint
pnpm format           # Prettier auto-fix
pnpm optimize-images  # Generate WebP thumbnails via sharp
pnpm clean-images     # Remove generated optimized images
pnpm test             # Unit tests (Vitest, single run)
pnpm test:watch       # Unit tests in watch mode
pnpm test:e2e         # End-to-end tests (Playwright, against pnpm dev)
pnpm test:smoke       # Smoke tests (Playwright, against build/ — run pnpm deploy first)
pnpm screenshots      # Regenerate doc/screenshots (needs a dev server; PORT=…)

Those two ports are a Daft Punk nod — Interstella 5555, and Discovery, the album it sets to pictures. strictPort is deliberately unset, so a busy port sends Vite to the next one and it prints where it actually landed. playwright.config.js and scripts/screenshots.js both default to 5555 because each means "wherever the dev server is": Playwright reuses a running one rather than starting its own, and the screenshot script requires one.

pnpm screenshots drives scripts/screenshots.js. Each shot is one 1280x1028 viewport captured by element, not a full page, and every route is longer than that — so no shot in the current set reaches the footer. A version bump alone therefore does not require regenerating them, and the footer fix of 2026-08-19 left all twelve untouched. Bump package.json first anyway if you regenerate for a release, in case a future shot does frame it. Dark-mode shots go through prefers-color-scheme, not the footer toggle.

Package manager: pnpm 11, as engines.pnpm. There is deliberately no packageManager field. An exact pin makes pnpm switch to that version, and for any 11.x target the switch goes through @pnpm/exe (packageManagerDeps() only drops it from pnpm 12) — which has published no macOS Intel binary since pnpm 11: @pnpm/macos-x64 stops at 10.34.5. So on an Intel Mac, the moment the installed pnpm differs from the pin — which it does at every pnpm release — install, dev and build all die on Cannot verify the identity of the @pnpm/exe.darwin-x64 native binary. Apple Silicon never sees it. The exact version is pinned in .github/workflows/deploy.yml instead, where the runner is linux-x64. pnpm 12 will reopen the question.

Node.js 22.13+ required — pnpm 11 uses node:sqlite and crashes on Node 20. Both engines are enforced at install time: .npmrc sets engine-strict=true, and pnpm throws on an unsatisfied engines.pnpm regardless. engines.node is a floor, not the tested version: CI runs the Active LTS (24 today), and the Homebrew formula installs whatever the unversioned node is, which tracks Current. Three different Node majors are therefore in play at once, on purpose.

The Homebrew formula depends on node, never node@N. Every versioned Node formula is keg-only, so Homebrew never links one onto PATH — and Homebrew's pnpm is the JavaScript package, whose shebang is #!/usr/bin/env node and which only depends on node for :build and :test. With node@22 a Mac with no Node of its own — which is every Mac out of the box — got env: node: No such file or directory from microfolio and from a bare pnpm alike. Pinning the LTS with node@24 does not fix it: it is keg-only too, and putting its opt_bin on the wrapper's PATH would rescue microfolio … while leaving the hundred pnpm … commands in the docs broken.

pnpm 11 no longer reads the pnpm field in package.json — its settings live in pnpm-workspace.yaml, where allowBuilds lists which dependencies may run install scripts (build scripts are blocked by default) and minimumReleaseAgeExclude records packages accepted despite being published in the last 24h.

Testing

  • Unit — Vitest, co-located src/**/*.test.js and scripts/**/*.test.js. vitest.config.js deliberately omits the SvelteKit plugin, so these cover plain modules only (the content parsing, the update script) and run in well under a second. They run on every fork's CI too, so they must hold on a site that set its own url and deleted the demo zip: markdown.test.js mocks config.js for the base-path case rather than read the site's, and install-demo.test.js skips the two tests that need the real archive when it is absent. A 0.14.0 fork that followed the docs had three red tests and a red badge for this.
  • End-to-end — Playwright, specs in e2e/. It starts its own dev server, or reuses one already running on the port. Set PLAYWRIGHT_PORT to exercise the CI path locally without colliding with a dev server on 5555.
  • Smoke — pnpm test:smoke, e2e/smoke/ under playwright.smoke.config.js. The only suite that loads build/ rather than a dev server: it serves the artefact with vite preview and walks its pages, asserting each returns 200, hydrates, throws nothing, and asks for no same-origin file it does not have. Cross-origin requests are filtered out — the font CDN and the tile server are somebody else's uptime and have no business failing a deploy. Deliberately shallow: behaviour is the e2e suite's job, this one is about the artefact. It runs in ~5s and it earns its place — reverting the ?worker&url fix in the map route makes it fail with 404 …/maplibre-gl-shared.mjs while all 29 e2e tests still pass.
  • The smoke suite always runs against a production build, because vite preview sets NODE_ENV=production itself whatever the build was made with. So it serves under /microfolio even after a plain pnpm build, and the origin root 404s. playwright.smoke.config.js sets NODE_ENV=production at the top of the file so getBasePath() agrees with the server by construction; locally, pair it with pnpm deploy, not pnpm build. It lives there rather than in the test:smoke script because a VAR=value prefix is POSIX shell syntax that Windows does not understand — for the same reason pnpm deploy is node build.js --production and not a NODE_ENV= prefix. Its routes are relative and its baseURL ends in a slash — Playwright joins them with new URL(), where a leading slash would drop the base path.
  • CI (.github/workflows/deploy.yml) runs lint, unit tests and e2e, then builds, then smoke-tests the build before uploading it. The demo unzip, lint and e2e steps run only on aker-dev/microfolio (if: github.repository == …): a fork or clone publishes someone's portfolio, whose Markdown was not written for Prettier and whose projects are not the demo the e2e suite counts on — there, unit tests, build and smoke are what runs. For the same reason the smoke suite's project page is the first valid project found in content/projects/, not example-project, which a real site deletes. It has no image step of its own: pnpm build optimizes first, under siteConfig.images.optimizeOnBuild, so a deployed site and a local one carry the same images. example_projects.zip ships only JPEGs plus one small real PDF per project, and the demo was published at full size until that was true.
  • A second job builds on windows-latest — install, pnpm demo, build, smoke — and deliberately does not gate deploy, which keeps needs: build: the site ships from the ubuntu build, so a Windows regression is a red check to fix rather than a reason to hold a publication. It exists because microfolio is written on macOS and published from Linux, and the Windows path was only ever tested by hand: build.js spawned npx, which is npx.cmd there and which Node refuses to launch without a shell, so pnpm build died on spawn npx ENOENT. Worse and quieter, generate-optimized-images.js and clean-optimized-images.js compared import.meta.url against a hand-built `file://${process.argv[1]}` — never equal on Windows, where argv[1] is C:\… and the URL is file:///C:/… — so both scripts exited 0 having done nothing, and a fixed build would have shipped a site with no WebP at all. Nothing spawns a shim any more: build.js runs process.execPath against a bin path resolved through the dependency's package.json, because vite's exports map publishes ./package.json but not ./bin/*. Lint and e2e stay on ubuntu — neither is platform-specific, and both would only double the wait.
  • Some specs run with javaScriptEnabled: false to assert that /list and /projects really do ship their content in the HTML, and others under a phone viewport. Everything else waits on data-hydrated, an attribute +layout.svelte sets on <html> once the tree is interactive: the whole page is prerendered, so a click can otherwise land on markup with no listener attached and be lost. That failure only ever showed on the slower CI runner.

What a green suite will not tell you

Look at anything visual. The rebuilt lightbox shipped with its panel translucent, the page showing through the metadata, and every test passed — they asserted presence, not legibility. Take a screenshot and read it.

Compare checksums on anything generated. Two of the documentation screenshots were byte-identical for a while because a scroll silently did nothing; the images looked plausible individually. md5 -q doc/screenshots/*.png | sort | uniq -d catches it in a second.

Do not trust a long-running dev server. One left running on 5555 served stale code twice in a single session, once nearly leading to the conclusion that a working feature was broken. Verify against a fresh server: CI=true PLAYWRIGHT_PORT=5199 pnpm test:e2e.

A green dev server says nothing about the build. MapLibre builds its worker URL at runtime from a name it assembles, which Rollup cannot see through: the production build referenced a worker chunk it had never emitted, so the map came up blank with no tile request at all — while pnpm dev was perfect. pnpm build then serving build/ is the only way that surfaces. pnpm test:smoke now does exactly that on every deploy, but it only visits the routes it is told about: a new page is not covered until it is added to PAGES in e2e/smoke/built-site.spec.js.

An overlay that covers something interactive also captures its events. The map's veil spanned the whole map, so selecting a project froze it — no panning, no zooming, no reaching another marker. It went unnoticed for as long as it did because looking at a screenshot cannot reveal it either: the fix is pointer-events-none on the layer and pointer-events-auto on what should still be clickable, and the check is document.elementFromPoint() on a spot that ought to reach through.

Architecture

Content System

Projects live in /content/projects/{slug}/ with:

  • index.md — YAML frontmatter (title, date, location, coordinates, type, tags, featured, authors) + Markdown body
  • thumbnail.jpg — Project thumbnail (optional thumbnail.webp for optimized version)
  • images/, videos/, documents/ — Resource subdirectories

Homepage content: /content/index.md. About page: /content/about.md.

Data Loading

All routes use server-side loading (+page.server.js) that reads content from the filesystem at build time:

  • src/routes/+page.server.js — Loads the homepage via loadMarkdownPage(), then filters loadProjects() on featured: true
  • src/routes/projects/+page.server.js — Delegates to $lib/utils/projects.js shared loader
  • src/routes/projects/[slug]/+page.server.js — Validates the frontmatter, then loads resources and EXIF metadata; a project that fails validation 404s rather than half-rendering
  • src/routes/list/, map/, about/ — Each has its own +page.server.js

Content parsing goes through $lib/utils/markdown.js, never an ad-hoc split('---'): its regex stops at the first closing delimiter, so a --- horizontal rule in the body stays in the body.

Key Utilities

  • $lib/utils/paths.js — getBasePath(): returns /microfolio in production, empty string otherwise (mirrors svelte.config.js logic). Server-only: it reads process.env, so client code uses base from $app/paths instead
  • $lib/utils/projects.js — loadProjects(): shared project loading used by the homepage, /projects, /list, /map. Validates each project, sorts by date, and reports skipped ones once per build
  • $lib/utils/markdown.js — splitFrontmatter(), renderMarkdownBody(), loadMarkdownPage()
  • $lib/utils/projectFrontmatter.js — parseProjectFrontmatter(): returns { metadata } or { problem } with a plain-language reason
  • $lib/utils/locale.js — getTextDirection(), shared by hooks.server.js (prerender) and +layout.svelte (client)
  • $lib/utils/imageMetadata.js — EXIF/IPTC extraction via exifreader (credit, camera, GPS, etc.)
  • $lib/utils/date.js — formatProjectDate(): the YYYY-MM shown everywhere a project is dated. It was written out four times before
  • $lib/config.js — Site config, and deliberately only what someone setting up their site needs: title, url, social links, navigation, ogImage, images.optimizeOnBuild, font.url, font.family, lightbox.hideControlsDelay, lightbox.showExtendedMetadata. Tile provider URLs and zoom limits live in the map route instead
  • $lib/utils/seo.js — absoluteUrl(): takes a route path without the base, because siteConfig.url already carries it
  • $lib/i18n.js — Internationalization setup with svelte-i18n (en/fr active, more commented out)

Styling

  • Tailwind CSS 4 configured in src/app.css with @tailwindcss/typography plugin
  • Custom theme in src/lib/theme.css
  • Dark mode has two layers: a prefers-color-scheme media query for the default, and a .dark / .light class on :root for the explicit toggle in AkFooter (persisted in localStorage). An inline script in app.html applies the stored choice before first paint to avoid a flash
  • Font: siteConfig.font — url (Bunny Fonts by default) and family. hooks.server.js writes them into app.html's %microfolio.font% at prerender: preconnect + stylesheet, then an unlayered :root{--default-font-family:…} that beats the @theme default in app.css. It lives in config rather than app.html because the update script protects config.js and overwrites app.html; a config without a font block falls back to IBM Plex rather than to no font
  • src/app.css also holds the rules no component owns: a global :focus-visible outline so keyboard focus is never invisible, .ak-filters :disabled for the pre-hydration state described under Components, and the map block — .ak-marker plus the overrides that flatten MapLibre's own chrome. Those last ones are written with two classes rather than one, because MapLibre's stylesheet is imported by the map route and therefore lands after this file: matching its specificity would leave the winner down to injection order

Components

All custom components use Ak prefix (e.g., AkHeader, AkFooter, AkProjectCard, AkProjectSummary, AkFilters, AkLightbox, AkOptimizedImage). Datatable components (Datatable, Search, ThSort, ThFilter, Pagination, RowCount, RowsPerPage) power the /list view using @vincjo/datatables.

AkFilters builds its TableHandler in the component body rather than in an $effect, because effects never run on the server — that is what puts the rows of /list and the cards of /projects in the prerendered HTML. Only restoring state from the query string still waits for the browser. Its controls carry disabled until onMount, so a click landing before hydration cannot be silently lost. Below md its whole panel collapses behind a button that counts the active filters.

Two components render a project, and the room decides which. AkProjectCard leads with a 4:3 thumbnail and belongs in the grids of the homepage and /projects. AkProjectSummary is text-first and belongs where an image would crowd the text out: the map callout, and /list below md. The whole summary is one link, which is why its tags are plain text — an anchor cannot contain other links.

The map is MapLibre GL on OpenFreeMap, worldwide OpenStreetMap vector tiles with no API key, in Positron for light and Dark for dark — the two neutral styles it publishes, which is why nothing desaturates the map any more. The styles and zoom limits sit at the top of map/+page.svelte, not in config.js. Things about it that are not guessable:

  • Coordinates swap. Frontmatter is [latitude, longitude], MapLibre wants [longitude, latitude]. toLngLat() in map/+page.svelte is the only place they meet — keep it that way
  • Switching theme swaps the whole style, since light and dark are two published styles rather than one repainted. Markers survive it: they are DOM nodes the map owns, not part of the style. Verified, not assumed — 30 before and after (31 projects, one of which names no place)
  • fitMaxZoom exists because fitting one project would otherwise frame its roof. The map's own maxZoom used to do that job back when it was capped at 6
  • MapLibre's chrome fights back twice. Its icons are baked dark SVG data URIs with variants only for Windows' forced-colors mode, so they are inverted in dark; and its compact attribution paints itself white through a two-class rule that ties with ours and wins on order, so ours carries a third class. Without it the bar was white with white links on it

Markers are built with createElement, out of reach of a Svelte template, so the star a featured project carries is the same IconStarFilled component mounted into the element (mount/unmount from svelte) — one original, rather than a traced copy free to drift.

MapLibre 6 has no default export; (await import('maplibre-gl')).default is undefined, and every example online still shows otherwise.

/list renders its rows twice. A list of AkProjectSummary below md, the seven-column table from md up — the table needed 840px inside 311px on a phone. Both live in src/routes/list/+page.svelte and iterate the same handler.rows. Add a column to one and you have to add it to the other; nothing in the markup says so. The cards sit flush and are parted by divide-y, echoing the rule between table rows: leave a gap and the rule lands on a card edge, reading as an underline rather than a separation.

Build & Deployment

  • Static site generation via @sveltejs/adapter-static (output: /build)
  • svelte.config.js dynamically generates prerender entries by scanning /content/projects/
  • vite.config.js copies the content/ directory to build output via vite-plugin-static-copy (build only, not dev)
  • Icons are local components, src/lib/icons/Icon*.svelte, generated by pnpm icons (scripts/icons.js) from the public Iconify API — 14 Carbon (Apache-2.0) and 3 Akar Icons (MIT), licences in src/lib/icons/README.md. Each spreads its props onto a 1.2em <svg>, exactly what unplugin-icons used to emit. To add one: name it in the script's ICONS list, run pnpm icons, import it. @iconify/json was 437 MB of the 643 MB node_modules before this; the folder is in .prettierignore because it is generated
  • The site's address is written once, as siteConfig.url. The base path is its pathname (empty in dev, so pnpm dev keeps serving from /), and every absolute URL — og:image, og:url, canonical, sitemap — is built from it by absoluteUrl(). getBasePath() is the single definition and svelte.config.js imports it
  • There is no CNAME file. Published through an Actions workflow, GitHub Pages ignores any CNAME in the build — the custom domain is set in the repository settings. The one that used to sit in static/ did nothing
  • sitemap.xml and robots.txt are prerendered endpoints, listed explicitly in svelte.config.js entries because nothing links to them and the crawler would never find them
  • Layout (+layout.js): prerender = true, trailingSlash = 'always'
  • Deployment to GitHub Pages is triggered by a push to main — .github/workflows/deploy.yml (it used to be a separate preview branch until 0.13.2; main is simpler for forks and clones, which publish with a plain push). Work happens on dev; publishing means merging dev into main, and a release tags that merge. The workflow also runs on dev, without deploying (the deploy job and the Pages steps carry if: github.ref == 'refs/heads/main'), so every push to dev is checked by the real runner first. The preview branch was deleted on 2026-08-21: GitHub Pages serves one site per repository, so a staging site would need a second repository and a build-time override of siteConfig.url — neither exists
  • That workflow runs pnpm demo after installing, so the demo content CI builds and tests against comes from content/projects/example_projects.zip, not from the working copy. .gitignore ignores the demo by name — a block between two marker comments that pnpm generate-demo rewrites from the dataset — and never content/projects/*: a user's projects must reach their repository, and until 0.13.2 they did not, so a site that followed the docs was published by GitHub Pages without a single one of them. It then runs lint, unit tests and e2e before the build
  • pnpm update-microfolio (scripts/update-microfolio.js) moves a site to a release. It downloads the version the site runs and the target from GitHub and decides file by file (decide(), three-way): PROTECTED — content/, src/lib/config.js, static/favicon.svg, static/og.jpg, .env* — is never touched; a file the user never edited takes the new version; one edited on both sides goes through git merge-file, and lands as <file>.upstream next to the user's when that fails; what changed in config.js upstream is printed, not applied. It refuses a dirty working tree so git checkout . && git clean -fd can undo it. Plain Node with no dependencies, on purpose: a copy of it runs in a site that predates it, which is how a 0.x site gets to 1.0. The Homebrew formula should grow a microfolio update that calls it
  • pnpm demo (scripts/install-demo.js) unzips the set into content/projects/; --remove deletes exactly the directories the zip lists. It reads the zip itself — central directory, then stored or deflated entries through inflateRawSync — because the command is for users and Windows ships no unzip. CI and generate-demo --install call the same function
  • The zip holds the thirty-project "Bauhaus" demo set, produced by pnpm generate-demo (scripts/generate-demo-projects.js — maintainer tool, shells out to zip). The dataset is handwritten in scripts/demo-projects/projects.js; the images are seeded geometric compositions (compose.js), so regeneration is byte-identical until the dataset changes. Tags never repeat a project's type and there is no umbrella tag; at least six projects share public-space, because the e2e pagination specs filter on it with rows=5 and need a second page. Eleven are featured so the homepage grid holds twelve with example-project. --install refreshes the unzipped working copies (it deletes the gitignored project directories and re-extracts)

Internationalization

  • Locale strings in src/lib/locales/{lang}.json
  • Default locale set in $lib/config.js (siteConfig.locale)
  • RTL support via getTextDirection(): hooks.server.js fills the lang and dir placeholders in app.html at prerender, and +layout.svelte updates them when the locale changes client-side

Deferred

JSON-LD structured data, deliberately left out of the sharing work: a CreativeWork per project and a site identity on the home page. The frontmatter already carries everything it needs — title, date, location, authors, type, tags — so it is a matter of emitting it, not of gathering it.

Project Metadata Schema

title and date are required. A project missing either, or whose YAML does not parse, is skipped from every view and named in a summary at the end of the build — it never fails the build. A missing thumbnail.jpg does not disqualify a project: it sets hasThumbnail: false and the UI shows a placeholder. Validation lives in $lib/utils/projectFrontmatter.js.

title: 'Project Title' # required
date: '2023-01-01' # required, must be parseable by new Date()
location: 'City, Country'
coordinates: [latitude, longitude] # For map display
description: 'Project description'
type: 'architecture' # Used for filtering
tags: ['tag1', 'tag2']
authors:
  - name: 'Author Name'
    role: 'Role'
featured: true # Shows on homepage

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.