Skip to content

🎥 Make videos programmatically with React

`create-video`: Add --yes flag for non-interactive mode (#6884)

Jonny Burger82793466dc1a
diff --git a/packages/create-video/src/init.ts b/packages/create-video/src/init.ts
index 8f6e0b9308..d7d7db8cee 100644
--- a/packages/create-video/src/init.ts
+++ b/packages/create-video/src/init.ts
@@ -23,7 +23,13 @@ import {
} from './pkg-managers';
import prompts from './prompts';
import {resolveProjectRoot} from './resolve-project-root';
-import {getDirectoryArgument, selectTemplate} from './select-template';
+import {
+ getDirectoryArgument,
+ isNoTailwindFlagSelected,
+ isTmpFlagSelected,
+ isYesFlagSelected,
+ selectTemplate,
+} from './select-template';
const gitExists = (commandToCheck: string, argsToCheck: string[]) => {
try {
@@ -85,6 +91,13 @@ export const init = async () => {
// Get directory argument if provided
const directoryArgument = getDirectoryArgument();
+ if (isYesFlagSelected() && !directoryArgument && !isTmpFlagSelected()) {
+ Log.error(
+ 'A directory name must be specified when using --yes. Example: --yes --blank my-video',
+ );
+ process.exit(1);
+ }
+
// Select template first
const selectedTemplate = await selectTemplate();
@@ -118,6 +131,15 @@ export const init = async () => {
const isInsideGitRepo = result.type === 'is-git-repo';
if (isInsideGitRepo) {
+ if (isYesFlagSelected()) {
+ Log.error(
+ `You are already inside a Git repo (${path.resolve(
+ result.location,
+ )}). Cannot use --yes inside an existing Git repository.`,
+ );
+ process.exit(1);
+ }
+
const {shouldContinue} = await prompts({
type: 'toggle',
name: 'shouldContinue',
@@ -136,10 +158,12 @@ export const init = async () => {
const latestRemotionVersionPromise = getLatestRemotionVersion();
const shouldOverrideTailwind = selectedTemplate.allowEnableTailwind
- ? await askTailwind()
+ ? isYesFlagSelected()
+ ? !isNoTailwindFlagSelected()
+ : await askTailwind()
: false;
- const shouldInstallSkills = await askSkills();
+ const shouldInstallSkills = isYesFlagSelected() ? false : await askSkills();
const pkgManager = selectPackageManager();
const pkgManagerVersion = await getPackageManagerVersionOrNull(pkgManager);
@@ -241,5 +265,7 @@ export const init = async () => {
);
Log.info();
- await openInEditorFlow(projectRoot);
+ if (!isYesFlagSelected()) {
+ await openInEditorFlow(projectRoot);
+ }
};
diff --git a/packages/create-video/src/select-template.ts b/packages/create-video/src/select-template.ts
index b6b59c81a5..5b29532d16 100644
--- a/packages/create-video/src/select-template.ts
+++ b/packages/create-video/src/select-template.ts
@@ -9,15 +9,22 @@ const ALL_TEMPLATES = [...FEATURED_TEMPLATES, ...PAID_TEMPLATES];
type Options = {
tmp: boolean;
+ yes: boolean;
+ 'no-tailwind': boolean;
};
const parsed = minimist<Options>(process.argv.slice(2), {
- boolean: [...ALL_TEMPLATES.map((f) => f.cliId), 'tmp'],
+ boolean: [...ALL_TEMPLATES.map((f) => f.cliId), 'tmp', 'yes', 'no-tailwind'],
string: ['_'],
+ alias: {y: 'yes'},
});
export const isTmpFlagSelected = () => parsed.tmp;
+export const isYesFlagSelected = () => parsed.yes;
+
+export const isNoTailwindFlagSelected = () => parsed['no-tailwind'];
+
export const getPositionalArguments = () => parsed._;
export const getDirectoryArgument = (): string | null => {
@@ -34,6 +41,12 @@ export const selectTemplate = async () => {
return isFlagSelected;
}
+ if (isYesFlagSelected()) {
+ throw new Error(
+ 'A template must be specified when using --yes. Example: --yes --blank',
+ );
+ }
+
return (await selectAsync({
message: 'Choose a template:',
optionsPerPage: 20,
diff --git a/packages/docs/components/CreateVideoTemplateFlags.tsx b/packages/docs/components/CreateVideoTemplateFlags.tsx
new file mode 100644
index 0000000000..4740ae9463
--- /dev/null
+++ b/packages/docs/components/CreateVideoTemplateFlags.tsx
@@ -0,0 +1,15 @@
+import {CreateVideoInternals} from 'create-video';
+import React from 'react';
+
+export const CreateVideoTemplateFlags: React.FC = () => {
+ return (
+ <>
+ {CreateVideoInternals.FEATURED_TEMPLATES.map((t) => (
+ <code key={t.cliId}>--{t.cliId}</code>
+ )).reduce<React.ReactNode[]>((acc, el, i) => {
+ if (i === 0) return [el];
+ return [...acc, ', ', el];
+ }, [])}
+ </>
+ );
+};
diff --git a/packages/docs/docs/cli/create-video.mdx b/packages/docs/docs/cli/create-video.mdx
new file mode 100644
index 0000000000..36cf46972c
--- /dev/null
+++ b/packages/docs/docs/cli/create-video.mdx
@@ -0,0 +1,101 @@
+---
+image: /generated/articles-docs-cli-create-video.png
+title: npx create-video
+sidebar_label: create-video
+crumb: CLI Reference
+---
+
+import {CreateVideoTemplateFlags} from '../../components/CreateVideoTemplateFlags';
+
+Scaffold a new Remotion project.
+
+```bash
+npx create-video <directory>
+```
+
+If no arguments are passed, an interactive TUI will guide you through the setup.
+
+## Arguments
+
+### `<directory>`
+
+The directory in which the project should be created.
+
+## Flags
+
+### `--yes`<AvailableFrom v="4.0.439" />
+
+Enable non-interactive mode. All prompts are skipped with sensible defaults.
+
+Requires a template flag and a directory argument.
+
+When used:
+- TailwindCSS is installed if the template supports it (disable with `--no-tailwind`)
+- Agent skills are not installed
+- The editor is not opened
+- If already inside a Git repository, the command fails
+
+```bash
+npx create-video --yes --blank my-video
+```
+
+### `-y`<AvailableFrom v="4.0.439" />
+
+Alias for `--yes`.
+
+### `--no-tailwind`<AvailableFrom v="4.0.439" />
+
+When combined with `--yes`, skip installing TailwindCSS. Without `--yes`, this flag has no effect because TailwindCSS is offered interactively.
+
+```bash
+npx create-video --yes --blank --no-tailwind my-video
+```
+
+### `--tmp`<AvailableFrom v="4.0.214" />
+
+Create the project in a temporary directory instead of specifying a directory name.
+
+```bash
+npx create-video --yes --blank --tmp
+```
+
+### Template flags
+
+Pass a template name as a flag to skip the template selection prompt.
+
+```bash
+npx create-video --blank my-video
+```
+
+Available templates: <CreateVideoTemplateFlags />.
+
+## Non-interactive mode
+
+By passing `--yes` (or `-y`), all prompts are skipped and the project is created with sensible defaults. This is useful for scripting and AI agents like Claude Code.
+
+A template flag and a directory argument are required.
+
+```bash
+npx create-video --yes --blank my-video
+```
+
+When using `--yes`:
+
+- TailwindCSS is installed if the template supports it. Pass [`--no-tailwind`](#--no-tailwind) to skip it.
+- [Agent skills](/docs/ai/skills) are not installed. You can add them manually afterwards by running [`npx skills add remotion-dev/skills`](/docs/cli/skills) in the project directory.
+- The editor is not opened after scaffolding.
+- The command fails if you are already inside a Git repository.
+
+### Examples
+
+Without TailwindCSS:
+
+```bash
+npx create-video --yes --blank --no-tailwind my-video
+```
+
+In a temporary directory:
+
+```bash
+npx create-video --yes --blank --tmp
+```
diff --git a/packages/docs/sidebars.ts b/packages/docs/sidebars.ts
index f6ead1a33b..35578ce253 100644
--- a/packages/docs/sidebars.ts
+++ b/packages/docs/sidebars.ts
@@ -13,6 +13,7 @@ const sidebars: SidebarsConfig = {
},
collapsed: true,
items: [
+ 'cli/create-video',
'cli/studio',
'cli/render',
'cli/still',
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index 0d90f801cb..f175c1f69f 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -692,6 +692,15 @@ export const articles = [
noAi: false,
slug: 'cli/compositions',
},
+ {
+ id: 'cli/create-video',
+ title: 'npx create-video',
+ relativePath: 'docs/cli/create-video.mdx',
+ compId: 'articles-docs-cli-create-video',
+ crumb: 'CLI Reference',
+ noAi: false,
+ slug: 'cli/create-video',
+ },
{
id: 'ffmpeg',
title: 'npx remotion ffmpeg',
diff --git a/packages/docs/static/generated/articles-docs-cli-create-video.png b/packages/docs/static/generated/articles-docs-cli-create-video.png
new file mode 100644
index 0000000000..4614adf537
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-cli-create-video.png differ