Guide for generating code from design specifications using MUSUBIX. Use this when asked to generate code, implement features, or create components following design documents.
This skill guides you through generating code from design specifications following MUSUBIX methodology.
Before generating code:
DES-*)REQ-*)steering/tech.ja.md for technology stack| Language | Extension | Features |
|---|---|---|
| TypeScript | .ts |
Full support with types |
| JavaScript | .js |
ES6+ modules |
| Python | .py |
Type hints support |
| Java | .java |
Interface/Class generation |
| Go | .go |
Struct/Interface generation |
| Rust | .rs |
Trait/Struct generation |
| C# | .cs |
Interface/Class generation |
# Generate code from design
npx musubix codegen generate <design-file>
Always include requirement references:
/**
* UserService - Handles user operations
*
* @see REQ-INT-001 - Neuro-Symbolic Integration
* @see DES-INT-001 - Integration Layer Design
*/
export class UserService {
// Implementation
}
describe('UserService', () => {
it('should create user', async () => {
const service = new UserService();
const user = await service.create({ name: 'Test' });
expect(user.id).toBeDefined();
});
});
export class UserService {
async create(data: CreateUserDto): Promise<User> {
return { id: generateId(), ...data };
}
}
/**
* @see REQ-DES-001 - Pattern Detection
* @pattern Singleton
*/
export class ConfigManager {
private static instance: ConfigManager;
private constructor() {}
static getInstance(): ConfigManager {
if (!ConfigManager.instance) {
ConfigManager.instance = new ConfigManager();
}
return ConfigManager.instance;
}
}
/**
* @see REQ-DES-001 - Pattern Detection
* @pattern Factory
*/
export interface ServiceFactory {
create(type: string): Service;
}
export class DefaultServiceFactory implements ServiceFactory {
create(type: string): Service {
switch (type) {
case 'auth': return new AuthService();
case 'user': return new UserService();
default: throw new Error(`Unknown service: ${type}`);
}
}
}
/**
* @see REQ-COD-001 - Code Generation
* @pattern Repository
*/
export interface Repository<T> {
findById(id: string): Promise<T | null>;
findAll(): Promise<T[]>;
save(entity: T): Promise<T>;
delete(id: string): Promise<void>;
}
export class UserRepository implements Repository<User> {
async findById(id: string): Promise<User | null> {
// Implementation
}
// ... other methods
}
# Generate code from design
npx musubix codegen generate <design-file>
# Analyze existing code
npx musubix codegen analyze <file>
# Security scan
npx musubix codegen security <path>
Before committing code:
any types (TypeScript)@see referencesnpm run lint passesnpm run build succeedsWhen generating code that involves decision-making:
/**
* @see REQ-INT-002 - Confidence Evaluation
*/
async function integrateResults(
neuralResult: NeuralResult,
symbolicResult: SymbolicResult
): Promise<FinalResult> {
// Decision rules from REQ-INT-002
if (symbolicResult.status === 'invalid') {
return rejectNeural(neuralResult);
}
if (neuralResult.confidence >= 0.8) {
return adoptNeural(neuralResult);
}
return prioritizeSymbolic(symbolicResult);
}
packages/
āāā core/
ā āāā src/
ā āāā [feature]/
ā ā āāā index.ts # Public exports
ā ā āāā [feature].ts # Main implementation
ā ā āāā types.ts # Type definitions
ā ā āāā __tests__/ # Tests
ā āāā index.ts # Package exports
/**
* @see REQ-ERR-001 - Graceful Degradation
*/
export class MuSubixError extends Error {
constructor(
message: string,
public code: string,
public recoverable: boolean = true
) {
super(message);
this.name = 'MuSubixError';
}
}
// Usage
throw new MuSubixError(
'Failed to connect to YATA',
'YATA_CONNECTION_ERROR',
true // Can retry
);