mcp-cli-bridge: Skill for Claude Code

.trae/skills/file-access-control/SKILL.md

file-access-control is a skill for Claude Code, Codex from liuqihonggit/mcp-cli-bridge. It costs 45 tokens per session (2,819 once invoked), scanned A, original, MIT.

A file-locking procedure for agents that read or write files. It uses a C# script lock with a five-second acquisition timeout and automatic expiry after 30 seconds.

In plain words
What is it for?
Use it when agent operations may read or write shared files and need the required locking workflow.
Why use it?
It helps prevent two operations from accessing the same file at once, which can cause race conditions or lost changes. The lock is acquired before file access and released afterward.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

This is liuqihonggit/mcp-cli-bridge's own configuration. It tells Claude Code and Codex how to work on mcp-cli-bridge itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything mcp-cli-bridge configures →

Reuse

Borrowing it

Nothing to install: this file belongs to liuqihonggit/mcp-cli-bridge. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/liuqihonggit/mcp-cli-bridge/main/.trae/skills/file-access-control/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/liuqihonggit/mcp-cli-bridge

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for file-access-control

README.md
[![agentmods](https://agentmods.dev/badge/skills/liuqihonggit/mcp-cli-bridge/file-access-control/github.svg)](https://agentmods.dev/skills/liuqihonggit/mcp-cli-bridge/file-access-control)
Your own site
<a href="https://agentmods.dev/skills/liuqihonggit/mcp-cli-bridge/file-access-control"><img src="https://agentmods.dev/badge/skills/liuqihonggit/mcp-cli-bridge/file-access-control/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for file-access-control

Your own site · 80×15
<a href="https://agentmods.dev/skills/liuqihonggit/mcp-cli-bridge/file-access-control"><img src="https://agentmods.dev/badge/skills/liuqihonggit/mcp-cli-bridge/file-access-control.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 45 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,819 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00045 $0.02819
Opus 5.5 $0.00018 $0.01128
Sonnet 5.5 $0.00009 $0.00564
Haiku 4.5 $0.00005 $0.00282

Measured 2mo ago against content hash 1685195d261b, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

file-access-control scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.trae/skills/file-access-control/SKILL.md · 411 lines

How it starts

The opening of the file, as written. The whole thing — 411 lines — stays where its author put it; the contents beside it link to each section on GitHub.

File Access Control

This skill enforces mandatory file locking before any file access operations to prevent race conditions and ensure data integrity.

Workflow

访问文件前
    ↓
检查 .csx 锁脚本是否存在?
    ↓ 否
创建锁脚本 (子智能体)
    ↓
调用 .csx 脚本获取文件锁
    ↓
5秒内获取成功?
    ↓ 否                    ↓ 是
委派子智能体做其他事情    执行文件操作
                          ↓
                          释放锁

命名规范

锁脚本名称

常量 值 说明
LockScript.FileName FileAccessGuard.csx 文件访问守卫脚本
LockScript.Directory .trae/skills/file-access-control/ 脚本存放目录

Rules

1. 锁脚本检查与创建

访问任何文件前,必须先检查锁脚本是否存在:

// 使用 nameof 和 typeof 避免硬编码
public static class LockScript
{
    public const string FileName = nameof(FileAccessGuard) + ".csx";
    public const string Directory = ".trae/skills/file-access-control/";
    public static readonly string FullPath = Path.Combine(Directory, FileName);
}

// 检查脚本是否存在
if (!File.Exists(LockScript.FullPath))
{
    // 委派子智能体创建锁脚本 FileAccessGuard.csx
    // 不要自己创建,让子智能体来做
}

2. 调用锁脚本获取锁

# 使用 dotnet-script 运行 .csx 脚本
dotnet script .trae\skills\file-access-control\FileAccessGuard.csx -- "C:\path\to\file.txt" acquire

3. 锁脚本标准接口

锁脚本必须支持以下命令:

命令 功能 返回值
acquire <filepath> 获取文件锁 SUCCESS / TIMEOUT / ERROR
release <filepath> 释放文件锁 SUCCESS / ERROR
status <filepath> 检查锁状态 LOCKED:<pid> / FREE / EXPIRED

锁脚本实现 (FileAccessGuard.csx)

#!/usr/bin/env dotnet-script
#r "System.IO.FileSystem"

using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

// 配置
const int ACQUISITION_TIMEOUT_SECONDS = 5;  // 5秒抢不到就放弃
const int LOCK_EXPIRY_SECONDS = 30;         // 锁30秒自动过期
const int RETRY_INTERVAL_MS = 100;          // 重试间隔100毫秒

// 命令行参数解析
if (Args.Count < 2)
{
    Console.WriteLine("ERROR: Usage: dotnet script FileLock.csx -- <command> <filepath>");
    Console.WriteLine("Commands: acquire, release, status");
    Environment.Exit(1);
}

string command = Args[0].ToLower();
string targetFilePath = Args[1];
string lockFilePath = $"{targetFilePath}.scx.lock";

switch (command)
{
    case "acquire":
        Environment.Exit(await AcquireLockAsync() ? 0 : 1);
        break;
    case "release":
        Environment.Exit(ReleaseLock() ? 0 : 1);
        break;
    case "status":
        Console.WriteLine(GetLockStatus());
        Environment.Exit(0);
        break;
    default:
        Console.WriteLine($"ERROR: Unknown command '{command}'");
        Environment.Exit(1);
        break;
}

// 获取锁
async Task<bool> AcquireLockAsync()
{
    var startTime = DateTime.UtcNow;

    while ((DateTime.UtcNow - startTime).TotalSeconds < ACQUISITION_TIMEOUT_SECONDS)
    {
        // 清理过期锁
        await TryRemoveExpiredLockAsync();

        try
        {
            // 尝试独占创建锁文件
            using var fs = new FileStream(
                lockFilePath,
                FileMode.CreateNew,
                FileAccess.Write,
                FileShare.None,
                bufferSize: 4096,
                useAsync: true);

            using var writer = new StreamWriter(fs);
            await writer.WriteLineAsync($"PID:{Environment.ProcessId}");
            await writer.WriteLineAsync($"Time:{DateTime.UtcNow:yyyy-MM-dd HH:mm:ss}");
            await writer.WriteLineAsync($"ExpirySeconds:{LOCK_EXPIRY_SECONDS}");
            await writer.FlushAsync();

            Console.WriteLine("SUCCESS");
            return true;
        }
        catch (IOException)
        {
            // 锁被占用,等待重试
            await Task.Delay(RETRY_INTERVAL_MS);
        }
    }

    // 5秒超时
    Console.WriteLine("TIMEOUT");
    return false;
}

// 释放锁
bool ReleaseLock()
{
    try
    {
        if (File.Exists(lockFilePath))
        {
            File.Delete(lockFilePath);
            Console.WriteLine("SUCCESS");
            return true;
        }
        Console.WriteLine("SUCCESS: Lock not found");
        return true;
    }
    catch (Exception ex)
    {
        Console.WriteLine($"ERROR: {ex.Message}");
        return false;
    }
}

// 获取锁状态
string GetLockStatus()
{
    if (!File.Exists(lockFilePath))
        return "FREE";

    try
    {
        var lines = File.ReadAllLines(lockFilePath);
        DateTime? lockTime = null;
        double expirySeconds = LOCK_EXPIRY_SECONDS;
        string? pid = null;

        foreach (var line in lines)
        {
            if (line.StartsWith("PID:"))
                pid = line[4..].Trim();
            if (line.StartsWith("Time:") && DateTime.TryParse(line[5..].Trim(), out var lt))
                lockTime = lt.ToUniversalTime();
            if (line.StartsWith("ExpirySeconds:") && double.TryParse(line[14..].Trim(), out var exp))
                expirySeconds = exp;
        }

        // 检查是否过期
        if (lockTime.HasValue && (DateTime.UtcNow - lockTime.Value).TotalSeconds > expirySeconds)
            return "EXPIRED";

        return pid != null ? $"LOCKED:{pid}" : "LOCKED:UNKNOWN";
    }
    catch
    {
        return "ERROR";
    }
}

// 清理过期锁
async Task TryRemoveExpiredLockAsync()
{
    if (!File.Exists(lockFilePath))
        return;

    try
    {
        var lines = await File.ReadAllLinesAsync(lockFilePath);
        DateTime? lockTime = null;
        double expirySeconds = LOCK_EXPIRY_SECONDS;

        foreach (var line in lines)
        {
            if (line.StartsWith("Time:") && DateTime.TryParse(line[5..].Trim(), out var lt))
                lockTime = lt.ToUniversalTime();
            if (line.StartsWith("ExpirySeconds:") && double.TryParse(line[14..].Trim(), out var exp))
                expirySeconds = exp;
        }

        if (lockTime.HasValue && (DateTime.UtcNow - lockTime.Value).TotalSeconds > expirySeconds)
        {
            File.Delete(lockFilePath);
        }
    }
    catch { /* 忽略清理错误 */ }
}

Read the full file on GitHub · 411 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 411 lines · 45 tokens per session scan A 1685195d261b

Subscribe to this mod's changes

file-access-control is a skill published in the GitHub repository liuqihonggit/mcp-cli-bridge (0 stars, last pushed 5mo ago), licensed MIT. It adds 45 tokens to every session and 2,819 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

file-access-control compared with skills from other repositories

file-access-control next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
file-access-controlliuqihonggit/mcp-cli-bridgeSkill05mo agoMITA45Claude Code, Codex
imagegenopenai/codexSkill133kyesterdayApache-2.0A113Codex
playwright-climicrosoft/playwrightSkill99kyesterdayApache-2.0A19Claude Code
local-ai-agentsmicrosoft/ai-agents-for-beginnersSkill79k4d agoMITA200Claude Code, Codex
systematic-debuggingobra/superpowersSkill313k3d agoMITA21Claude Code
next-cache-components-adoptionvercel/next.jsSkill143kyesterdayMITA95Claude Code
next-partial-prefetching-adoptionvercel/next.jsSkill143kyesterdayMITA103Claude Code