Dark mode

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

It shows a real, working example of a coding agent handling a full production CSS feature end-to-end, from prompt to commit.

Read this as

Simon Willison asked Claude Code, an AI programming assistant, to add a dark mode to his blog. It wrote the CSS theme system in one pass, which respects the reader's device setting and includes a footer toggle for auto, light, or dark. Claude Code also built the animated demo image from two screenshots using the ImageMagick graphics tool.

Willison used Claude Code for web to ship dark mode on his blog from a single one-line prompt, with the full diff on GitHub. The result respects user OS preferences via CSS and localStorage, with a manual toggle. AI-generated code duplication was cleaned up afterward with the templating tool Cog, showing where human editing still mattered.

Claude Code generated dark theme CSS using @media (prefers-color-scheme: dark) plus a data-theme="dark" attribute driven by localStorage, with a footer toggle cycling auto/forced-light/forced-dark. Handling both the media query and the explicit toggle caused CSS duplication, which was deduplicated by Cog (github.com/simonw/simonwillisonblog PR #572). The animated GIF was produced via magick with -delay 300, -colors 128, and -layers Optimize.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

Claude Code Simon Willison GitHub Cog ImageMagick localStorage

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading