Code Patterns Beat AI Guidelines: Porting a Firefox Extension to Chrome

A developer on r/ClaudeAI shared a concrete case study in building cross-browser extensions with AI coding agents. The project: a Firefox extension built with human-guided architecture. Two attempts to port it to Chrome via AI prompts failed. The root cause: prompts compensated for training gaps but coupled to model versions and degraded at scale.
The solution was to extract browser-agnostic logic into a core package with a BrowserShell interface. Each extension became a thin shell — the Chrome version's final code differed from Firefox's by only 5 meaningful lines. Key insight: code patterns beat abstract guidelines. A clear, testable codebase lets the model replicate patterns reliably, while abstract prompts fight the model's training distribution. The Humble Object pattern keeps boundary code thin.
Practical Takeaways
- Define a browser-agnostic core (e.g.,
BrowserShell) that abstracts APIs like tabs, storage, and messaging. - Implement that interface with platform-specific adapters (e.g.,
FirefoxShell,ChromeShell). - Prompt the AI to follow the established pattern rather than listing rules. Show it a working adapter and ask it to replicate the pattern for a new browser.
- Focus on testability — the core logic should be unit-testable without browser APIs.
The approach scales because patterns are deterministic for the model, whereas guidelines are fuzzy and drift with model updates. If you're using AI to port code across platforms, invest in an architecture that lets the model do what it does best: pattern matching.
📖 Read the full source: r/ClaudeAI
👀 See Also

How to Fix Claude Code's CSS Guesswork with a Design System
A developer found Claude Code repeatedly regenerated misaligned HTML/CSS because it designs blind without visual feedback. The solution: provide a complete design system with spacing, colors, and type variables, then separate HTML and CSS prompts.

Claude Code Token Waste Fix: Disable Attribution Header for Better Cache Hits
Setting CLAUDE_CODE_ATTRIBUTION_HEADER=false in your shell configuration can improve Claude Code's cross-session prompt cache hit rate from 48% to 99.98%, reducing system prompt processing costs by 7x per session.

Spent $850 on OpenClaw in One Month? Fix Your Architecture, Not Your Model
A developer burned $850 in a month on OpenClaw multi-agent setup — with $350 gone in a single day. The fix wasn't a cheaper model — it was system design: strict context pruning, session resets, n8n for non-reasoning tasks, and a routing tier for cheap vs. strong models.

How to disable Claude Code's verb spinner feature
Claude Code includes a default verb spinner that displays whimsical gerunds like 'Seasoning' and 'Crafting' during processing. You can disable it by editing the settings.json file with a blank space in the spinnerVerbs array.