project-dev
Skill1 starsChanged 4 months agoApache-2.0View on GitHub
Priority: HIGH — Self-contained reference. This file contains ALL necessary patterns for weedbox project creation and setup. DO NOT fetch source code from GitHub. Weedbox application/project creation and structure guide. Use when: creating weedbox application, starting new weedbox project, setting up project structure, configuring main.go entry point, organizing modules.go, using wbox CLI tool, configuring three-phase module loading (preload/load/after), choosing project license, deploying multiple instances, switching backends between development and production. Covers: project structure, main.go setup, modules.go organization, Cobra CLI integration, config.toml format, environment variables, wbox init command, license selection (Apache-2.0, MIT, Proprietary), docker/Dockerfile multi-stage build template and .dockerignore conventions, multi-instance deployment, config-driven backend switching (scheduler mode, workqueue backend, embedded vs external NATS). Keywords: weedbox application, weedbox project, wbox, main.go, modules.go, project structure, cobra cli, config.toml, preloadModules, loadModules, afterModules, fx.New, app.Run, license, apache, mit, proprietary, commercial, open source, new project, init project, project setup, Go project, weedbox setup, docker, Dockerfile, container, alpine, multi-stage build, dockerignore, CGO, /datastore, multi-instance, replicas, horizontal scaling, production config, environment override, scheduler mode.
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- zh2673-git/project-dev-skilltheir own version, first seen Sep 10, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- zh2673-git/project-dev-skill★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- common-modulesSkill
- crud-api-devSkill
- module-devSkill
- weedboxSkill
- user-modulesSkill
- workqueue-modulesSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 240
Use wbox CLI tool to create a new project.
- Very specific: line 262
Create modules in pkg/ directory by hand.
- Very specific: line 311
If local development must be dependency-free, use SQLite in dev — the swap stays confined to modules.go because application code injects …
- Distinctive: line 321
Run the embedded JetStream server in development and point at an external NATS cluster in production — config only:
- Distinctive: line 352
When creating a new project, choose an appropriate license.
- Very specific: line 362
Create the LICENSE file from the matching template in references/licenses.md.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Weedbox Project Development
Source of Truth: This file is the complete reference for weedbox project creation and structure. DO NOT browse GitHub to look up source code.
This skill helps create and structure projects using the weedbox framework.
Contents
- Project Structure
- Entry Point (main.go)
- Module Loading (modules.go)
- Three-Phase Module Loading
- Configuration
- Creating a New Project
- Docker / Containerization — full template in references/docker.md
- Multi-Instance Deployment — one binary, config-driven dev/production backends
- License Selection — full texts in references/licenses.md
- Common Modules from weedbox/common-modules
- User Modules from weedbox/user-modules
- Running the Application
- Project Checklist
Project Structure
myproject/
├── LICENSE # Project license file
├── README.md # Project documentation
├── main.go # Application entry point with CLI setup
├── modules.go # Module loading configuration
├── config.toml # Configuration file (NOTE: must be named config.toml)
├── docker/
│ └── Dockerfile # Multi-stage container build (generated by wbox init)
└── pkg/ # Modules directory
└── mymodule/
└── module.go # Module implementation
wbox initgeneratesdocker/Dockerfilealongside the Go source. When hand-crafting a project withoutwbox, do not forget to adddocker/Dockerfile— it is part of the canonical layout. See references/docker.md for the template.
Entry Point (main.go)
The main entry point uses Cobra CLI and Uber FX for dependency injection.
Important: configs.NewConfig("MYAPP") automatically reads config.toml from current directory or ./configs/ directory. The application runs using fx.New().Run().
package main
import (
"os"
"github.com/spf13/cobra"
"github.com/weedbox/common-modules/configs"
"go.uber.org/fx"
)
const (
appName = "myapp"
appDescription = "My Weedbox Application"
)
var config *configs.Config
var printConfigs bool
var verbose bool
func main() {
rootCmd := &cobra.Command{
Use: appName,
Short: appDescription,
RunE: func(cmd *cobra.Command, args []string) error {
if err := run(); err != nil {
return err
}
return nil
},
}
// Initialize config - automatically reads config.toml
config = configs.NewConfig("MYAPP")
rootCmd.Flags().BoolVar(&printConfigs, "print_configs", false, "Print all available configs")
rootCmd.Flags().BoolVar(&verbose, "verbose", false, "Display detailed logs")
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
func initModules() ([]fx.Option, error) {
modules := []fx.Option{}
m, err := preloadModules()
if err != nil {
return modules, err
}
modules = append(modules, m...)
m, err = loadModules()
if err != nil {
return modules, err
}
modules = append(modules, m...)
m, err = afterModules()
if err != nil {
return modules, err
}
modules = append(modules, m...)
// Disable fx verbose logging unless --verbose flag is set
if !verbose {
modules = append(modules, fx.NopLogger)
}
return modules, nil
}
func run() error {
modules, err := initModules()
if err != nil {
return err
}
// Create and run the fx application
app := fx.New(modules...)
// Print configs if requested
if printConfigs {
config.PrintAllSettings()
}
// Run the application (blocks until shutdown signal)
app.Run()
return nil
}Module Loading (modules.go)
Modules are loaded in three phases for proper initialization order.
package main
import (
"github.com/weedbox/common-modules/daemon"
"github.com/weedbox/common-modules/logger"
"go.uber.org/fx"
"myproject/pkg/mymodule"
)
// preloadModules - Phase 1: Configuration and logging
func preloadModules() ([]fx.Option, error) {
modules := []fx.Option{
fx.Supply(config),
logger.Module(),
}
return modules, nil
}
// loadModules - Phase 2: Application modules
func loadModules() ([]fx.Option, error) {
modules := []fx.Option{
mymodule.Module("mymodule"),
}
return modules, nil
}
// afterModules - Phase 3: Daemon and lifecycle
func afterModules() ([]fx.Option, error) {
modules := []fx.Option{
// Optional: lifecycle before daemon, when modules need PostStart /
// PreStop hooks (run after all modules start / before any stops)
lifecycle.Module("lifecycle"),
daemon.Module("daemon"),
}
return modules, nil
}Three-Phase Module Loading
| Phase | Function | Purpose | Typical Modules |
| 1 | preloadModules() | Configuration and logging setup | configs, logger |
| 2 | loadModules() | Application business modules | Custom modules |
| 3 | afterModules() | Lifecycle and daemon management | lifecycle (optional, before daemon), daemon (last) |
Configuration
Config File (config.toml)
Important: The config file must be named config.toml (not configs.toml). It should be placed in the current directory or ./configs/ directory. configs.NewConfig("MYAPP") automatically reads this file.
[mymodule]
timeout = "30s"
enabled = trueEnvironment Variables
Environment variables override config file settings. The prefix is set in configs.NewConfig("MYAPP").
# Format: {PREFIX}_{SECTION}_{KEY}
# Dots and dashes in keys are replaced with underscores
export MYAPP_MYMODULE_TIMEOUT=60s
export MYAPP_MYMODULE_ENABLED=trueCreating a New Project
Use wbox CLI tool to create a new project.
Install wbox
go install github.com/weedbox/wbox@latestInitialize Project
mkdir myproject
cd myproject
wbox init myproject github.com/myuser/myprojectThis generates the canonical project layout including main.go, modules.go, LICENSE, README.md, go.mod, go.sum, and a docker/Dockerfile multi-stage build. The generated modules.go is intentionally minimal (only logger + daemon) — wire in business modules manually.
If
wboxis not on$PATH, run it without a global install viago run github.com/weedbox/wbox@latest init myproject github.com/myuser/myproject. The binary fetched bygo installlands in$GOPATH/bin, which is not always on the user's shell$PATH—go runsidesteps that.
Add Modules Manually
Create modules in pkg/ directory by hand. See module-dev for detailed guidance.
Docker / Containerization
wbox init generates a multi-stage docker/Dockerfile (Go build stage + minimal Alpine runtime, non-root user, /datastore volume mountpoint). Adapt the template to your project: Go version to match go.mod, EXPOSE port to match config.toml, CGO_ENABLED when using sqlite_connector, and a config copy if the app needs config.toml at startup. Pair it with a .dockerignore to keep the build context small.
Full template, adaptation table, .dockerignore, and build/run commands: references/docker.md.
Multi-Instance Deployment
Production deployments run multiple replicas of the same binary. Design for this from day one: one binary, one module list, and configuration (not code) selects single-instance dev backends vs multi-instance production backends. Full decision table: root skill § Design for Multi-Instance Deployment by Default.
Recommended pattern: PostgreSQL everywhere, config-only switching
The lowest-friction setup uses PostgreSQL in every environment (run it via Docker locally). Dev → production is then pure configuration — modules.go never changes:
// modules.go — identical in dev and production
func loadModules() ([]fx.Option, error) {
return []fx.Option{
postgres_connector.Module("database"),
scheduler.Module("scheduler"), // mode from config: gorm (dev) / postgres (prod)
postgres_workqueue.Module("workqueue"), // multi-process safe in every environment
// ... business modules ...
}, nil
}# config.toml — development defaults (single local process)
[scheduler]
mode = "gorm"# Production — environment variables override config.toml
export MYAPP_SCHEDULER_MODE=postgres # claim-based multi-instance scheduling
export MYAPP_DATABASE_HOST=db.internal
export MYAPP_DATABASE_PASSWORD=secretscheduler postgres mode shares gorm mode's tables, so the switch requires no data migration.
SQLite-based development
If local development must be dependency-free, use SQLite in dev — the swap stays confined to modules.go because application code injects interfaces (database.DatabaseConnector, workqueue.WorkQueue) only:
| Development | Production | |
| Database | sqlite_connector.Module("database") | postgres_connector.Module("database") |
| Workqueue | gorm_workqueue.Module("workqueue") | postgres_workqueue.Module("workqueue") (same table layout — no data migration) |
| Scheduler | mode = "gorm" | mode = "postgres" or "nats" |
NATS-based stacks
Run the embedded JetStream server in development and point at an external NATS cluster in production — config only:
# config.toml — development
[nats_server]
enabled = true # embedded NATS JetStream server (preload phase)
[nats]
host = "nats://localhost:4222"# Production
export MYAPP_NATS_SERVER_ENABLED=false
export MYAPP_NATS_HOST=nats://nats.internal:4222
export MYAPP_SCHEDULER_MODE=natsMulti-instance production rules
- Replicas > 1 →
schedulermode MUST bepostgresornats, nevergorm(every replica would fire every job) - Replicas > 1 → workqueue backend MUST be
gorm_workqueue,postgres_workqueue, ornats_workqueue, nevermemory_workqueue - The embedded
nats_jetstream_serveris for development and single-node use — production uses an external NATS cluster - SQLite is a local file, single-node by nature — use
postgres_connectorwhen scaling out - Cross-instance shared state (cache, locks, counters) goes in the database,
redis_connector, or NATS — never process memory - Custom modules must follow module-dev § Multi-Instance Safety
License Selection
When creating a new project, choose an appropriate license. The default is Apache License 2.0.
Available License Options
| License | Type | Use Case |
| Apache-2.0 (Default) | Open Source | Open source projects, allows commercial use with attribution |
| MIT | Open Source | Simple permissive license, minimal restrictions |
| Proprietary | Closed Source | Commercial/private projects, all rights reserved |
Create the LICENSE file from the matching template in references/licenses.md. Also add the per-file source header from the same reference.
Common Modules from weedbox/common-modules
| Module | Import | Phase | Purpose |
logger | logger.Module() | preload | Zap structured logging |
daemon | daemon.Module("scope") | after | Application lifecycle |
http_server | http_server.Module("scope") | load | Gin HTTP server |
sqlite_connector | sqlite_connector.Module("scope") | load | SQLite database |
nats_connector | nats_connector.Module("scope") | load | NATS messaging |
User Modules from weedbox/user-modules
| Module | Import | Phase | Purpose |
user | user.Module("user") | load | User management (CRUD, bcrypt, UUID v7) |
rbac | rbac.Module("rbac") | load | Role-based access control |
auth | auth.Module("auth") | load | JWT authentication and middleware |
user_apis | user_apis.Module("user_apis") | load | User REST API endpoints |
auth_apis | auth_apis.Module("auth_apis") | load | Auth REST API endpoints |
role_apis | role_apis.Module("role_apis") | load | Role/resource REST API endpoints |
http_token_validator | http_token_validator.Module("scope") | load | Global JWT validation (optional) |
See user-modules skill for detailed documentation.
Running the Application
# Run with default config (reads config.toml automatically)
go run .
# Print all configurations
go run . --print_configs
# Verbose mode (shows fx dependency injection logs)
go run . --verbose
# Build and run
go build -o myapp .
./myapp
./myapp --print_configs
./myapp --verboseNote: The config file path is not configurable via command-line flags. Place your config.toml in the current directory or ./configs/ directory.
Project Checklist
- Install wbox:
go install github.com/weedbox/wbox@latest(or usego run github.com/weedbox/wbox@latest init ...to skip the install) - Initialize project:
wbox init <name> <module-path> - Choose license: Apache-2.0 (default), MIT, or Proprietary
- Create
LICENSEfile with chosen license - Create configuration file (
config.toml, notconfigs.toml) - Implement application modules in
pkg/ - Design for multi-instance: pick production backends per the multi-instance table (scheduler mode
postgres/nats, durable workqueue backend, external NATS) and keep dev/production switching config-driven - Verify
docker/Dockerfilewas generated (if hand-crafted, copy the template from references/docker.md) - Add a
.dockerignoreto keep the build context small - Adapt the Dockerfile: Go version,
EXPOSEport,CGO_ENABLED, config copy,<PREFIX>_DATABASE_PATH - Add license headers to source files (for open source projects)
Related
- module-dev - Detailed module development guide
- user-modules - User management, auth, and RBAC modules
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

