- Node.js v16+
- pnpm
- Git
- Chrome browser
# Clone repository
git clone <your-repo-url>
cd extension-twitter
# Install dependencies
pnpm installStart development server with hot reload:
pnpm devThis will:
- Build extension in watch mode
- Auto-rebuild on file changes
- Output to
build/chrome-mv3-dev
Load the extension:
- Open
chrome://extensions - Enable Developer mode
- Click "Load unpacked"
- Select
build/chrome-mv3-dev
Create production-ready extension:
pnpm buildOutput: build/chrome-mv3-prod
Create a ZIP file for Chrome Web Store:
pnpm packageOutput: build/chrome-mv3-prod.zip
extension-twitter/
├── src/
│ ├── background/
│ │ └── index.ts # Background service worker
│ ├── contents/
│ │ └── injectButton.ts # Content script for inject button
│ ├── components/
│ │ ├── Footer.tsx # Footer component
│ │ └── WelcomeScreen.tsx # Onboarding screen
│ ├── lib/
│ │ ├── ai.ts # Gemini AI integration
│ │ ├── twitter.ts # Twitter API helpers
│ │ └── utils.ts # Utility functions
│ ├── sidepanel/
│ │ └── index.tsx # Main side panel UI
│ └── style.css # Global Tailwind styles
├── assets/
│ └── icon.svg # Extension icon
├── guide/ # Documentation
├── build/ # Build output (gitignored)
└── package.json
- Plasmo 0.90.5 - Extension framework
- TypeScript 5.0.4 - Type safety
- React 18.2.0 - UI library
- TailwindCSS 3.4.1 - Utility-first CSS
- PostCSS - CSS processing
- Google Gemini AI - Reply generation
- TwitterAPI.io - Thread fetching
- @plasmohq/storage - Chrome storage wrapper
# Development with hot reload
pnpm dev
# Production build
pnpm build
# Create distribution package
pnpm package
# Type checking
pnpm type-check
# Clean build artifacts
rm -rf build .plasmoMain UI component containing:
- Thread fetching logic
- AI reply generation
- Settings management
- Character counter
Content script that:
- Injects floating AI button on Twitter
- Handles button visibility
- Opens side panel on click
Service worker that:
- Handles side panel opening
- Manages extension lifecycle
Gemini AI integration:
- API key management
- Prompt formatting
- Response generation
Twitter API helpers:
- Thread context fetching
- Tweet parsing
- Reply insertion
- Extension metadata
- Dependencies
- Build scripts
- Custom color scheme
- Component styles
- TypeScript configuration
- Path aliases
Development builds include console logs:
if (process.env.NODE_ENV === "development") {
console.log("Debug info")
}Production builds strip these automatically.
- Right-click extension icon → "Inspect popup"
- Or open side panel → F12
- Check Console, Network, and Storage tabs
- Go to
chrome://extensions - Find KairoAI extension
- Click "Service worker" link
- DevTools will open for background script
- Use TypeScript for type safety
- Follow React best practices
- Use Tailwind utility classes
- Keep components small and focused
- Use React hooks (useState, useEffect)
- Store persistent data in Chrome storage
- Keep UI state separate from stored state
try {
// API call
} catch (error) {
if (process.env.NODE_ENV === "development") {
console.error("Error:", error)
}
setError("User-friendly message")
}- Test in both dev and production builds
- Test with different API keys
- Test error scenarios
- Test on various Twitter thread types
# Clear cache and rebuild
rm -rf .plasmo node_modules
pnpm install
pnpm build- Reload extension from
chrome://extensions - Close and reopen side panel
- Clear Chrome cache
# Run type checker
pnpm type-check- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request