npx skills add https://github.com/replicas-group/skill --skill replicas-agent你是一个在 Replicas 云工作空间(远程虚拟机)内运行的后台编码代理。本指南涵盖此环境特有的功能和最佳实践。
当你在端口上运行服务时——例如 Web 应用、API 服务器或数据库——人类用户可能希望直接与之交互。你可以将本地运行的服务暴露为公共预览 URL。
服务必须作为分离的后台进程运行,以便在你的命令会话结束后它们仍然存活。不要将它们附加到前台终端。
一些可能的方法:
# 启动一个带日志记录的分离服务
setsid -f bash -lc 'cd /path/to/app && exec yarn dev >> /tmp/app.log 2>&1'
# 对于像 Docker 这样的守护进程
nohup dockerd > /tmp/dockerd.log 2>&1 &
启动服务后:
pgrep -af 'yarn dev'tail -f /tmp/app.logcurl -s http://localhost:3000(或适当的健康检查)如果同一端口上存在先前的分离进程,请在重启前停止它。
# 将本地端口暴露为公共 URL
replicas preview create <端口号>
# 列出所有活动的预览 URL
replicas preview list
create 命令会打印出公共 URL。你也可以从 读取所有活动的预览。
You are a background coding agent running inside a Replicas cloud workspace (a remote VM). This guide covers capabilities and best practices specific to this environment.
When you run services on ports — such as a web app, API server, or database — humans may want to interact with them directly. You can expose your locally running services as public preview URLs.
Services must run as detached background processes so they survive after your command session ends. Do not leave them attached to a foreground terminal.
Some potential methods:
# Start a detached service with logging
setsid -f bash -lc 'cd /path/to/app && exec yarn dev >> /tmp/app.log 2>&1'
# For daemons like Docker
nohup dockerd > /tmp/dockerd.log 2>&1 &
After starting a service:
pgrep -af 'yarn dev'tail -f /tmp/app.logcurl -s http://localhost:3000 (or appropriate health check)广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
~/.replicas/preview-ports.json当你暴露多个相互引用的服务时,必须更新它们的配置,使其使用预览 URL 而不是 localhost。
示例: 你在端口 3000 上运行一个 React 前端,它向端口 8585 上的后端发起 API 调用。
为两者创建预览:
replicas preview create 8585
# 输出:https://8585-<沙盒ID>.replicas.dev
replicas preview create 3000
# 输出:https://3000-<沙盒ID>.replicas.dev
更新前端的配置环境,使其 API 基础 URL 指向后端的预览 URL,而不是 localhost:8585。例如,设置 REACT_APP_API_URL=https://8585-<sandbox-id>.replicas.dev 或更新相关的配置文件。
为什么? 前端在 localhost 上对你有效,因为两个服务运行在同一台机器上。但查看预览的人类用户位于不同的机器上——从他们的浏览器向 localhost:8585 发出的请求将会失败。他们需要的是公共预览 URL。
你的责任是确保预览对外部用户的效果与在本地 localhost 上对你一样好。如果你在任何时候需要查看已创建的公共 URL,请读取 ~/.replicas/preview-ports.json。
每周安装次数
654
仓库
首次出现
8 天前
安全审计
已安装于
cline654
gemini-cli654
claude-code654
github-copilot654
codex654
kimi-cli654
If a prior detached process exists on the same port, stop it before restarting.
# Expose a local port as a public URL
replicas preview create <port>
# List all active preview URLs
replicas preview list
The create command prints the public URL. You can also read all active previews from ~/.replicas/preview-ports.json.
When you expose multiple services that reference each other, you must update their configuration so they use preview URLs instead of localhost.
Example: You run a React frontend on port 3000 that makes API calls to a backend on port 8585.
Create previews for both:
replicas preview create 8585
# Output: https://8585-<sandbox-id>.replicas.dev
replicas preview create 3000
# Output: https://3000-<sandbox-id>.replicas.dev
Update the frontend's environment so its API base URL points to the backend's preview URL , not localhost:8585. For example, set REACT_APP_API_URL=https://8585-<sandbox-id>.replicas.dev or update the relevant config file.
Why? The frontend works on localhost for you because both services run on the same machine. But a human viewing the preview is on a different machine — requests to localhost:8585 from their browser will fail. They need the public preview URL instead.
It is your responsibility to make previews work for outsiders as well as they work for you on localhost. If at any time you need to see the public URLs that have been created, read ~/.replicas/preview-ports.json.
Weekly Installs
654
Repository
First Seen
8 days ago
Security Audits
Installed on
cline654
gemini-cli654
claude-code654
github-copilot654
codex654
kimi-cli654
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
106,200 周安装