<div align="center">
    <h1>🦦 Stack</h1>
    <strong>My opinionated scaffolding tool to ease project building</strong>
</div>
<br>
<br>

## ✨ Features

`Stack` allows creating an NPM project in a **quick**, **easy** and **opinionated** way with:

- A unified monorepo-driven and git-driven approach for all kinds of projects (single-purpose library, multiple libraries, application(s), ...)
- Support for several application templates (for now, only a default template is available, but others can be added later).
- Standardized file structure including optional folder creation such as `examples`, `packages`, ...
- Enable all project lifecycle steps with commands from the setup, check, fix, build, and test to the versioning and release.
- Built-in configuration preset setup (including Node/NPM runtime, Git ignore/hooks, [TypeScript](https://github.com/adbayb/stack/blob/main/stack/configs/typescript/), [Oxlint](https://github.com/adbayb/stack/blob/main/stack/configs/oxlint/), [Oxfmt](https://github.com/adbayb/stack/blob/main/stack/configs/oxfmt/), EditorConfig, Renovate, Changesets, and VSCode).
- A welcoming environment for users and contributors with the continuous integration setup, and the creation of `README.md`, `CONTRIBUTING.md`, and GitHub template files (including issue and pull request ones), ...
- An optimized development environment with command caching (no build needed if nothing changes).

<br>

## 🚀 Usage

This section introduces the `stack` essentials by walking through its main commands:

1️⃣ Create the NPM project via the `@adbayb/create` initializer:

```bash
# Npm
npm init @adbayb
# Pnpm
pnpm create @adbayb
```

2️⃣ Play with available commands (already set up in the generated root `package.json`):

```bash
# Setup initial requirements (including Git hooks installation)
stack install
# Clean the project
stack clean
# Check code health (static analysis including linters and types)
stack check
# Fix auto-fixable issues
stack fix
# Start the project in production mode
stack start
# Build the project in production mode
stack build
# Build and start the project in development mode
stack watch
# Test the code execution
stack test
# Log, version, and publish package(s)
stack release
```

3️⃣ Enjoy!

<br>

## 🌍 Ecosystem

### Available configurations

- [@adbayb/stack/oxlint](https://github.com/adbayb/stack/blob/main/stack/configs/oxlint/) to align logical and stylistic rules across projects.
- [@adbayb/stack/oxfmt](https://github.com/adbayb/stack/blob/main/stack/configs/oxfmt/) to align code formatting conventions across projects.
- [@adbayb/stack/typescript](https://github.com/adbayb/stack/blob/main/stack/configs/typescript/) to align type checking and processing across projects.

### Agent skills

`@adbayb/stack` ships six [Agent Skills](https://agentskills.io/specification) for coding agents:

- [software-design](https://github.com/adbayb/stack/blob/main/stack/skills/software-design/): design and write clean, testable code; the single source of the design rules and glossary.
- [software-audit](https://github.com/adbayb/stack/blob/main/stack/skills/software-audit/): audit code or pull requests against the `software-design` rules (depends on `software-design`).
- [document-design](https://github.com/adbayb/stack/blob/main/stack/skills/document-design/): create project documentation from the embedded README template; requires the [`makespec`](https://github.com/adbayb/makespec) skill for ADR, RFC, and PDR work.
- [document-audit](https://github.com/adbayb/stack/blob/main/stack/skills/document-audit/): audit project documentation, including ADR, RFC, and PDR records (requires `document-design` and [`makespec`](https://github.com/adbayb/makespec)).
- [skill-design](https://github.com/adbayb/stack/blob/main/stack/skills/skill-design/): design and write skills with one shared anatomy, plus agent instructions such as `AGENTS.md`; the single source of the writing rules.
- [skill-audit](https://github.com/adbayb/stack/blob/main/stack/skills/skill-audit/): audit and score skills and agent instructions such as `AGENTS.md` against the `skill-design` rules (depends on `skill-design` and Anthropic `skill-creator` for skill evaluation).

With [pnpm 12.11.0 or later](https://pnpm.io/agent-skills), install the package as a direct dependency and approve its skills:

```bash
pnpm add -D @adbayb/stack
pnpm approve
```

If the package is already installed, run `pnpm approve`. Select `@adbayb/stack` to approve all six skills; pnpm records the approval in `pnpm-workspace.yaml`. pnpm links skills into existing agent skill directories by default. To choose a directory explicitly, configure:

```yaml
skills:
    dirs:
        - .agents/skills
```

Links use names such as `pnpm-@adbayb+stack-software-design`. Global installs and `pnpm dlx` do not link skills.

For older pnpm versions or global installation, install from the repository with:

```bash
pnpm dlx skills add adbayb/stack --skill software-design -g
pnpm dlx skills add adbayb/stack --skill software-audit -g
pnpm dlx skills add adbayb/stack --skill document-design -g
pnpm dlx skills add adbayb/stack --skill document-audit -g
pnpm dlx skills add adbayb/stack --skill skill-design -g
pnpm dlx skills add adbayb/stack --skill skill-audit -g
```

Use `pnpm dlx` rather than `npx`: the repo's `devEngines` gate accepts pnpm only.

In this repository, `stack/skills/` is the published source and `.agents/skills` is a relative symlink to it, so local agents use the same files.

### Used technologies

- **Static code analysis**: Oxlint, Oxfmt
- **Node package manager**: PNPM
- **Task orchestration**: Turborepo
- **Release**: Changesets
- **Testing**: Vitest

### Used conventions

- [Commits](https://www.conventionalcommits.org/)
- [Scripts](https://conventionalscripts.org/)
- [File Structure](https://nx.dev/concepts/decisions/folder-structure)
    - Monorepo-first structure to:
        - Keep a consistent file structure pattern across templates (ease template familiarity and onboarding).
        - Ease examples setup.
        - Not clutter the published package with development-related context, metadata, and artifacts.

<br>

## 🏗️ Architecture

### Project creation workflow

```mermaid
flowchart TD
    N("npm init @adbayb"):::strokeWidth -- Runs --> C("@adbayb/create"):::strokeWidth
    C -- Runs --> S("@adbayb/stack create"):::strokeWidth
    S -- "Scaffolds (via template and shared configurations)" --> P("New project"):::strokeWidth
    style C fill:#daf2d7,stroke:#90cf8e
    style S fill:#daf2d7,stroke:#90cf8e
    classDef strokeWidth stroke-width:3px
```

<br>

## ✍️ Contribution

We're open to new contributions, you can find more details [here](https://github.com/adbayb/stack/blob/main/CONTRIBUTING.md).

<br>

## 📖 License

[MIT](https://github.com/adbayb/stack/blob/main/LICENSE "License MIT")

<br>
