Skip to content
Back to skills

Enums

ASecurity

Use when adding or extending an enum under enums/** (endpoint path, UI message, role, route, storage-state path) or deciding whether a repeated string is an enum at all. Not for URLs and credentials (see `config`), curated test inputs (see `data-strategy`) or changing an existing member (see `refactor-values`).

  • 312 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 22, 2026
testingtypescriptgoapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned November 29, 2026

npx -y skills add idavidov13/agentic-playwright --skill enums --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Enums?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Enums
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/idavidov13-enums/badge)](https://www.skillsdirectory.com/skills/idavidov13-enums)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: enums
description: Use when adding or extending an enum under enums/** (endpoint path, UI message, role, route, storage-state path) or deciding whether a repeated string is an enum at all. Not for URLs and credentials (see `config`), curated test inputs (see `data-strategy`) or changing an existing member (see `refactor-values`).
---

# Enums

## Critical

- A TypeScript `enum`, never an `as const` object: PascalCase name, SCREAMING_SNAKE_CASE members, the value exactly as the app uses it (case, punctuation, whitespace).

    ```typescript
    // CORRECT
    export enum ApiEndpoints {
        LOGIN = '/users/login',
    }
    // WRONG
    export const API_ENDPOINTS = { login: '/users/Login' } as const;
    ```

- Any app-defined string used in more than one place (endpoint path, UI message, role, route, storage-state path) lives in an enum and is imported; `ApiEndpoints` members are the only source of endpoint paths.
- App-specific enums in `enums/{area}/*.ts`, cross-app constants in `enums/util/*.ts`; extend an existing enum before creating a file, never a new top-level folder.
- Every enum declaration carries a JSDoc line naming what it groups.
- A UI message value is captured from the live app with `playwright-cli`, never guessed; app unreachable: stop and tell the human.
- Changing or renaming an existing member goes through `refactor-values` first.

## Procedure

1. Classify the value; `ls enums/` resolves `{area}`. URLs and credentials go to `config`, curated test inputs to `data-strategy`, Playwright tuning to `playwright.config.ts`.

    | Value                                    | Home                                                                                            |
    | ---------------------------------------- | ----------------------------------------------------------------------------------------------- |
    | Endpoint path, route, storage-state path | `enums/{area}/*` (`ApiEndpoints`, `AppRoutes`, `StorageStatePaths` in `enums/app/app.ts`)       |
    | UI message (error, success, validation)  | `enums/{area}/*` (`Messages`), text captured live                                               |
    | Role or permission name                  | `enums/util/*` (`Roles` in `enums/util/roles.ts`)                                               |
    | HTTP status code in an assertion         | inline literal, `expect(status).toBe(200)`: the sanctioned carve-out from the magic-number rule |

2. Extend the enum that already groups the value; a new domain gets `enums/{area}/<domain>.ts` with its own JSDoc line.
3. UI text: open the page with `playwright-cli`, trigger the state, copy the rendered string into the value.
4. Add the member, then replace every hardcoded copy with the import: `grep -rn "<value>" tests pages fixtures helpers`.
5. Run `npx tsc --noEmit`, `npm run lint` and the consuming tests.

## References

- None. The live instances are `enums/app/app.ts` (`Messages`, `AppRoutes`, `ApiEndpoints`, `StorageStatePaths`) and `enums/util/roles.ts` (`Roles`).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.