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

Claude users report faster sessions by requesting markdown instead of Word documents
A Claude user discovered that asking for markdown instead of Word documents significantly reduces response time and token usage. The AI natively outputs markdown, while generating .docx files requires spinning up a Python environment and running conversion scripts.

Building a Process Layer on Top of Claude Code to Handle Context and Coordination
A team shares how they built a process layer over Claude Code that declares inputs/outputs per engineering step, reducing context loss across handoffs and enabling compounding productivity gains without relying on individual discipline.
5 Claude Code Terminal Commands You Might Be Missing
A senior dev shares five hidden Claude Code commands for the terminal: custom statusline, shell commands, file mentions, multi-repo context, and side conversations.

Workflow Memory Over Tooling: Why Context Loading Beats Giant Prompts
Instead of piling instructions into prompts, load workflow-specific checklists on demand — release checklist, hotfix rules, migration steps — and drop them when done.