Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a76e423
initial lefthook support
therealsamyak Dec 13, 2025
0356aa6
lefthook template
therealsamyak Dec 13, 2025
9630225
lefthook addon
therealsamyak Dec 13, 2025
25de9d6
skip lefthook template if no linter selected
therealsamyak Dec 13, 2025
a255b0f
template update
therealsamyak Dec 13, 2025
2d8916f
always add lefthook.yml file
therealsamyak Dec 13, 2025
8a2e864
lint-staged only necessary w/ husky
therealsamyak Dec 13, 2025
74ef0e5
file fixing
therealsamyak Dec 13, 2025
a38915d
lefthook and husky work in parallel
therealsamyak Dec 18, 2025
6fc2f40
git hooks group
therealsamyak Dec 18, 2025
f5ebc14
spacing fix
therealsamyak Dec 18, 2025
d48afc9
reordered addons section to make more sense
therealsamyak Dec 18, 2025
2c6c649
fixed ultracite compat
therealsamyak Dec 18, 2025
4e53c72
skip lefthook template if ultracite configured
therealsamyak Dec 20, 2025
6015238
coderabbit fixes
therealsamyak Dec 21, 2025
8b87414
newest lefthook version
therealsamyak Dec 21, 2025
5000e14
'bun check' fixes
therealsamyak Dec 21, 2025
3877c38
hasLinting
therealsamyak Dec 22, 2025
fb8c776
logic fixes
therealsamyak Dec 22, 2025
11aaae9
fixed merge conflict
therealsamyak Dec 25, 2025
246ea17
Merge branch 'main' into sk/add-lefthook
AmanVarshney01 Jan 9, 2026
69e4c7c
feat: add lefthook to dependencyVersionMap
AmanVarshney01 Jan 10, 2026
2461e98
refactor: update lefthook config to use newer jobs syntax
AmanVarshney01 Jan 10, 2026
561b4ff
fix: remove unnecessary glob from oxfmt job
AmanVarshney01 Jan 10, 2026
357ba6a
fix: update ultracite setup to match latest CLI
AmanVarshney01 Jan 10, 2026
475d87d
fix: init git before install dependencies
AmanVarshney01 Jan 10, 2026
b9fce67
Revert "fix: init git before install dependencies"
AmanVarshney01 Jan 10, 2026
5ffb73a
fix: make prepare scripts git-aware to avoid install failures
AmanVarshney01 Jan 10, 2026
286dc2d
fix: husky uses simple prepare, lefthook uses git check
AmanVarshney01 Jan 10, 2026
cb9a1b2
fix: remove biome.json.hbs from ultracite templates
AmanVarshney01 Jan 10, 2026
b7d335a
fix: remove prepare script for lefthook (auto-installs via postinstall)
AmanVarshney01 Jan 10, 2026
d68c268
refactor: move lefthook config to template-generator with package man…
AmanVarshney01 Jan 10, 2026
b7f886e
chore: regenerate embedded templates with lefthook
AmanVarshney01 Jan 10, 2026
e7199f9
feat: add lefthook install instructions to post-install output
AmanVarshney01 Jan 10, 2026
700ad84
fix
AmanVarshney01 Jan 10, 2026
b22990e
fix
AmanVarshney01 Jan 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ npx create-better-t-stack@latest
- Databases: SQLite, PostgreSQL, MySQL, MongoDB (or none)
- ORMs: Drizzle, Prisma, Mongoose (or none)
- Auth: Better-Auth (optional)
- Addons: Turborepo, PWA, Tauri, Biome, Husky, Starlight, Fumadocs, Ruler, Ultracite, Oxlint
- Addons: Turborepo, PWA, Tauri, Biome, Lefthook, Husky, Starlight, Fumadocs, Ruler, Ultracite, Oxlint
- Examples: Todo, AI
- DB Setup: Turso, Neon, Supabase, Prisma PostgreSQL, MongoDB Atlas, Cloudflare D1, Docker
- Web Deploy: Cloudflare Workers
Expand Down
6 changes: 3 additions & 3 deletions apps/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Follow the prompts to configure your project or use the `--yes` flag for default
| **Database Setup** | • Turso (SQLite)<br>• Cloudflare D1 (SQLite)<br>• Neon (PostgreSQL)<br>• Supabase (PostgreSQL)<br>• Prisma Postgres<br>• MongoDB Atlas<br>• None (manual setup) |
| **Authentication** | Better-Auth (email/password, with more options coming soon) |
| **Styling** | Tailwind CSS with shadcn/ui components |
| **Addons** | • PWA support<br>• Tauri (desktop applications)<br>• Starlight (documentation site)<br>• Biome (linting and formatting)<br>• Husky (Git hooks)<br>• Turborepo (optimized builds) |
| **Addons** | • PWA support<br>• Tauri (desktop applications)<br>• Starlight (documentation site)<br>• Biome (linting and formatting)<br>• Lefthook, Husky (Git hooks)<br>• Turborepo (optimized builds) |
| **Examples** | • Todo app<br>• AI Chat interface (using Vercel AI SDK) |
| **Developer Experience** | • Automatic Git initialization<br>• Package manager choice (npm, pnpm, bun)<br>• Automatic dependency installation |

