Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计异常

port-allocator端口分配器

Agent Skill

port-allocator 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

353

周安装

15

GitHub Stars

236

下载量

124
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:port-allocator(端口分配器)
来源仓库:https://github.com/guo-yu/skills
仓库路径:skills/port-allocator
安装命令:
npx skills add https://github.com/guo-yu/skills --skill port-allocator
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/guo-yu/skills --skill port-allocator

简介

port-allocator 用于查找、检索和筛选相关信息,适合根据关键词或任务场景快速定位候选结果。

  • 它能帮助 Agent 组织信息线索或缩小搜索范围,使用时需明确查询目标和筛选条件。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装,需结合原始 README 确认具体用法。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Port Allocator

Smart port allocator that only assigns ports to real projects containing package.json.

Usage

CommandDescription
/port-allocatorAllocate/query port for current project
/port-allocator listList all allocated ports
/port-allocator scanScan code directory, discover and allocate ports for new projects
/port-allocator config <path>Set the main code directory path
/port-allocator add <dir-path>Manually add port allocation for a project
/port-allocator allowConfigure Claude Code permissions for this skill's commands

Important Rules

1. Only Operate on Current Project's Ports When Restarting Services

When restarting the development server, only kill processes within the current project's port range, never affect other ports:

# Correct: Only kill current project ports (e.g., 3000-3009)
lsof -ti:3000 | xargs kill -9 2>/dev/null
lsof -ti:3001 | xargs kill -9 2>/dev/null

# Wrong: Kill all node processes or other ports
pkill -f node  # Will affect other projects!
lsof -ti:3010 | xargs kill  # This is another project's port!

2. Append Rather Than Overwrite When Updating CLAUDE.md

When updating ~/.claude/CLAUDE.md, must preserve the user's existing content:

# Correct: Check and append or update specific sections
# Wrong: Directly overwrite the entire file

Execution Steps

Command: /port-allocator allow

Configure Claude Code to allow commands used by this skill, avoiding manual confirmation each time:

  1. Read ~/.claude/settings.json (if exists)
  2. Merge the following commands into permissions.allow array (preserve existing config):
{
  "permissions": {
    "allow": [
      "Bash(ls -d *)",
      "Bash(find * -maxdepth * -name package.json *)",
      "Bash(cat ~/.claude/*)",
      "Bash(dirname *)",
      "Bash(lsof -i:3*)",
      "Bash(lsof -ti:3*)"
    ]
  }
}
  1. Write updated settings.json
  2. Output the list of added permissions

Output Format:

Configured Claude Code permissions

Added allowed command patterns:
  - Bash(ls -d *)
  - Bash(find * -maxdepth * -name package.json *)
  - Bash(cat ~/.claude/*)
  - Bash(lsof -i:3*)
  - Bash(lsof -ti:3*)

Config file: ~/.claude/settings.json

Command: /port-allocator config <path>

Set the user's main code directory:

  1. Verify path exists (required! Error and exit if not found)
  2. Update code_root field in ~/.claude/port-registry.json
  3. Output confirmation

First Run: Auto-Detection

On first run (when ~/.claude/port-registry.json doesn't exist or has no code_root), automatically detect the code directory:

# Check common code directories
for dir in ~/Codes ~/Code ~/Projects ~/Dev ~/Development ~/repos; do
  if [ -d "$dir" ]; then
    CODE_ROOT="$dir"
    break
  fi
done

# If none exist, default to ~/Codes
CODE_ROOT="${CODE_ROOT:-~/Codes}"

Auto-detection output:

First run, detecting code directory...

Code directory detected: ~/Codes

Port registry initialized: ~/.claude/port-registry.json

To change, use:
   /port-allocator config ~/your/code/path

If no directory found:

Could not auto-detect code directory.

Please configure manually:
   /port-allocator config ~/your/code/path

Common locations:
   ~/Codes, ~/Code, ~/Projects, ~/Dev

Command: /port-allocator scan

Scan code directory, automatically discover and register projects:

  1. Read ~/.claude/port-registry.json to get code_root

- If config doesn't exist, run auto-detection first - If code_root directory doesn't exist, prompt user to configure

  1. Find all directories containing package.json (exact to package.json location):
# Find all package.json, exclude build artifact directories
find <code_root> -maxdepth 3 -name "package.json" -type f \
  -not -path "*/.next/*" \
  -not -path "*/node_modules/*" \
  -not -path "*/dist/*" \
  -not -path "*/build/*" | while read pkg; do
  dirname "$pkg"
done
  1. Important: Path must be exact to the directory containing package.json

- Correct: ~/Codes/chekusu/landing - Wrong: ~/Codes/chekusu (if package.json is in subdirectory)

  1. For each discovered project directory:

- Check if already in registry - If not, allocate next available port range

  1. Update config file (append mode, don't overwrite user content)
  2. Output scan result summary

Command: /port-allocator (default)

Allocate/query port for current project:

  1. Get current working directory
  2. Read config to get code_root and allocated ports
  3. Match current directory to corresponding project
  4. If no package.json, indicate this is not a project needing ports
  5. If exists, check if port already allocated, auto-allocate if not
  6. Output port info

Command: /port-allocator list

List all allocated ports (read-only operation).

Output Format

Port Information

Project directory: ~/Codes/chekusu/landing
package.json: Detected
Port range: 3000-3009
   - Main app: 3000
   - API: 3001
   - Other services: 3002-3009

Warning: Only operate on ports 3000-3009 when restarting services!

Scan Results

Scan complete: ~/Codes

Registered projects (N):
   - chekusu/landing: 3000-3009
   - saifuri: 3010-3019

Newly discovered projects (M):
   - new-project: 3090-3099 (newly allocated)

Skipped (K):
   - .next, node_modules (build artifacts)
   - research-folder (no package.json)

Port Allocation Rules

  • Each project is allocated 10 consecutive ports
  • Starting port: 3000
  • Interval: 10
  • x0: Main application (e.g., 3000, 3010, 3020)
  • x1: API service (e.g., 3001, 3011, 3021)
  • x2-x9: Other services (database, cache, etc.)

Configuration Files

  • Port registry: ~/.claude/port-registry.json
  • Global instructions: ~/.claude/CLAUDE.md (append mode updates)
  • Claude Code settings: ~/.claude/settings.json (stores allowedCommands)
  • Skip patterns: .next, node_modules, dist, build

Notes

  1. Only operate on project ports - Never affect other projects when restarting services
  2. Append not overwrite - Preserve user's existing content when updating config files
  3. Precise paths - Point to actual directory containing package.json
  4. Skip build artifacts -.next, node_modules, etc. don't get port allocation
  5. First use - Recommend running /port-allocator allow to configure permissions first

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

30.07%
按下载量换算37

OpenCode

21.25%
按下载量换算26

Antigravity

16.16%
按下载量换算20

Codex

11.52%
按下载量换算14

Gemini CLI

8.45%
按下载量换算10

Cursor

3.55%
按下载量换算4

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills