home / skills / next-friday / nextfriday-skills / nextfriday-imports

nextfriday-imports skill

/skills/nextfriday-imports

This skill enforces absolute import usage, type-only imports, and centralized date utilities to improve code consistency and maintainability.

npx playbooks add skill next-friday/nextfriday-skills --skill nextfriday-imports

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.4 KB
---
name: nextfriday-imports
description: Next Friday import rules for absolute paths, type imports, and date utilities. Use when adding import statements or working with modules.
user-invocable: false
---

# Next Friday Imports

Rules for import statements and module resolution.

## Absolute Imports

Disallow relative imports with `../`. Use absolute imports instead.

```typescript
// Bad:
import { Button } from "../../../components/Button";
import { formatDate } from "../../utils/format";

// Good:
import { Button } from "@/components/Button";
import { formatDate } from "@/utils/format";
import { validate } from "./validate"; // sibling import OK
```

## Type Imports

Use `import type` for type-only imports.

```typescript
// Bad:
import { ReactNode, FC } from "react";
import { User, Item } from "@/types";

// Good:
import type { ReactNode, FC } from "react";
import type { User, Item } from "@/types";
```

## Date Utilities

Use centralized date utilities (e.g., dayjs) instead of native Date.

```typescript
// Bad:
const now = new Date();
const timestamp = Date.now();

// Good:
import dayjs from "dayjs";

const now = dayjs();
const timestamp = dayjs().valueOf();
```

## Quick Reference

| Rule | Pattern |
| ---- | ------- |
| No `../` imports | Use absolute paths or `@/` alias |
| Type imports | `import type { X }` for types |
| Date handling | Use dayjs, not native Date |

Overview

This skill enforces Next Friday import conventions for absolute paths, type-only imports, and centralized date utilities. It helps maintain consistent module resolution, clear type imports, and reliable date handling across a codebase. Use it to reduce fragile relative paths, ensure correct TypeScript type imports, and standardize on a date library.

How this skill works

The skill inspects import statements and usage patterns to detect relative imports that traverse up the directory tree, type imports that are not declared with the import type form, and direct uses of native Date APIs. It recommends replacing ../ paths with the configured absolute alias (e.g., @/), converting type-only imports to import type, and switching native Date constructions and Date.now calls to a centralized date utility like dayjs. It flags violations and provides actionable replacements.

When to use it

  • When adding or refactoring import statements to avoid fragile relative paths.
  • When writing TypeScript code that imports interfaces, types, or React type helpers.
  • When normalizing date handling across the application for consistency and testability.
  • During code review to catch non-conforming imports and date usage.
  • When setting up or enforcing a project's module resolution conventions.

Best practices

  • Prefer absolute imports with a project alias (e.g., @/) for modules outside the current folder.
  • Use import type for type-only imports to keep runtime bundles clean and avoid TS emit issues.
  • Centralize date logic behind a single utility (e.g., dayjs) to simplify formatting and mocking.
  • Allow relative imports for sibling or same-directory modules, but avoid upward ../ traversals.
  • Update linter or tooling rules to automatically warn or fix these import patterns.

Example use cases

  • Refactoring a component that used multiple ../ imports into stable @/ imports for clarity.
  • Converting ReactNode and FC imports to import type to remove runtime import overhead.
  • Replacing new Date() and Date.now() usages with a dayjs-based utility for unified parsing and formatting.
  • Running checks as part of a pre-commit or CI step to prevent new violations from entering the codebase.
  • Onboarding contributors by enforcing a straightforward import style and date handling approach.

FAQ

Why use absolute imports instead of ../ relative paths?

Absolute imports reduce path fragility when files move or are deeply nested, making refactors safer and imports easier to read.

When should I still use relative imports?

Use relative imports for sibling or same-directory modules where an absolute path adds noise; avoid relative imports that traverse up with ../.