add-module
Create a new core infrastructure module with standard API, lazy init, and proper structure
Best use case
add-module is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Create a new core infrastructure module with standard API, lazy init, and proper structure
Teams using add-module should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/add-module/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How add-module Compares
| Feature / Agent | add-module | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Create a new core infrastructure module with standard API, lazy init, and proper structure
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Add Module Skill
## Usage
```
/add-module <ModuleName>
```
**Note:** Modules are core infrastructure (always-on). For toggleable functionality, use `/add-feature` instead.
---
## Step 1: Ask Questions
### 1. Module Purpose
```
What infrastructure does this module provide?
Brief description:
```
### 2. Data Source
```
Where does the module get its data?
A) Game runtime - Hooks into game code
B) Network - Captures WebSocket/HTTP
C) Assets - Game assets (sprites, audio, etc.)
D) Computed - Derives from other modules
E) Other: ___
```
### 3. Dependencies
```
Which existing modules does it depend on?
[ ] MGData [ ] MGSprite [ ] MGTile
[ ] MGPixi [ ] MGAudio [ ] MGCosmetic
[ ] MGVersion [ ] MGAssets [ ] MGManifest
[ ] MGEnvironment [ ] MGCalculators [ ] None
```
### 4. State Type
```
Does it need runtime state?
A) Yes - Caches data in memory (needs state.ts)
B) No - Stateless utilities only
```
### 5. Public API Methods
```
What methods should the module expose?
(Besides required init/isReady)
Examples:
- get(key) - Get data by key
- calculate(params) - Perform calculation
- render(target) - Render something
```
---
## Step 2: Create Structure
```
src/modules/<moduleName>/
├── index.ts # Public façade (MG<ModuleName>)
├── types.ts # Type definitions
├── state.ts # Runtime state (if needed)
└── logic/
└── core.ts # Business logic
```
**No `logic/index.ts`** - Import directly from logic files.
---
## Step 3: File Templates
### types.ts
```typescript
/**
* <ModuleName> Module Types
*/
// ─────────────────────────────────────────────────────────────────────────────
// Types
// ─────────────────────────────────────────────────────────────────────────────
export interface <ModuleName>Data {
// Define data structures
}
// ─────────────────────────────────────────────────────────────────────────────
// Constants
// ─────────────────────────────────────────────────────────────────────────────
export const <MODULE_NAME>_CONSTANTS = {
// Define constants
} as const;
```
### state.ts (if needed)
```typescript
/**
* <ModuleName> Module State
*
* Runtime cache/state management.
*/
import type { <ModuleName>Data } from './types';
// ─────────────────────────────────────────────────────────────────────────────
// State
// ─────────────────────────────────────────────────────────────────────────────
let cache: <ModuleName>Data | null = null;
let ready = false;
// ─────────────────────────────────────────────────────────────────────────────
// Accessors
// ─────────────────────────────────────────────────────────────────────────────
export function getCache(): <ModuleName>Data | null {
return cache;
}
export function setCache(data: <ModuleName>Data): void {
cache = data;
ready = true;
}
export function isReady(): boolean {
return ready;
}
export function reset(): void {
cache = null;
ready = false;
}
```
### logic/core.ts
```typescript
/**
* <ModuleName> Core Logic
*/
import { setCache, getCache } from '../state';
import type { <ModuleName>Data } from '../types';
// ─────────────────────────────────────────────────────────────────────────────
// Initialization
// ─────────────────────────────────────────────────────────────────────────────
export async function initialize(): Promise<void> {
// Initialization logic
// Capture data, setup hooks, etc.
const data: <ModuleName>Data = {
// ...
};
setCache(data);
}
// ─────────────────────────────────────────────────────────────────────────────
// Public Methods
// ─────────────────────────────────────────────────────────────────────────────
export function getData(): <ModuleName>Data | null {
return getCache();
}
```
### index.ts
```typescript
/**
* <ModuleName> Module
*
* <Brief description>
*
* @example
* ```typescript
* await MG<ModuleName>.init();
* const data = MG<ModuleName>.get();
* ```
*/
import { initialize, getData } from './logic/core';
import { isReady as checkReady } from './state';
// ─────────────────────────────────────────────────────────────────────────────
// State
// ─────────────────────────────────────────────────────────────────────────────
let initialized = false;
// ─────────────────────────────────────────────────────────────────────────────
// Public API
// ─────────────────────────────────────────────────────────────────────────────
/**
* Initialize the module
* Idempotent - safe to call multiple times
*/
async function init(): Promise<void> {
if (initialized) return;
initialized = true;
await initialize();
console.log('[<ModuleName>] Initialized');
}
/**
* Check if module is ready
*/
function isReady(): boolean {
return checkReady();
}
/**
* Get module data
*/
function get() {
return getData();
}
// ─────────────────────────────────────────────────────────────────────────────
// Export
// ─────────────────────────────────────────────────────────────────────────────
export const MG<ModuleName> = {
// Required (standard API)
init,
isReady,
// Module-specific
get,
// Add other public methods
};
export type { <ModuleName>Data } from './types';
```
---
## Step 4: Register
### Export → `src/modules/index.ts`
```typescript
export { MG<ModuleName> } from './<moduleName>';
export type { <ModuleName>Data } from './<moduleName>';
```
### API → `src/api/index.ts`
```typescript
import { MG<ModuleName> } from '../modules/<moduleName>';
Modules: {
// ... existing
<ModuleName>: MG<ModuleName>,
}
```
### Bootstrap → `src/ui/loader/bootstrap.ts`
```typescript
import { MG<ModuleName> } from '../../modules/<moduleName>';
// In initModules():
await MG<ModuleName>.init();
```
---
## Step 5: Validate
### Structure
- [ ] `index.ts` exports `MG<ModuleName>`
- [ ] `types.ts` defines types/constants
- [ ] `state.ts` exists (if stateful)
- [ ] `logic/` folder for business logic
- [ ] No `logic/index.ts` barrel file
### API
- [ ] `init()` - Required, idempotent
- [ ] `isReady()` - Required, returns boolean
- [ ] Other methods are module-specific
### Rules
- [ ] No toggles (modules are always-on)
- [ ] No UI rendering (DOM in src/ui/ only)
- [ ] No direct WS sends (use websocket/api.ts)
- [ ] No side effects on import
### Registration
- [ ] Exported from `src/modules/index.ts`
- [ ] Exposed in `src/api/index.ts`
- [ ] Initialized in bootstrap
---
## Module vs Feature
| Aspect | Module | Feature |
|--------|--------|---------|
| Toggle | Always on | `enabled: boolean` |
| Location | `src/modules/` | `src/features/` |
| Purpose | Infrastructure | Enhancement |
| API | `MG<Name>` | `MG<Name>` |
| Storage | `MODULE_KEYS` (rare) | `FEATURE_KEYS` |
---
## References
- Rules: `.claude/rules/modules.md`
- Existing modules: `src/modules/*/`Related Skills
analyze-m1-module-for-migration
Systematically analyze a Magento 1 module to determine its purpose, usage, and migration requirements for Magento 2. Use when you need to decide whether to migrate a M1 module, find alternatives, or skip it.
amplifier-modulebuilder-skill
Build amplifier-foundation modules using "bricks and studs" architecture. Covers tool, hook, provider, context, and orchestrator modules with testing, publishing, and best practices.
1k-patching-native-modules
Patches native modules (expo-image, react-native, etc.) to fix native crashes or bugs.
1k-defi-module-integration
Interactive guide for integrating new DeFi modules or protocols into OneKey. Use when adding new DeFi features like staking protocols, lending markets, or entirely new DeFi modules. Triggers on DeFi, protocol, integration, Earn, Borrow, staking, lending, supply, borrow, withdraw, repay, claim, new module, Pendle, Aave, Compound.
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
angular-best-practices
Angular performance optimization and best practices guide. Use when writing, reviewing, or refactoring Angular code for optimal performance, bundle size, and rendering efficiency.
angular-app-setup
Creates an Angular 20 app directly in the current folder with strict defaults, deterministic non-interactive flags, and preflight safety checks. Use when the user asks to create, scaffold, or initialize Angular 20 in place and wants build/test verification.
angreal-patterns
This skill should be used when the user asks to "test angreal tasks", "mock angreal", "document tasks", "angreal best practices", "error handling in tasks", "subprocess patterns", "dry run mode", "verbose mode", or needs guidance on testing patterns, development workflows, documentation strategies, or common implementation patterns for angreal tasks.
android
Build, review, and refactor Android mobile apps (Kotlin) using modern Android patterns. Use for tasks like setting up Gradle modules, Jetpack Compose UI, navigation, ViewModel/state management, networking (Retrofit/OkHttp), persistence (Room/DataStore), DI (Hilt/Koin), testing, performance, release builds, and Play Store readiness.
android-watch-logs
Start real-time log streaming from connected Android device using adb logcat. Shows only app's log messages. Use when monitoring app behavior, debugging, or viewing Android logs.
android-use
Control Android devices via ADB commands - tap, swipe, type, navigate apps
android-supabase
Supabase integration patterns for Android - authentication, database, realtime subscriptions. Use when setting up Supabase SDK, implementing OAuth, querying database, or setting up realtime.