abczsl520

Node.js Project Architecture

开发编程v1.1.0
作者:abczsl520更新于 2026-05-18共 2 个版本 · 最新版本发布于 2026-03-06nodejs-project-arch@clawhub_abczsl520/nodejs-project-arch
代码生成脚本工具#Sdk

据 AlphaMoat 统计,截至 2026-09,Node.js Project Architecture 累计下载 1,729 次、获 0 个星标,在全部 5,078 个 AI 技能中排名第 4,627 位,在「开发编程」分类(577 个)中排名第 546 位。

累计安装
304
累计下载
1,729
星标
-
全站排名
#4,627
全站前 92% · 「开发编程」前 95%
平台累计安装累计下载星标评论
ClawHub ↗401,729--
SkillHub ↗3041,692-—

各平台的计数口径不同,统计时间不一致。

这个技能是做什么的

拆分路由、共享服务、数据库访问和前端资源,提供运行配置与管理编辑模式,示例涵盖游戏、工具和库。共享配置不含秘密,只公开白名单值,并在生产采用前校验已认证管理变更。

资料发布于 2026-10-27

可以用来做什么

  • 重构大型 Node.js 项目

什么时候用

  • 模块与配置需要清楚边界时

示例提示词

以下是根据技能文档生成的示例,不代表实际运行结果。

提出模块布局,审查公开配置和秘密的划分。

月度数据趋势

累计下载1,729
5591,1881,8162026-03 · 累计下载 6462026-05 · 累计下载 8862026-06 · 累计下载 1,0572026-07 · 累计下载 1,2942026-08 · 累计下载 1,5422026-09 · 累计下载 1,72926-0326-09
星标-
0112026-03 · 星标 -2026-05 · 星标 -2026-06 · 星标 -2026-07 · 星标 -2026-08 · 星标 -2026-09 · 星标 -26-0326-09

2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。

月份累计下载环比星标
2026-091,729—-
2026-081,542+19.2%-
2026-071,294+22.4%-
2026-061,057+19.3%-
2026-05886—-
2026-03646—-

SKILL.md 原文

以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。

3.4 KB · ClawHub v1.1.0
---
name: nodejs-project-arch
description: Node.js project architecture standards for AI-assisted development. Enforces file splitting (<400 lines), config externalization, route modularization, and admin dashboards. Use when creating new Node.js projects, refactoring large single-file codebases, or when AI context window is being consumed by oversized files. Covers H5 games (Canvas/Phaser/Matter.js), data tools (crawlers/scrapers), content platforms, monitoring dashboards, API services, and SDK libraries.
---

# Node.js Project Architecture for AI-Friendly Development

Architecture standards that keep files small enough for AI agents to read/edit without blowing the context window.

## Core Rules
展开全部(共 76 行)

- Single file max **400 lines**, `index.html` max **200 lines**, `server.js` entry max **100 lines**
- All tunable values in `config.json`, loaded at runtime, editable via admin dashboard
- Backend: `routes/` by domain, `services/` for shared logic, `db.js` for database
- Frontend: HTML skeleton only, JS/CSS in separate files
- Every project gets `admin.html` + `routes/admin.js` for config hot-reload

## Project Type Selection

Determine project type, then read the corresponding reference:

| Type | Signals | Reference |
|------|---------|-----------|
| **H5 Game** | Canvas, Phaser, Matter.js, game loop, sprites | [references/game.md](references/game.md) |
| **Data Tool** | Crawler, scraper, scheduler, data sync, analytics | [references/tool.md](references/tool.md) |
| **Content/Utility** | Generator, library, publisher, file processing | [references/tool.md](references/tool.md) |
| **Dashboard/Monitor** | Charts, real-time, alerts, metrics | [references/tool.md](references/tool.md) |
| **API Service** | REST endpoints, middleware, microservice | [references/tool.md](references/tool.md) |
| **SDK/Library** | Shared module, build step, multi-consumer | [references/sdk.md](references/sdk.md) |

## Quick Start (All Types)

1. Identify project type from table above
2. Read the corresponding reference file
3. Create directory structure per the reference
4. Extract hardcoded values → `config.json`
5. Split large files by function (each <400 lines)
6. Add `routes/admin.js` + `admin.html`
7. Frontend: `config.js` fetches `/api/config` at startup, code reads `GAME_CONFIG.xxx` or `APP_CONFIG.xxx`
8. Test locally → backup → deploy

## config.json Pattern (Universal)

```javascript
// Server: load and serve config
const config = JSON.parse(fs.readFileSync('./config.json', 'utf8'));
app.get('/api/config', (req, res) => {
  const safe = { ...config };
  delete safe.admin; // strip secrets
  res.json(safe);
});

// Admin: hot-reload
app.post('/admin/config', requireAdmin, (req, res) => {
  fs.writeFileSync('./config.json.bak', fs.readFileSync('./config.json'));
  fs.writeFileSync('./config.json', JSON.stringify(req.body, null, 2));
  Object.assign(config, req.body);
  res.json({ ok: true });
});
```

## Admin Dashboard Pattern (Universal)

`admin.html` auto-generates form from config structure:
- Password login (`x-admin-password` header)
- Visual config editor with save + hot-reload
- Stats overview (users/data/uptime)
- Config backup history + restore

## Why This Matters

Large single files consume massive context tokens when AI reads them:
- 3000-line file → ~40K tokens per read (20% of 200K window)
- 200-line module → ~2.7K tokens per read (1.3% of window)
- **Result: 10-15 productive rounds vs 3-5 before context compression**

「开发编程」分类下的热门技能

数据月份:2026-09 · 下载/星标/安装数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。