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

Stable OpenClaw browser automation using Chrome remote debugging and Playwright
A developer reports success with Chrome's --remote-debugging-port=9222 flag and Playwright's chromium.connect_over_cdp() to maintain persistent browser sessions for OpenClaw, solving disconnection issues with the built-in browser and Chrome extension relay.

Using Dictation Tools for More Effective AI Agent Instructions
A developer found that switching from typed to spoken instructions for OpenClaw improved output quality by providing more natural, detailed context, using SaySo.ai as a dictation tool.

Fix Ollama Cloud Model maxTokens: Cap is 16K, Not Config Value
Ollama cloud caps output at 16,384 tokens regardless of maxTokens config. Set to 14,000 to avoid EOF errors. Restructure long outputs or route to direct provider.

Multi-model routing reduces OpenClaw API costs by 50%
A developer cut OpenClaw API costs by 50% by routing different tasks through different models: Claude for complex reasoning, DeepSeek for file operations and test generation, and Gemini or GPT for mid-range tasks.