Contribution Workflow
Fork the repository
- Go to github.com/alichherawalla/off-grid-mobile
- Click Fork in the top right
- Clone your fork locally:
Create a feature branch
Use a descriptive branch name that indicates the type of change:
- Feature
- Bug Fix
- Documentation
- Chore
- Test
Never commit directly to
main. Always create a feature branch.Make your changes
- Follow the existing code style and conventions
- Use
useTheme()anduseThemedStyles()for all styling - never hardcode colors - Use
TYPOGRAPHYandSPACINGfromsrc/constants/for theme-independent tokens - Write tests for new functionality
- Update documentation if needed
Test your changes
Pre-Commit Quality Gates (Husky)
Off Grid uses Husky to automatically run quality gates on everygit commit. The checks are scoped to the file types you staged, so you only run relevant tests.
What Runs When
| Staged file type | Checks that run automatically |
|---|---|
.ts / .tsx / .js / .jsx | ESLint (staged only), tsc --noEmit, npm test |
.swift | SwiftLint (staged only), npm run test:ios |
.kt / .kts | compileDebugKotlin (type check), lintDebug, npm run test:android |
Requirements
- SwiftLint: Install via
brew install swiftlint(skipped with a warning if not installed) - Android checks: Require the Gradle wrapper in
android/
Hook Behavior
Example pre-commit output
Code Style and Conventions
TypeScript Style
- Use TypeScript for all new code
- Define interfaces for all complex types
- Avoid
any- use proper types orunknown - Use descriptive variable names
React Native Style
Styling Guidelines
Styling Guidelines
- Never hardcode colors - use
useTheme()andcolors.* - Never hardcode spacing/typography - use
SPACINGandTYPOGRAPHYconstants - Always use
useThemedStyles- never inline styles or staticStyleSheet.create - No pixel values - use design tokens
Good example
Bad example
Component Guidelines
Component Guidelines
- Use functional components with hooks (no class components)
- Keep components small and focused (single responsibility)
- Extract reusable logic into custom hooks
- Use
AnimatedPressablefor interactive elements (includes haptics) - Use
AnimatedEntryorAnimatedListItemfor list items (staggered animations)
Performance Guidelines
Performance Guidelines
- Use
FlatListorFlashListfor large lists (not.map()insideScrollView) - Use
React.memo()for expensive components - Use
useMemo()anduseCallback()to prevent unnecessary re-renders - Check with React DevTools Profiler if unsure
Native Module Guidelines
Native Module Guidelines
- Both platforms required - no new native module without Android + iOS implementations
- Register in Xcode - add new iOS modules to
project.pbxprojbuild target - Cross-platform paths - resolve file paths correctly on both platforms (no hardcoded
/vs\\) - Progress reporting - long-running tasks must report progress to UI
Service Layer Guidelines
- Singleton pattern for all core services (prevent duplicate instances)
- Background-safe operations for long-running tasks (independent of component lifecycle)
- Memory checks before model operations (check RAM budget)
- Comprehensive logging for debugging
- Graceful error handling with user-friendly messages
Testing Guidelines
- Write tests for all new functionality
- Test stores with
@testing-library/react-native - Test services with Jest mocks
- Test components with snapshot tests or RTL queries
- Ensure coverage doesn’t decrease (Codecov will block PRs)
Pull Request Template
When creating a PR, fill out the template at.github/pull_request_template.md:
Do NOT include “Generated with Claude Code” or any AI attribution in PR descriptions.
CI Review Loop
After pushing your PR, three automated reviewers will analyze your code. You must address all feedback before merging.Automated Reviewers
- Gemini Bot
- Codecov
- SonarCloud
What it checks: Code quality, style, logic issues, best practicesHow to address:
- Pull down comments:
- Fix code or reply explaining why the suggestion doesn’t apply
- Push fixes
- Comment
/gemini reviewon the PR to trigger a fresh review pass
Review Loop Workflow
Address all feedback
- Gemini: Fix code or reply with explanations
- Codecov: Add tests for uncovered lines
- SonarCloud: Fix security hotspots, code smells, and duplications
Development Guidelines Summary
Styling
- Use
useTheme()anduseThemedStyles()for all styling - Never hardcode colors, spacing, or typography
- Use
TYPOGRAPHYandSPACINGconstants
Services
- Follow singleton pattern
- Implement background-safe operations
- Check memory before model operations
- Add comprehensive logging
Components
- Functional components with hooks
- Small, focused components
- Use
AnimatedPressablefor interactions - Use
FlatListfor large lists
Testing
- Write tests for all new functionality
- Ensure coverage doesn’t decrease
- Test on both Android and iOS
- Test light and dark modes
Getting Help
- Documentation: Start with Architecture and Project Structure
- Community: Join the Slack workspace
- Issues: Check GitHub Issues for known problems
Next Steps
Building from Source
Set up your development environment
Testing Guide
Learn how to run tests locally
Project Structure
Understand the codebase organization