spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / agents-md / hooks / modes / mode-of.ts
13 lines · 446 BRaw
1import { DEFAULT_MODE } from './default-mode.js'
2import { MODES } from './modes.js'
3import type { Mode } from './types'
4
5/**
6 * The mode a stored option names; unset, a typo or a value of another type
7 * names the default.
8 *
9 * @param value the `instructionFiles` option as stored
10 * @returns the mode named, DEFAULT_MODE for anything else
11 */
12export const modeOf = (value: unknown): Mode =>
13 MODES.find(mode => mode === value) ?? DEFAULT_MODE