ForgeCLI is a developer tool that enables scalable, maintainable React applications using a plugin-driven architecture with AST-based code transformation.
It eliminates manual provider nesting and introduces a priority-based injection system to manage application-level concerns like authentication, theming, and more.
As React applications grow, managing multiple providers becomes messy:
<AuthProvider>
<ThemeProvider>
<Router>
<StateProvider>
<App />
</StateProvider>
</Router>
</ThemeProvider>
</AuthProvider>❌ Hard to maintain and scale
❌ Manual ordering errors
❌ Duplicate or conflicting providers
❌ Poor developer experience
💡 Solution: ForgeCLI \
🔌 Plugin-based architecture
⚙️ AST-powered code transformation
🧠 Priority-driven provider injection
♻️ Idempotent rebuild system \
🔹 1. Plugin System
Add features using simple CLI commands:
forge add auth
forge add theme🔹 2. AST-Based Code Transformation
ForgeCLI uses Babel to:
- Parse your React app
- Extract
- Rebuild provider tree safely
🔹 3. Priority-Based Provider Injection
Each plugin defines a priority:
```bash
auth → priority 1 \
theme → priority 10
```
```bash
<AuthProvider>
<ThemeProvider>
<App />
</ThemeProvider>
</AuthProvider>
```
🔹 4. Clean Rebuild Engine
Instead of patching code, ForgeCLI:
- Extracts core app
- Rebuilds provider tree from scratch
- Ensures consistent output
🔹 5. Idempotent Execution
Running commands multiple times does NOT break your app:
forge add auth
forge add auth➡️ No duplicate providers
➡️ No unnecessary changes
🔹 6. Automatic Import Injection
ForgeCLI:
Detects existing imports
Adds missing imports
Prevents duplication \
Plugins → Config → AST Parser → Provider Extractor → Priority Sort → Tree Rebuild → Code Generator
utils/
astModifier.ts # AST parsing & transformation
rebuildProviders.ts # Provider rebuild engine
logger.ts # Logging system
error-handler.ts # Error handling
templates/
react-app/ # Starter templates
package.json
tsconfig.json- User runs:
forge add <plugin>- Plugin configuration is loaded
- AST parses React entry file
- Existing providers are removed
- Providers are sorted by priority
New tree is generated:
<StrictMode>
<AuthProvider>
<ThemeProvider>
<App />
</ThemeProvider>
</AuthProvider>
</StrictMode>Before
<React.StrictMode>
<App />
</React.StrictMode>
After
<React.StrictMode>
<AuthProvider>
<ThemeProvider>
<App />
</ThemeProvider>
</AuthProvider>
</React.StrictMode>
Ensures deterministic and clean output
Avoids dependency conflicts
Guarantees safe transformations
🔗 Plugin dependency resolution system
⚡ Smart diff engine (avoid unnecessary rebuilds)
🧩 Plugin hooks (modify routes, config, etc.)
🧪 Automated test suite
🌐 Support for non-React frameworks \
ForgeCLI brings:
📈 Scalable architecture
🧹 Cleaner codebases
⚡ Faster development workflows
🔌 Extensible ecosystem
Contributions are welcome! Feel free to:
- Open issues
- Suggest features
- Submit PRs
MIT License
Shubham Srivastava shubhamsrivastava12568@gmail.com