add-new-file

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.

16 stars

Best use case

add-new-file is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

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.

Teams using add-new-file 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

$curl -o ~/.claude/skills/add-new-file/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/add-new-file/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/add-new-file/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How add-new-file Compares

Feature / Agentadd-new-fileStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

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.

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 New File

This skill guides you through adding new files to the codebase while maintaining architectural consistency and code quality standards.

## Quick Reference

When adding a new file to this project:

1. **Determine the scope** - What domain/concern does this file address?
2. **Follow module pattern** - Create types.ts, constants.ts, main logic file
3. **Externalize constants** - All magic strings/numbers go in constants.ts
4. **Keep functions small** - Max 20 lines of logic per function
5. **Use proper imports** - `node:` prefix, `import type`, `.ts` extensions
6. **Write co-located tests** - Create `.test.ts` alongside source

See [references/architecture-principles.md](references/architecture-principles.md) for comprehensive guidelines.

## Adding a New Module

When creating a new module (e.g., `cache/`, `auth/`, `logger/`):

### Step 1: Create Module Directory

```
module-name/
├── types.ts          # Type definitions only
├── constants.ts      # Externalized constants
├── module-name.ts    # Core logic
└── module-name.test.ts  # Tests
```

### Step 2: Define Types First

Create `types.ts`:

```typescript
export interface ModuleConfig {
  enabled: boolean;
  timeout: number;
}

export type ModuleState = "idle" | "active" | "error";
```

### Step 3: Externalize Constants

Create `constants.ts`:

```typescript
export const DEFAULT_TIMEOUT_MS = 5000;
export const MODULE_CONFIG_FILE = "module-config.json";
export const ERROR_INVALID_CONFIG = "Invalid module configuration";
```

### Step 4: Implement Core Logic

Create `module-name.ts`:

```typescript
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"));
};
```

### Step 5: Write Tests

Create `module-name.test.ts` following Vitest patterns in the reference doc.

## Adding a Utility File

For standalone utilities that don't need a full module:

1. Place in appropriate existing module or create `utils/` if needed
2. Create `utils/helper.ts` and `utils/helper.test.ts`
3. Extract any constants to the parent module's `constants.ts`
4. Keep functions small and composable

## Pre-Flight Checklist

Before creating files, verify:

- ✅ **Correct location** - File belongs in right module/directory
- ✅ **Constants identified** - Know what values need externalizing
- ✅ **Types defined** - Clear interfaces for inputs/outputs
- ✅ **Single responsibility** - File has one clear purpose
- ✅ **Dependencies mapped** - Know what to import

## Post-Creation Checklist

After creating files, verify:

- ✅ **All imports use `node:` prefix** for built-ins
- ✅ **Type imports use `import type`**
- ✅ **Relative imports include `.ts` extension**
- ✅ **All exports have explicit return types**
- ✅ **Constants externalized to `constants.ts`**
- ✅ **Functions under 20 lines of logic**
- ✅ **Tests created and passing**
- ✅ **Code follows style guide** (see reference doc)
- ✅ **No `console.log` statements** (use `client.tui`)

## Common Patterns

### Configuration Module

```
config/
├── types.ts       # ConfigOptions, ConfigSchema
├── constants.ts   # CONFIG_FILE_NAME, DEFAULT_VALUES
├── config.ts      # loadConfig(), saveConfig()
└── config.test.ts
```

### Business Logic Module

```
processor/
├── types.ts          # ProcessorInput, ProcessorOutput
├── constants.ts      # MAX_RETRIES, TIMEOUT_MS
├── processor.ts      # process(), validate()
└── processor.test.ts
```

### Utility Module

```
utils/
├── string-utils.ts      # String manipulation helpers
├── string-utils.test.ts
├── path-utils.ts        # Path manipulation helpers
└── path-utils.test.ts
```

## Detailed Guidelines

For comprehensive information on:

- Complete constants externalization rules with examples
- Full code style guide (imports, functions, naming, formatting)
- Error handling patterns
- Testing patterns with Vitest
- File system operation patterns

**Read:** [references/architecture-principles.md](references/architecture-principles.md)

## Verification Commands

After creating new files:

```bash
bun run typecheck   # Verify TypeScript types
bun run lint        # Check code style
bun run test        # Run tests
bun run build       # Ensure it builds
```

Related Skills

file-suggestion

16
from diegosouzapw/awesome-omni-skill

Set up fast file suggestions for Claude Code using ripgrep, jq, and fzf. Use this skill when users want to improve file autocomplete performance or add custom file suggestion behavior.

file-path-traversal

16
from diegosouzapw/awesome-omni-skill

This skill should be used when the user asks to "test for directory traversal", "exploit path traversal vulnerabilities", "read arbitrary files through web applications", "find LFI vu...

file-management-rules

16
from diegosouzapw/awesome-omni-skill

Specifies file management guidelines, including including full file paths as comments, updating project structure in AI.MD, and maintaining package.json. This rule ensures organized and well-documente

file-archiver

16
from diegosouzapw/awesome-omni-skill

创建和解压ZIP、TAR和GZIP压缩包,支持密码保护。

deepagents-filesystem

16
from diegosouzapw/awesome-omni-skill

Using FilesystemMiddleware with virtual filesystems, backends (State, Store, Filesystem, Composite), and context management for Deep Agents.

authoring-excalidraw-files

16
from diegosouzapw/awesome-omni-skill

Generate architecture diagrams as .excalidraw files. Use when the user asks to create architecture diagrams, system diagrams, visualize codebase structure, infrastructure diagrams, or generate excalidraw files.

ai-file-analyzer

16
from diegosouzapw/awesome-omni-skill

Analyze Adobe Illustrator (.ai) files to extract design information including text content, fonts, color palettes, vector paths, and generate high-resolution preview images. Use when analyzing logo files, design assets, or any Adobe Illustrator documents that need programmatic inspection.

waiverfile-automation

16
from diegosouzapw/awesome-omni-skill

Automate Waiverfile tasks via Rube MCP (Composio). Always search tools first for current schemas.

routing-profiles

16
from diegosouzapw/awesome-omni-skill

Change the Routing Solution routing profiles/vehicle types. To be used as part of customize-main skill

chatfiles

16
from diegosouzapw/awesome-omni-skill

Coordinate multiple Claude agents via shared text files. Triggers on Chatfile, multi-agent, cross-machine coordination.

azure-storage-file-datalake-py

16
from diegosouzapw/awesome-omni-skill

Azure Data Lake Storage Gen2 SDK for Python. Use for hierarchical file systems, big data analytics, and file/directory operations.

agentpmt-tool-file-management-d789ed

16
from diegosouzapw/awesome-omni-skill

Use AgentPMT external API to run the File Management tool with wallet signatures, credits purchase, or credits earned from jobs.