Guide for adding new files to this codebase while respecting architectural principles including Separation of Concerns, Common Closure Principle, small composable functions (max 20 lines), and externalizing constants. Use when creating new modules, utilities, or any new source files in the project.
This skill guides you through adding new files to the codebase while maintaining architectural consistency and code quality standards.
When adding a new file to this project:
node: prefix, import type, .ts extensions.test.ts alongside sourceSee references/architecture-principles.md for comprehensive guidelines.
When creating a new module (e.g., cache/, auth/, logger/):
module-name/
├── types.ts # Type definitions only
├── constants.ts # Externalized constants
├── module-name.ts # Core logic
└── module-name.test.ts # Tests
Create types.ts:
export interface ModuleConfig {
enabled: boolean;
timeout: number;
}
export type ModuleState = "idle" | "active" | "error";
Create constants.ts:
export const DEFAULT_TIMEOUT_MS = 5000;
export const MODULE_CONFIG_FILE = "module-config.json";
export const ERROR_INVALID_CONFIG = "Invalid module configuration";
Create module-name.ts:
import { existsSync, readFileSync } from "node:fs";
import { join } from "node:path";
import type { ModuleConfig } from "./types.ts";
import { DEFAULT_TIMEOUT_MS, MODULE_CONFIG_FILE } from "./constants.ts";
export const loadModuleConfig = (dir: string): ModuleConfig => {
const configPath = join(dir, MODULE_CONFIG_FILE);
if (!existsSync(configPath)) {
return { enabled: true, timeout: DEFAULT_TIMEOUT_MS };
}
return JSON.parse(readFileSync(configPath, "utf-8"));
};
Create module-name.test.ts following Vitest patterns in the reference doc.
For standalone utilities that don't need a full module:
utils/ if neededutils/helper.ts and utils/helper.test.tsconstants.tsBefore creating files, verify:
After creating files, verify:
node: prefix for built-insimport type.ts extensionconstants.tsconsole.log statements (use client.tui)config/
├── types.ts # ConfigOptions, ConfigSchema
├── constants.ts # CONFIG_FILE_NAME, DEFAULT_VALUES
├── config.ts # loadConfig(), saveConfig()
└── config.test.ts
processor/
├── types.ts # ProcessorInput, ProcessorOutput
├── constants.ts # MAX_RETRIES, TIMEOUT_MS
├── processor.ts # process(), validate()
└── processor.test.ts
utils/
├── string-utils.ts # String manipulation helpers
├── string-utils.test.ts
├── path-utils.ts # Path manipulation helpers
└── path-utils.test.ts
For comprehensive information on:
Read: references/architecture-principles.md
After creating new files:
bun run typecheck # Verify TypeScript types
bun run lint # Check code style
bun run test # Run tests
bun run build # Ensure it builds
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer