R-Kentaren's picture
feat(agent): add Claude Code-style agent, skills, slash-commands, hooks, todos, sandboxed workspace, and full-stack scaffolding
81aa0b5 verified
|
Raw
History Blame Contribute Delete
3.88 kB
---
name: fullstack-scaffold
description: Scaffold complete fullstack projects with proper structure. Generates package.json, requirements.txt, Dockerfiles, and config files for any framework.
language: any
tags: scaffold, fullstack, project, structure, framework
---
# Fullstack Project Scaffolding
When generating a fullstack application, always produce a complete, runnable project β€” not just snippets.
## Project structure rules
### Python (Flask/FastAPI/Django/Streamlit/Gradio)
```
project-name/
β”œβ”€β”€ app.py # Entry point (HF Spaces expects app.py)
β”œβ”€β”€ requirements.txt # Pinned dependencies
β”œβ”€β”€ README.md # With HF Space frontmatter if deploying
β”œβ”€β”€ .env.example # Document required env vars
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ __init__.py
β”‚ β”œβ”€β”€ routes/ # API routes
β”‚ β”œβ”€β”€ models/ # Data models
β”‚ β”œβ”€β”€ services/ # Business logic
β”‚ └── utils/ # Helpers
β”œβ”€β”€ tests/
β”‚ └── test_app.py
└── static/ # Static assets (if web framework)
```
### Next.js / React (Vite)
```
project-name/
β”œβ”€β”€ package.json # name, version, scripts, deps
β”œβ”€β”€ next.config.js # (Next.js only) output: 'standalone'
β”œβ”€β”€ vite.config.js # (Vite only)
β”œβ”€β”€ tsconfig.json # (TypeScript)
β”œβ”€β”€ Dockerfile # Multi-stage build for HF Spaces
β”œβ”€β”€ .dockerignore
β”œβ”€β”€ README.md
β”œβ”€β”€ public/
β”‚ └── (static assets)
└── src/
β”œβ”€β”€ app/ # Next.js App Router
β”œβ”€β”€ pages/ # Next.js Pages Router (legacy)
β”œβ”€β”€ components/ # Reusable components
β”œβ”€β”€ lib/ # Utilities, helpers
β”œβ”€β”€ hooks/ # Custom hooks
β”œβ”€β”€ styles/ # Global CSS
└── types/ # TypeScript types
```
### Express / NestJS
```
project-name/
β”œβ”€β”€ package.json
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ .dockerignore
β”œβ”€β”€ README.md
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ index.js # Entry β€” app.listen(7860, '0.0.0.0')
β”‚ β”œβ”€β”€ routes/
β”‚ β”œβ”€β”€ middleware/
β”‚ β”œβ”€β”€ controllers/ # NestJS only
β”‚ β”œβ”€β”€ services/
β”‚ └── models/
└── tests/
```
## Port and host rules (critical for HF Spaces)
- All servers MUST listen on `0.0.0.0` (not `localhost` or `127.0.0.1`)
- All servers MUST use port `7860` (HF Spaces default)
- For sub-servers (Gradio subprocess), use 7861, 7862, etc.
## Dockerfile rules
For JS/TS projects, generate a Dockerfile:
- Use `node:20-slim` as base
- Multi-stage build: deps β†’ builder β†’ runner
- For SPAs (React/Vue), serve with nginx on port 7860
- For Next.js, use `output: 'standalone'` and copy `.next/standalone`
- Run as non-root user
For Python projects, the HF Space SDK auto-generates the runtime β€” no Dockerfile needed unless using Docker SDK.
## package.json rules
- Always include `name`, `version`, `private: true`
- Scripts: `dev`, `build`, `start` (start must bind 0.0.0.0:7860)
- Pin major versions: `"react": "^18.3.0"` not `"react": "latest"`
- Dev dependencies: TypeScript, types, build tools, linters
- Production dependencies: runtime libraries only
## requirements.txt rules
- Pin with `>=` to allow patch updates: `flask>=3.0.0`
- Group by category (web, db, ml, dev) with comments
- Always include the framework (flask, fastapi, gradio, etc.)
- Never include stdlib modules
## README.md rules
For HF Spaces, include frontmatter:
```yaml
---
title: App Name
emoji: πŸš€
colorFrom: blue
colorTo: purple
sdk: gradio # or docker, static, streamlit
app_file: app.py # or index.html, Dockerfile
pinned: false
---
```
## Don't include
- `node_modules/`
- `.next/` (build output)
- `__pycache__/`
- `.venv/`, `venv/`
- Lock files (let HF install fresh)
- `.env` (only `.env.example`)