Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
lovstudio avatar

Lovstudio:Project Port

  • 1 installs
  • Updated July 13, 2026
  • lovstudio/project-port-skill

Generates a stable unique dev-server port (3000-8999) from a project name and updates the project's port configuration.

About

Generates a stable unique dev port from a project name so the same project always maps to the same port, and updates the project's port config. A developer uses it to avoid port collisions across multiple local projects.

  • Hashes the project name to a stable port in 3000-8999
  • Updates .env, package.json, or vite.config port config with minimal changes

Lovstudio:Project Port by the numbers

  • 1 all-time installs (skills.sh)
  • Ranked #1,983 of 2,715 Automation & Workflows skills by installs in the Skillselion catalog
  • Data as of Jul 14, 2026 (Skillselion catalog sync)
npx skills add https://github.com/lovstudio/project-port-skill --skill lovstudioproject-port

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1
Last updatedJuly 13, 2026
Repositorylovstudio/project-port-skill

What it does

Generates a stable unique dev-server port (3000-8999) from a project name and updates the project's port configuration.

Files

SKILL.mdMarkdownGitHub ↗

Project Port Generator

为项目生成稳定唯一的端口号(范围 3000-8999),同一项目名永远返回相同端口。

端口生成算法

def generate_port(project_name: str) -> int:
    hash_value = sum(ord(c) * (i + 1) for i, c in enumerate(project_name))
    return 3000 + (hash_value % 6000)

使用场景

1. 查询项目端口

用户询问端口时,直接计算并告知:

项目 "lovstudio" 的端口号是:7965

2. 更新项目配置

检测并更新项目中的端口配置文件:

文件配置方式
.env / .env.localPORT=<port>
package.jsonscripts 中的 --port <port>
vite.config.tsserver.port: <port>
next.config.js通常使用 .env

更新时优先使用 .env 方式,最小侵入性。

3. 启动开发服务器

PORT=$(scripts/hashport.sh) pnpm dev

脚本

运行 scripts/hashport.sh [project-name] 生成端口:

# 使用当前目录名
./scripts/hashport.sh
# 输出: 7965

# 指定项目名
./scripts/hashport.sh my-project
# 输出: 5123

端口冲突处理

若端口被占用: 1. 提示用户哪个进程占用了端口 2. 建议使用 lsof -i :<port> 查看 3. 可追加后缀生成备用端口:generate_port("project-dev")

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.