init-taro-miniapp
Init Taro Mini-Program
Initialize a Taro project only with the official CLI; after init, create directories, configure the API proxy, and may add or update README and AGENTS.md. Do not modify any other generated files or config.
Constraint
- Init command (mandatory): Must use
npx @tarojs/cli init <projectName>to create the project. Do not use globaltaro initor other scaffolding. - Required after init: Run
npm install(orpnpm install/yarnif chosen during init) from the project root; do not skip. - After init (allowed only): (1) create new directories under
src, (2) add or edit the dev proxy configuration for the backend API, and (3) add or edit README and AGENTS.md. Do not changepackage.json, existing source files, or other config files.
Reference Docs
Workflow
1. Initialize with Taro CLI (required)
From the parent directory where the project should be created, run:
npx @tarojs/cli init <projectName>
Example:
npx @tarojs/cli init myApp
- Use only this command to create the project. During the interactive init, the user (or you on their behalf) may choose framework (React/Vue3), TypeScript, CSS preprocessor, bundler, package manager.
- Do not replace or re-scaffold with any other tool or template.
2. Install dependencies (required)
From the project root (the directory created by init), run:
npm install
If the user chose pnpm or yarn during init, use pnpm install or yarn instead. This step is required; do not skip it.
3. Create directories under src
Only add these directories under the project's src (create only if missing; do not change existing files):
- apis — API wrappers and request helpers
- utils — Utilities
- components — Shared and feature components
- consts — Constants, enums, config
Optionally add: hooks (React), services. Do not add files inside them unless the user explicitly asks; creating empty directories is enough.
4. Configure dev proxy for API
Only modify the project config to add the H5 dev proxy so the frontend can call the backend during local development. Default backend port: 5000.
- Config file: usually
config/index.js(orconfig/dev.jsin the generated project). - Under h5 → devServer, add or merge proxy (e.g. forward
/apito the backend):
h5: {
devServer: {
proxy: {
'/api': {
target: 'http://localhost:5000',
changeOrigin: true,
pathRewrite: { '^/api': '/api' }
}
}
}
}
- If the backend port is not 5000, set
targettohttp://localhost:<port>. AdjustpathRewriteif the backend uses a different path prefix. - Do not change other options in the config file beyond what is needed for this proxy.
5. Add or update README and AGENTS.md
- AGENTS.md: In the project root, create or overwrite
AGENTS.mdfrom this skill's templateassets/templates/AGENTS.template.md. Fill placeholders:{{PROJECT_NAME}},{{PROJECT_DESCRIPTION}},{{TECH_STACK_TABLE}},{{DIR_STRUCTURE}}(includesrc/with apis, utils, components, consts, andconfig/,dist/),{{SCRIPTS}},{{INITIALIZED_DATE}}(YYYY-MM-DD). - README: May add or update a project README (e.g. project name, how to run, proxy/port note). Keep minimal unless the user asks for more.
6. Do not do
- Do not change
package.json, dependencies, or scripts (except running the install command in step 2). - Do not modify existing source files, app entry, or other config (e.g.
app.config.ts,babel.config.js) except the proxy block in step 4.