Expand All @@ -58,7 +58,7 @@ Options:
--auth Include authentication
--no-auth Exclude authentication
--frontend <types...> Frontend types (tanstack-router, react-router, tanstack-start, next, nuxt, svelte, solid, native-bare, native-uniwind, native-unistyles, none)
--addons <types...> Additional addons (pwa, tauri, starlight, biome, husky, turborepo, fumadocs, ultracite, oxlint, none)
--addons <types...> Additional addons (pwa, tauri, starlight, biome, lefthook, husky, turborepo, fumadocs, ultracite, oxlint, none)
--examples <types...> Examples to include (todo, ai, none)
--git Initialize git repository
--no-git Skip git initialization
Expand Down Expand Up @@ -193,7 +193,7 @@ npx create-better-t-stack --frontend none --backend hono --api trpc --database n
- **ORM 'none'**: Can be used when you want to handle database operations manually or use a different ORM.
- **Runtime 'none'**: Only available with Convex backend or when backend is 'none'.
- **Cloudflare Workers runtime**: Only compatible with Hono backend, Drizzle ORM (or no ORM), and SQLite database (with D1 setup). Not compatible with MongoDB.
- **Addons 'none'**: Skips all addons (PWA, Tauri, Starlight, Biome, Husky, Turborepo).
- **Addons 'none'**: Skips all addons (PWA, Tauri, Starlight, Biome, Lefthook,Husky, Turborepo).
- **Examples 'none'**: Skips all example implementations (todo, AI chat).
- **SvelteKit, Nuxt, and SolidJS** frontends are only compatible with oRPC API layer
- **PWA support** requires React with TanStack Router, React Router, or SolidJS
Expand Down
1 change: 1 addition & 0 deletions apps/cli/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const ADDON_COMPATIBILITY = {
tauri: ["tanstack-router", "react-router", "nuxt", "svelte", "solid", "next"],
biome: [],
husky: [],
lefthook: [],
turborepo: [],
starlight: [],
ultracite: [],
Expand Down
29 changes: 22 additions & 7 deletions apps/cli/src/helpers/addons/addons-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ export async function setupAddons(config: ProjectConfig) {
const hasUltracite = addons.includes("ultracite");
const hasBiome = addons.includes("biome");
const hasHusky = addons.includes("husky");
const hasLefthook = addons.includes("lefthook");
const hasOxlint = addons.includes("oxlint");

if (!hasUltracite) {
if (hasUltracite) {
const gitHooks: string[] = [];
if (hasHusky) gitHooks.push("husky");
if (hasLefthook) gitHooks.push("lefthook");
await setupUltracite(config, gitHooks);
} else {
if (hasBiome) {
await setupBiome(projectDir);
}
Expand All @@ -49,14 +55,19 @@ export async function setupAddons(config: ProjectConfig) {
await setupOxlint(projectDir, config.packageManager);
}

if (hasHusky) {
if (hasHusky || hasLefthook) {
let linter: "biome" | "oxlint" | undefined;
if (hasOxlint) {
linter = "oxlint";
} else if (hasBiome) {
linter = "biome";
}
await setupHusky(projectDir, linter);
if (hasHusky) {
await setupHusky(projectDir, linter);
}
if (hasLefthook) {
await setupLefthook(projectDir);
}
}
}

Expand All @@ -76,10 +87,6 @@ export async function setupAddons(config: ProjectConfig) {
await setupWxt(config);
}

if (hasUltracite) {
await setupUltracite(config, hasHusky);
}

if (addons.includes("ruler")) {
await setupRuler(config);
}
Expand Down Expand Up @@ -136,3 +143,11 @@ export async function setupHusky(projectDir: string, linter?: "biome" | "oxlint"
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
}
}

export async function setupLefthook(projectDir: string) {
await addPackageDependency({
devDependencies: ["lefthook"],
projectDir,
});
// lefthook.yml is generated by template-generator from templates/addons/lefthook/
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lefthook missing prepare script for automatic hook installation

Medium Severity

The setupLefthook function only adds the lefthook dependency but doesn't add a prepare script to package.json. In contrast, setupHusky adds prepare: "husky" which ensures hooks are installed automatically when users run npm install. Without this, lefthook users must manually run lefthook install every time they clone the repo. The PR description claims a prepare script with lefthook install is added to the template, but the implementation is missing this functionality.

Fix in Cursor Fix in Web

21 changes: 16 additions & 5 deletions apps/cli/src/helpers/addons/ultracite-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ type UltraciteAgent =
| "crush"
| "qwen"
| "amazon-q-cli"
| "firebender";
| "firebender"
| "cursor-cli"
| "mistral-vibe"
| "vercel";

type UltraciteHook = "cursor" | "windsurf";
type UltraciteHook = "cursor" | "windsurf" | "claude";

const LINTERS = {
biome: { label: "Biome", hint: "Fast formatter and linter" },
Expand Down Expand Up @@ -85,11 +88,15 @@ const AGENTS = {
qwen: { label: "Qwen" },
"amazon-q-cli": { label: "Amazon Q CLI" },
firebender: { label: "Firebender" },
"cursor-cli": { label: "Cursor CLI" },
"mistral-vibe": { label: "Mistral Vibe" },
vercel: { label: "Vercel" },
} as const;

const HOOKS = {
cursor: { label: "Cursor" },
windsurf: { label: "Windsurf" },
claude: { label: "Claude" },
} as const;

function getFrameworksFromFrontend(frontend: string[]): string[] {
Expand Down Expand Up @@ -117,7 +124,7 @@ function getFrameworksFromFrontend(frontend: string[]): string[] {
return Array.from(frameworks);
}

export async function setupUltracite(config: ProjectConfig, hasHusky: boolean) {
export async function setupUltracite(config: ProjectConfig, gitHooks: string[]) {
const { packageManager, projectDir, frontend } = config;

try {
Expand Down Expand Up @@ -193,8 +200,12 @@ export async function setupUltracite(config: ProjectConfig, hasHusky: boolean) {
ultraciteArgs.push("--hooks", ...hooks);
}

if (hasHusky) {
ultraciteArgs.push("--integrations", "husky", "lint-staged");
if (gitHooks.length > 0) {
const integrations = [...gitHooks];
if (gitHooks.includes("husky")) {
integrations.push("lint-staged");
}
ultraciteArgs.push("--integrations", ...integrations);
Comment thread
AmanVarshney01 marked this conversation as resolved.
Resolved
}

const ultraciteArgsString = ultraciteArgs.join(" ");
Expand Down
18 changes: 16 additions & 2 deletions apps/cli/src/helpers/core/post-installation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ export async function displayPostInstallInstructions(
packageManager === "npm" ? "npm run" : packageManager === "pnpm" ? "pnpm run" : "bun run";
const cdCmd = `cd ${relativePath}`;
const hasHusky = addons?.includes("husky");
const hasLinting = addons?.includes("biome") || addons?.includes("oxlint");
const hasLefthook = addons?.includes("lefthook");
const hasGitHooksOrLinting =
addons?.includes("husky") ||
addons?.includes("biome") ||
addons?.includes("lefthook") ||
addons?.includes("oxlint");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instructions reference non-existent check script

Medium Severity

The hasGitHooksOrLinting variable now includes husky and lefthook in its condition, but it's used to determine whether to show linting instructions that tell users to run ${runCmd} check. The check script is only added by setupBiome or setupOxlint, not by setupHusky or setupLefthook. When a user selects only lefthook or husky without biome/oxlint, they receive instructions to run a script that doesn't exist, causing a "missing script" error.

Additional Locations (1)

Fix in Cursor Fix in Web


const databaseInstructions =
!isConvex && database !== "none"
Expand All @@ -56,7 +61,8 @@ export async function displayPostInstallInstructions(

const tauriInstructions = addons?.includes("tauri") ? getTauriInstructions(runCmd) : "";
const huskyInstructions = hasHusky ? getHuskyInstructions(runCmd) : "";
const lintingInstructions = hasLinting ? getLintingInstructions(runCmd) : "";
const lefthookInstructions = hasLefthook ? getLefthookInstructions(packageManager) : "";
const lintingInstructions = hasGitHooksOrLinting ? getLintingInstructions(runCmd) : "";
Comment thread
AmanVarshney01 marked this conversation as resolved.
Resolved

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linting instructions shown when no linter is configured

Medium Severity

The variable hasGitHooksOrLinting is used to determine whether to show linting instructions (line 65), but it includes husky and lefthook in addition to biome and oxlint. The check script is only created when setupBiome() or setupOxlint() is called, not when husky or lefthook is configured. If a user selects only husky or lefthook without biome or oxlint, they'll see instructions to run the check script that doesn't exist. The variable should be split - one for git hooks and one specifically for linting tools that actually add the check script.

Fix in Cursor Fix in Web

const nativeInstructions =
(frontend?.includes("native-bare") ||
frontend?.includes("native-uniwind") ||
Expand Down Expand Up @@ -184,6 +190,7 @@ export async function displayPostInstallInstructions(
if (databaseInstructions) output += `\n${databaseInstructions.trim()}\n`;
if (tauriInstructions) output += `\n${tauriInstructions.trim()}\n`;
if (huskyInstructions) output += `\n${huskyInstructions.trim()}\n`;
if (lefthookInstructions) output += `\n${lefthookInstructions.trim()}\n`;
if (lintingInstructions) output += `\n${lintingInstructions.trim()}\n`;
if (pwaInstructions) output += `\n${pwaInstructions.trim()}\n`;
if (alchemyDeployInstructions) output += `\n${alchemyDeployInstructions.trim()}\n`;
Expand Down Expand Up @@ -250,6 +257,13 @@ function getLintingInstructions(runCmd: string) {
)} Format and lint fix: ${`${runCmd} check`}\n`;
}

function getLefthookInstructions(packageManager: string) {
const cmd = packageManager === "npm" ? "npx" : packageManager;
return `${pc.bold("Git hooks with Lefthook:")}\n${pc.cyan(
"•",
)} Install hooks: ${cmd} lefthook install\n`;
}
Comment thread
AmanVarshney01 marked this conversation as resolved.
Resolved

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect package manager commands for lefthook installation

Medium Severity

The getLefthookInstructions function generates incorrect shell commands for pnpm and bun users. When packageManager is pnpm, it generates pnpm lefthook install, and for bun, it generates bun lefthook install. These commands won't work because pnpm and bun don't automatically resolve binaries from node_modules/.bin when called directly. The correct commands would be pnpm exec lefthook install for pnpm and bunx lefthook install for bun, following the pattern established in the existing getPackageExecutionCommand utility.

Fix in Cursor Fix in Web


async function getDatabaseInstructions(
database: Database,
orm: ORM,
Expand Down
6 changes: 5 additions & 1 deletion apps/cli/src/prompts/addons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ function getAddonDisplay(addon: Addons): { label: string; hint: string } {
label = "Ruler";
hint = "Centralize your AI rules";
break;
case "lefthook":
label = "Lefthook";
hint = "Fast and powerful Git hooks manager";
break;
case "husky":
label = "Husky";
hint = "Modern native Git hooks made easy";
Expand Down Expand Up @@ -72,7 +76,7 @@ function getAddonDisplay(addon: Addons): { label: string; hint: string } {
}

const ADDON_GROUPS = {
Tooling: ["turborepo", "biome", "oxlint", "ultracite", "husky"],
Tooling: ["turborepo", "biome", "oxlint", "ultracite", "husky", "lefthook"],
Documentation: ["starlight", "fumadocs"],
Extensions: ["pwa", "tauri", "opentui", "wxt", "ruler"],
};
Expand Down
23 changes: 22 additions & 1 deletion apps/cli/test/addons.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { expectError, expectSuccess, runTRPCTest, type TestConfig } from "./test

describe("Addon Configurations", () => {
describe("Universal Addons (no frontend restrictions)", () => {
const universalAddons = ["biome", "husky", "turborepo", "oxlint"];
const universalAddons = ["biome", "lefthook", "husky", "turborepo", "oxlint"];

for (const addon of universalAddons) {
it(`should work with ${addon} addon on any frontend`, async () => {
Expand Down Expand Up @@ -195,6 +195,27 @@ describe("Addon Configurations", () => {
expectSuccess(result);
});

it("should work with lefthook and husky together", async () => {
const result = await runTRPCTest({
projectName: "both-git-hooks",
addons: ["lefthook", "husky"],
frontend: ["tanstack-router"],
backend: "hono",
runtime: "bun",
database: "sqlite",
orm: "drizzle",
auth: "none",
api: "trpc",
examples: ["none"],
dbSetup: "none",
webDeploy: "none",
serverDeploy: "none",
install: false,
});

expectSuccess(result);
});

it("should fail with incompatible addon combination", async () => {
const result = await runTRPCTest({
projectName: "incompatible-addons-fail",
Expand Down
1 change: 1 addition & 0 deletions apps/web/content/docs/cli/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ Additional features to include:
- `starlight`: Starlight documentation site
- `fumadocs`: Fumadocs documentation site
- `biome`: Biome linting and formatting
- `lefthook`: Git hooks with Lefthook
- `husky`: Git hooks with Husky
- `turborepo`: Turborepo monorepo setup
- `ultracite`: Ultracite configuration
Expand Down
2 changes: 1 addition & 1 deletion apps/web/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ See the full list in the [CLI Reference](/docs/cli). Key flags:
- `--api`: trpc, orpc, none
- `--auth`: better-auth, clerk, none
- `--payments`: polar, none
- `--addons`: turborepo, pwa, tauri, biome, husky, starlight, fumadocs, ultracite, oxlint, ruler, opentui, wxt, none
- `--addons`: turborepo, pwa, tauri, biome, lefthook, husky, starlight, fumadocs, ultracite, oxlint, ruler, opentui, wxt, none
- `--examples`: todo, ai, none

## Next Steps
Expand Down
2 changes: 1 addition & 1 deletion apps/web/content/docs/project-structure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ When using Starlight or Fumadocs addon:
"backend": "<none|hono|express|fastify|elysia|next|convex>",
"runtime": "<bun|node|workers>",
"frontend": ["<next|tanstack-router|react-router|tanstack-start|nuxt|svelte|solid>"] ,
"addons": ["<turborepo|biome|husky|pwa|starlight>"] ,
"addons": ["<turborepo|biome|lefthook|husky|pwa|starlight>"] ,
"examples": ["<ai|todo|none>"] ,
"auth": <"better-auth"|"clerk"|"none">,
"packageManager": "<bun|pnpm|npm>",
Expand Down
62 changes: 35 additions & 27 deletions apps/web/src/lib/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,19 @@ export const TECH_OPTIONS: Record<
default: false,
},
{
id: "biome",
name: "Biome",
description: "Format, lint, and more",
icon: `${ICON_BASE_URL}/biome.svg`,
color: "from-green-500 to-green-700",
id: "fumadocs",
name: "Fumadocs",
description: "Build excellent documentation site",
icon: `${ICON_BASE_URL}/fumadocs.svg`,
color: "from-indigo-500 to-indigo-700",
default: false,
},
{
id: "lefthook",
name: "Lefthook",
description: "Fast and powerful Git hooks manager",
icon: "",
color: "from-red-500 to-red-700",
default: false,
},
{
Expand All @@ -509,20 +517,11 @@ export const TECH_OPTIONS: Record<
default: false,
},
{
id: "ultracite",
name: "Ultracite",
description: "Biome preset with AI integration",
icon: `${ICON_BASE_URL}/ultracite.svg`,
color: "from-blue-500 to-blue-700",
className: "invert-0 dark:invert",
default: false,
},
{
id: "fumadocs",
name: "Fumadocs",
description: "Build excellent documentation site",
icon: `${ICON_BASE_URL}/fumadocs.svg`,
color: "from-indigo-500 to-indigo-700",
id: "biome",
name: "Biome",
description: "Format, lint, and more",
icon: `${ICON_BASE_URL}/biome.svg`,
color: "from-green-500 to-green-700",
default: false,
},
{
Expand All @@ -533,6 +532,14 @@ export const TECH_OPTIONS: Record<
color: "from-orange-500 to-orange-700",
default: false,
},
{
id: "turborepo",
name: "Turborepo",
description: "High-performance build system",
icon: `${ICON_BASE_URL}/turborepo.svg`,
color: "from-gray-400 to-gray-700",
default: true,
},
{
id: "ruler",
name: "Ruler",
Expand All @@ -541,6 +548,15 @@ export const TECH_OPTIONS: Record<
color: "from-violet-500 to-violet-700",
default: false,
},
{
id: "ultracite",
name: "Ultracite",
description: "Biome preset with AI integration",
icon: `${ICON_BASE_URL}/ultracite.svg`,
color: "from-blue-500 to-blue-700",
className: "invert-0 dark:invert",
default: false,
},
{
id: "opentui",
name: "OpenTUI",
Expand All @@ -557,14 +573,6 @@ export const TECH_OPTIONS: Record<
color: "from-emerald-500 to-emerald-700",
default: false,
},
{
id: "turborepo",
name: "Turborepo",
description: "High-performance build system",
icon: `${ICON_BASE_URL}/turborepo.svg`,
color: "from-gray-400 to-gray-700",
default: true,
},
],
examples: [
{
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/lib/stack-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export function generateStackCommand(stack: StackState) {
"tauri",
"starlight",
"biome",
"lefthook",
"husky",
"turborepo",
"ultracite",
Expand Down
Loading