OpenParable
Skip to content
← Back to skills

YAML JSON Toml Loader

Development
yaml-json-toml-loader

YAML JSON Toml Loader is an Agent Skill for development published in the a5c-ai/babysitter repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Generate multi-format configuration file loaders for YAML, JSON, and TOML formats.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/a5c-ai/babysitter/blob/HEAD/library/specializations/cli-mcp-development/skills/yaml-json-toml-loader/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/yaml-json-toml-loader, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

YAML/JSON/TOML Loader

Generate multi-format config file loaders.

Generated Patterns

import fs from 'fs';
import path from 'path';
import yaml from 'yaml';
import toml from '@iarna/toml';

type ConfigFormat = 'json' | 'yaml' | 'toml' | 'auto';

export function loadConfigFile(filepath: string, format: ConfigFormat = 'auto'): unknown {
  const content = fs.readFileSync(filepath, 'utf-8');
  const ext = format === 'auto' ? path.extname(filepath).toLowerCase() : `.${format}`;

  switch (ext) {
    case '.json': return JSON.parse(content);
    case '.yaml': case '.yml': return yaml.parse(content);
    case '.toml': return toml.parse(content);
    default: throw new Error(`Unknown config format: ${ext}`);
  }
}

export function saveConfigFile(filepath: string, data: unknown, format: ConfigFormat = 'auto'): void {
  const ext = format === 'auto' ? path.extname(filepath).toLowerCase() : `.${format}`;
  let content: string;

  switch (ext) {
    case '.json': content = JSON.stringify(data, null, 2); break;
    case '.yaml': case '.yml': content = yaml.stringify(data); break;
    case '.toml': content = toml.stringify(data as any); break;
    default: throw new Error(`Unknown format: ${ext}`);
  }

  fs.writeFileSync(filepath, content);
}

Target Processes

  • configuration-management-system
  • cli-application-bootstrap