Js writer

From pixelastic/oroshi · View interactive version

Js writer is an AI agent skill from the GitHub repository pixelastic/oroshi. Use when writing or modifying JavaScript code. Apply when adding functions, fixing bugs, or implementing features.

How to use this skill

Skill file

JavaScript Writer

Overview

Write JavaScript code consistent with my conventions.

Use my preferred libraries — the references explain when and why:

console, and system utilities

pMap, dayjs, yoctocolors, pProps, and more

Core Workflow

Step 1 — Place the file

Goal: Correct path and name.

Exit criterion: File exists at correct path with correct name.

re-exporting them

testing

Structure example
lib/
  pull/
    __tests__/
      fetch.js
      merge.js
    fetch.js
    index.js      ← barrel: re-exports fetch and merge
    merge.js
  __tests__/
    listEntries.js
  listEntries.js
  main.js         ← single top-level entry point

Step 2 — TDD: Write a failing test

Goal: Ensure the bug/feature has a failing test first

Exit criterion: Test fails.

Write a failing test for the bug or missing feature you want to implement.

it.each([
  {
    title: "Default path",
    filepath: '/tmp/a',
    options: {},
    expected: 'a'
  },
  {
    title: "Forced path",
    filepath: '/tmp/b',
    options: {
      force: true
    },
    expected: 'b'
  },
])('$title', async ({ filepath, options, expected }) => {
  const actual = await myFn(filepath, options);
  expect(actual).toEqual(expected);
});

Step 3 — Make it work

Goal: Write the minimal code to make the failing test pass.

Exit criterion: Test is green.

Write the simplest code that makes the test pass. No patterns yet — just correct

behavior.

Step 4 — Refactor

Goal: Apply structural and style patterns without changing behavior.

Exit criterion: Tests still pass after refactor.

| Pattern | Rule |

| ------------------------------------ | ----------------------------------------------------------------------------------------- |

| Modules | ES6 import/export; named exports; .js extension; __ for private methods |

| Style | async/await; camelCase; minimal try/catch; lodash chains for 2+ ops; JSDoc on all fns |

| Comments | How to write inline comments and JSDoc blocks |

| firost | File I/O and system operations |

| golgoth | Data transformation, dates, async utilities |

import { formatEntry } from './formatEntry.js';
import { read, glob } from 'firost';
import { _ } from 'golgoth';

export let __;

/**
 * List all entries in a directory, formatted
 * @param {string} dirPath - Directory to scan
 * @returns {string[]} Formatted entry names
 */
export async function listEntries(dirPath) {
  const files = await __.findFiles(dirPath);

  return _.chain(files)
    .map((f) => formatEntry(f))
    .compact()
    .value();
}

__ = {
  /**
   * @param {string} dir
   * @returns {string[]} Matching file paths
   */
  findFiles(dir) {
    return glob(`${dir}/**/*.js`);
  },
};

Step 5 — Lint

Goal: Ensure code follows best practices.

Exit criterion: Lint passes.

Write code that passes automated lint.

remaining ones


Common Rationalizations

| Rationalization | Reality |

| ------------------------------------------------ | ----------------------------------------------------------- |

| "These comments are clutter, I'll clean them up" | Never remove existing comments |

| "mockResolvedValue is more idiomatic Vitest" | Always mockReturnValue(value) — abstract away sync/async |

| "expect().rejects.toThrow() is cleaner" | Use let actual = null + try/catch pattern |

| "This helper is too small for __" | All local helpers go in __. Only imports are conditional. |

Checklist

.test. or .spec. suffix

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.