[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6NTK2J4RSQ8PGJN2FXMMZKM":3,"skill-same:01M6NTK2J4RSQ8PGJN2FXMMZKM":86},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":25,"publishedAt":46,"linkOnly":47,"markdownContent":48,"markdownBody":49,"frontMatter":50,"refName":41,"commitSha":61,"skillDirectory":62,"forksCount":13,"repositoryHtmlUrl":63,"repositoryHomepageUrl":6,"ownerHtmlUrl":64,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":65,"install":66,"resources":79},"01M6NTK2J4RSQ8PGJN2FXMMZKM","ai-coding-agent-guardrails",null,"Secure AI coding agents (Claude Code, Cursor, Codex, Copilot) with permission boundaries, secret protection, code review gates, and safe sandbox configurations for team environments.","duc-duy-1612\u002FOnline-Delivery-Systems-Web","duc-duy-1612","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F192231384?v=4","01M6NSDKQQDKVTHZ8DZMZ1VYY6","01M6NSDKW8DDVTQHBT1HBDDJPT",0,"MIT","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fai-coding-agent-guardrails\u002FSKILL.md",[17,22],{"categoryNo":18,"categoryName":19,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000007","代码审查","SCENARIO","使用场景",{"categoryNo":23,"categoryName":24,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000023","Skill与智能体开发",[26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45],"coding","ai coding agent","ai coding agent guardrails","ai coding","Guardrails","coding agent","assessment","code","ai coding agents","devops-security","team","code review","only","copilot","community","main","active","scope","relevant","review","2026-11-10 10:12:30",false,"---\nname: ai-coding-agent-guardrails\ndescription: Secure AI coding agents (Claude Code, Cursor, Codex, Copilot) with permission\n  boundaries, secret protection, code review gates, and safe sandbox configurations\n  for team environments.\ncategory: security\nrisk: safe\nsource: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\nsource_repo: BagelHole\u002FDevOps-Security-Agent-Skills\nsource_type: community\ndate_added: '2026-09-20'\nlicense: MIT\nlicense_source: https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE\ncompatibility: Requires the relevant security tooling (scanners, vault CLIs) and an\n  authorized scope for any active assessment. Docs-only; helper scripts and templates\n  not bundled.\nmetadata:\n  author: devops-skills\n  version: '1.0'\n---\n\n# AI Coding Agent Guardrails\n\nSecure the use of AI coding agents across engineering teams. This skill covers permission boundaries, secret protection, sandbox isolation, code review gates, and audit trails for Claude Code, Cursor, Copilot, and Codex.\n\n---\n\n## Permission Boundaries\n\n### CLAUDE.md Configuration\n\nCreate a `CLAUDE.md` at the repository root to restrict Claude Code behavior:\n\n```markdown\n# CLAUDE.md\n\n## Restrictions\n\n- NEVER read or output contents of .env, .env.*, secrets.yaml, or any file matching *.pem, *.key\n- NEVER execute `rm -rf`, `DROP TABLE`, `kubectl delete`, or `terraform destroy` commands\n- NEVER push directly to main or master branches\n- NEVER modify files in the infrastructure\u002F, terraform\u002F, or .github\u002Fworkflows\u002F directories without explicit user approval\n- NEVER install new dependencies without listing them first for review\n- NEVER access or display API keys, tokens, passwords, or connection strings\n\n## Allowed Operations\n\n- Read and modify application source code in src\u002F, lib\u002F, and tests\u002F\n- Run test suites with `npm test`, `pytest`, `go test`\n- Run linters with `eslint`, `ruff`, `golangci-lint`\n- Create new branches with prefix `ai\u002F` or `agent\u002F`\n- Create and modify files in docs\u002F directory\n\n## Code Standards\n\n- All new functions must include docstrings or JSDoc comments\n- All new code must have corresponding unit tests\n- Follow existing code style and patterns in the repository\n- Maximum file length: 500 lines. Suggest splitting if exceeded.\n```\n\n### Command Allowlists\n\nFor agents that execute shell commands, define an explicit allowlist:\n\n```yaml\n# .agent-permissions.yaml\nagent_permissions:\n  allowed_commands:\n    - \"npm test\"\n    - \"npm run lint\"\n    - \"npm run build\"\n    - \"pytest\"\n    - \"ruff check\"\n    - \"go test .\u002F...\"\n    - \"git status\"\n    - \"git diff\"\n    - \"git log\"\n    - \"git checkout -b\"\n    - \"git add\"\n    - \"git commit\"\n    - \"ls\"\n    - \"cat\"\n    - \"head\"\n    - \"tail\"\n\n  blocked_commands:\n    - \"rm -rf\"\n    - \"curl\"\n    - \"wget\"\n    - \"ssh\"\n    - \"scp\"\n    - \"kubectl\"\n    - \"terraform\"\n    - \"aws\"\n    - \"gcloud\"\n    - \"az\"\n    - \"docker push\"\n    - \"npm publish\"\n\n  blocked_paths:\n    - \".env*\"\n    - \"**\u002F*.pem\"\n    - \"**\u002F*.key\"\n    - \"**\u002Fsecrets\u002F**\"\n    - \"infrastructure\u002F**\"\n    - \".github\u002Fworkflows\u002F**\"\n\n  allowed_paths:\n    - \"src\u002F**\"\n    - \"lib\u002F**\"\n    - \"tests\u002F**\"\n    - \"docs\u002F**\"\n    - \"package.json\"\n    - \"pyproject.toml\"\n```\n\n### File System Access Controls\n\nUse filesystem permissions to enforce boundaries at the OS level:\n\n```bash\n#!\u002Fbin\u002Fbash\n# setup-agent-workspace.sh\n# Create a restricted workspace for agent execution\n\nAGENT_USER=\"ai-agent\"\nREPO_DIR=\"\u002Fworkspace\u002Frepo\"\n\n# Create agent user with limited permissions\nuseradd --system --shell \u002Fbin\u002Fbash --no-create-home \"$AGENT_USER\"\n\n# Set ownership: developers own everything, agent gets read on most\nchown -R root:developers \"$REPO_DIR\"\nchmod -R 750 \"$REPO_DIR\"\n\n# Grant agent write access only to safe directories\nsetfacl -R -m u:${AGENT_USER}:rwx \"${REPO_DIR}\u002Fsrc\"\nsetfacl -R -m u:${AGENT_USER}:rwx \"${REPO_DIR}\u002Ftests\"\nsetfacl -R -m u:${AGENT_USER}:rwx \"${REPO_DIR}\u002Fdocs\"\n\n# Deny agent access to sensitive files\nsetfacl -m u:${AGENT_USER}:--- \"${REPO_DIR}\u002F.env\"\nsetfacl -R -m u:${AGENT_USER}:--- \"${REPO_DIR}\u002Finfrastructure\"\nsetfacl -R -m u:${AGENT_USER}:--- \"${REPO_DIR}\u002F.github\u002Fworkflows\"\n\necho \"Agent workspace permissions configured.\"\n```\n\n---\n\n## Secret Protection\n\n### Pre-commit Hooks with git-secrets\n\n```bash\n#!\u002Fbin\u002Fbash\n# install-secret-scanning.sh\n\n# Install git-secrets\ngit clone https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fgit-secrets.git \u002Ftmp\u002Fgit-secrets\ncd \u002Ftmp\u002Fgit-secrets && make install\n\n# Initialize in repository\ncd \u002Fpath\u002Fto\u002Frepo\ngit secrets --install\n\n# Register common secret patterns\ngit secrets --register-aws\n\n# Add custom patterns for common credential formats\ngit secrets --add '-----BEGIN (RSA |EC |DSA )?PRIVATE KEY-----'\ngit secrets --add 'AKIA[0-9A-Z]{16}'\ngit secrets --add 'ghp_[a-zA-Z0-9]{36}'\ngit secrets --add 'sk-[a-zA-Z0-9]{48}'\ngit secrets --add 'xox[baprs]-[0-9a-zA-Z-]{10,}'\ngit secrets --add 'password\\s*[:=]\\s*[\"\\x27][^\\s]{8,}'\ngit secrets --add 'api[_-]?key\\s*[:=]\\s*[\"\\x27][^\\s]{8,}'\n\n# Add allowed patterns (false positive exclusions)\ngit secrets --add --allowed 'EXAMPLE_KEY'\ngit secrets --add --allowed 'your-api-key-here'\n```\n\n### Agent Output Scanning\n\nScan agent-generated output before it reaches version control:\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"scan_agent_output.py - Scan AI agent output for leaked secrets.\"\"\"\n\nimport re\nimport sys\nfrom pathlib import Path\n\nSECRET_PATTERNS = [\n    (r'AKIA[0-9A-Z]{16}', 'AWS Access Key'),\n    (r'(?i)aws_secret_access_key\\s*[:=]\\s*\\S+', 'AWS Secret Key'),\n    (r'ghp_[a-zA-Z0-9]{36}', 'GitHub Personal Access Token'),\n    (r'gho_[a-zA-Z0-9]{36}', 'GitHub OAuth Token'),\n    (r'sk-[a-zA-Z0-9]{48,}', 'OpenAI\u002FAnthropic API Key'),\n    (r'xox[baprs]-[0-9a-zA-Z\\-]{10,}', 'Slack Token'),\n    (r'-----BEGIN (RSA |EC |DSA )?PRIVATE KEY-----', 'Private Key'),\n    (r'(?i)(password|passwd|pwd)\\s*[:=]\\s*[\"\\x27][^\\s]{4,}', 'Hardcoded Password'),\n    (r'(?i)(api[_-]?key|apikey)\\s*[:=]\\s*[\"\\x27][^\\s]{8,}', 'API Key'),\n    (r'eyJ[a-zA-Z0-9_-]{10,}\\.[a-zA-Z0-9_-]{10,}', 'JWT Token'),\n    (r'(?i)database_url\\s*[:=]\\s*\\S+', 'Database Connection String'),\n]\n\n\ndef scan_file(filepath: str) -> list[dict]:\n    findings = []\n    content = Path(filepath).read_text(errors=\"ignore\")\n    for line_num, line in enumerate(content.splitlines(), 1):\n        for pattern, label in SECRET_PATTERNS:\n            if re.search(pattern, line):\n                findings.append({\n                    \"file\": filepath,\n                    \"line\": line_num,\n                    \"type\": label,\n                    \"content\": line.strip()[:120],\n                })\n    return findings\n\n\ndef main():\n    files = sys.argv[1:]\n    if not files:\n        print(\"Usage: scan_agent_output.py \u003Cfile1> [file2] ...\")\n        sys.exit(1)\n\n    all_findings = []\n    for f in files:\n        all_findings.extend(scan_file(f))\n\n    if all_findings:\n        print(f\"BLOCKED: {len(all_findings)} potential secret(s) detected:\\n\")\n        for finding in all_findings:\n            print(f\"  [{finding['type']}] {finding['file']}:{finding['line']}\")\n            print(f\"    {finding['content']}\\n\")\n        sys.exit(1)\n\n    print(\"OK: No secrets detected in agent output.\")\n    sys.exit(0)\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Git Pre-commit Hook Integration\n\n```bash\n#!\u002Fbin\u002Fbash\n# .git\u002Fhooks\u002Fpre-commit\n# Block commits containing secrets from AI agents\n\nSTAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)\n\nif [ -z \"$STAGED_FILES\" ]; then\n  exit 0\nfi\n\necho \"Scanning staged files for secrets...\"\n\n# Run git-secrets\ngit secrets --pre_commit_hook -- \"$@\"\nGIT_SECRETS_EXIT=$?\n\n# Run custom scanner on staged files\npython3 .tools\u002Fscan_agent_output.py $STAGED_FILES\nSCANNER_EXIT=$?\n\nif [ $GIT_SECRETS_EXIT -ne 0 ] || [ $SCANNER_EXIT -ne 0 ]; then\n  echo \"\"\n  echo \"COMMIT BLOCKED: Secrets detected in staged files.\"\n  echo \"If this is a false positive, use: git commit\"\n  exit 1\nfi\n```\n\n---\n\n## Sandbox Configuration\n\n### Docker Sandbox for Agent Execution\n\n```dockerfile\n# Dockerfile.agent-sandbox\nFROM ubuntu:24.04\n\nRUN apt-get update && apt-get install -y \\\n    git \\\n    nodejs \\\n    npm \\\n    python3 \\\n    python3-pip \\\n    && rm -rf \u002Fvar\u002Flib\u002Fapt\u002Flists\u002F*\n\n# Create non-root agent user\nRUN useradd -m -s \u002Fbin\u002Fbash agent && \\\n    mkdir -p \u002Fworkspace && \\\n    chown agent:agent \u002Fworkspace\n\n# Drop capabilities\nUSER agent\nWORKDIR \u002Fworkspace\n\n# No network by default - override at runtime if needed\n# No access to Docker socket\n# No access to host filesystem beyond mounted volume\n```\n\n```bash\n#!\u002Fbin\u002Fbash\n# run-agent-sandbox.sh\n# Launch an AI coding agent inside a locked-down container\n\nREPO_DIR=\"$(pwd)\"\nCONTAINER_NAME=\"agent-sandbox-$$\"\n\ndocker run \\\n  --name \"$CONTAINER_NAME\" \\\n  --rm \\\n  --network none \\\n  --read-only \\\n  --tmpfs \u002Ftmp:size=512m \\\n  --tmpfs \u002Fhome\u002Fagent:size=256m \\\n  --memory 4g \\\n  --cpus 2 \\\n  --pids-limit 256 \\\n  --security-opt no-new-privileges:true \\\n  --security-opt seccomp=seccomp-agent.json \\\n  --cap-drop ALL \\\n  --cap-add DAC_OVERRIDE \\\n  -v \"${REPO_DIR}\u002Fsrc:\u002Fworkspace\u002Fsrc\" \\\n  -v \"${REPO_DIR}\u002Ftests:\u002Fworkspace\u002Ftests:rw\" \\\n  -v \"${REPO_DIR}\u002Fdocs:\u002Fworkspace\u002Fdocs:rw\" \\\n  -v \"${REPO_DIR}\u002Fpackage.json:\u002Fworkspace\u002Fpackage.json:ro\" \\\n  -e \"NO_COLOR=1\" \\\n  agent-sandbox:latest \\\n  \"$@\"\n```\n\n### Seccomp Profile for Agent Containers\n\n```json\n{\n  \"defaultAction\": \"SCMP_ACT_ERRNO\",\n  \"comment\": \"seccomp-agent.json - Restrictive profile for AI coding agents\",\n  \"syscalls\": [\n    {\n      \"names\": [\n        \"read\", \"write\", \"open\", \"close\", \"stat\", \"fstat\", \"lstat\",\n        \"poll\", \"lseek\", \"mmap\", \"mprotect\", \"munmap\", \"brk\",\n        \"access\", \"pipe\", \"select\", \"sched_yield\", \"mremap\",\n        \"dup\", \"dup2\", \"nanosleep\", \"getpid\", \"getuid\", \"getgid\",\n        \"geteuid\", \"getegid\", \"getppid\", \"getpgrp\", \"setsid\",\n        \"getgroups\", \"uname\", \"fcntl\", \"flock\", \"fsync\",\n        \"getcwd\", \"chdir\", \"readlink\", \"chmod\", \"mkdir\",\n        \"rmdir\", \"unlink\", \"rename\", \"symlink\", \"readlinkat\",\n        \"openat\", \"mkdirat\", \"newfstatat\", \"unlinkat\", \"renameat\",\n        \"faccessat\", \"pselect6\", \"ppoll\", \"set_robust_list\",\n        \"get_robust_list\", \"epoll_create1\", \"epoll_ctl\", \"epoll_wait\",\n        \"eventfd2\", \"pipe2\", \"dup3\", \"pread64\", \"pwrite64\",\n        \"futex\", \"clock_gettime\", \"clock_getres\", \"exit_group\",\n        \"wait4\", \"clone\", \"execve\", \"arch_prctl\", \"set_tid_address\",\n        \"exit\", \"getdents64\", \"rt_sigaction\", \"rt_sigprocmask\",\n        \"rt_sigreturn\", \"ioctl\", \"writev\", \"madvise\", \"getrandom\"\n      ],\n      \"action\": \"SCMP_ACT_ALLOW\"\n    },\n    {\n      \"names\": [\n        \"socket\", \"connect\", \"bind\", \"listen\", \"accept\",\n        \"sendto\", \"recvfrom\", \"sendmsg\", \"recvmsg\"\n      ],\n      \"action\": \"SCMP_ACT_ERRNO\",\n      \"comment\": \"Block all network syscalls\"\n    },\n    {\n      \"names\": [\"ptrace\", \"process_vm_readv\", \"process_vm_writev\"],\n      \"action\": \"SCMP_ACT_ERRNO\",\n      \"comment\": \"Block debugging and process inspection\"\n    }\n  ]\n}\n```\n\n---\n\n\n## Contents\n\n- [Code Review Gates](references\u002Fdetails.md)\n- [Repository Configuration](references\u002Fdetails.md)\n- [Security Rules](references\u002Fdetails.md)\n- [File Restrictions](references\u002Fdetails.md)\n- [Code Quality](references\u002Fdetails.md)\n- [Git Behavior](references\u002Fdetails.md)\n- [Rules](references\u002Fdetails.md)\n- [Network Controls](references\u002Fdetails.md)\n- [Audit Trail](references\u002Fdetails.md)\n- [Team Policies](references\u002Fdetails.md)\n- [Testing Agent Output](references\u002Fdetails.md)\n- [Quick Reference](references\u002Fdetails.md)\n\n## When to Use\n\nApply these guardrails when:\n\n- Onboarding AI coding agents into an engineering team for the first time\n- Developers are using Claude Code, Cursor, Copilot, or Codex to generate production code\n- Agents have access to repositories containing secrets, infrastructure configs, or sensitive business logic\n- Your compliance framework (SOC 2, ISO 27001, FedRAMP) requires controls around automated code generation\n- Autonomous or semi-autonomous agents are creating pull requests without direct human typing\n- You need to enforce consistent security policies across multiple agents and team members\n\nSigns you need tighter guardrails:\n\n- Agents have committed secrets or credentials to version control\n- Agent-generated code has introduced vulnerabilities caught late in the pipeline\n- No clear audit trail distinguishes human-written from AI-generated code\n- Developers are bypassing code review for \"simple\" agent changes\n- Agents are executing arbitrary shell commands in production-connected environments\n\n---\n\n## Limitations\n\n- Apply guidance only within authorized scope; test destructive steps in non-production first.\n- Docs-only import: upstream scripts and templates not bundled.\n\n### Example\n\n```bash\n# Read-only first: inventory before any active step.\nwhich \u003Ctool> && \u003Ctool> --help | head -n 20\n```\n\n> Adapted from [BagelHole\u002FDevOps-Security-Agent-Skills](https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills) (MIT); frontmatter, When to Use\u002FLimitations, and safety boundaries added for upstream compliance. Docs-only import: helper scripts and templates not bundled.\n","# AI Coding Agent Guardrails\n\nSecure the use of AI coding agents across engineering teams. This skill covers permission boundaries, secret protection, sandbox isolation, code review gates, and audit trails for Claude Code, Cursor, Copilot, and Codex.\n\n---\n\n## Permission Boundaries\n\n### CLAUDE.md Configuration\n\nCreate a `CLAUDE.md` at the repository root to restrict Claude Code behavior:\n\n```markdown\n# CLAUDE.md\n\n## Restrictions\n\n- NEVER read or output contents of .env, .env.*, secrets.yaml, or any file matching *.pem, *.key\n- NEVER execute `rm -rf`, `DROP TABLE`, `kubectl delete`, or `terraform destroy` commands\n- NEVER push directly to main or master branches\n- NEVER modify files in the infrastructure\u002F, terraform\u002F, or .github\u002Fworkflows\u002F directories without explicit user approval\n- NEVER install new dependencies without listing them first for review\n- NEVER access or display API keys, tokens, passwords, or connection strings\n\n## Allowed Operations\n\n- Read and modify application source code in src\u002F, lib\u002F, and tests\u002F\n- Run test suites with `npm test`, `pytest`, `go test`\n- Run linters with `eslint`, `ruff`, `golangci-lint`\n- Create new branches with prefix `ai\u002F` or `agent\u002F`\n- Create and modify files in docs\u002F directory\n\n## Code Standards\n\n- All new functions must include docstrings or JSDoc comments\n- All new code must have corresponding unit tests\n- Follow existing code style and patterns in the repository\n- Maximum file length: 500 lines. Suggest splitting if exceeded.\n```\n\n### Command Allowlists\n\nFor agents that execute shell commands, define an explicit allowlist:\n\n```yaml\n# .agent-permissions.yaml\nagent_permissions:\n  allowed_commands:\n    - \"npm test\"\n    - \"npm run lint\"\n    - \"npm run build\"\n    - \"pytest\"\n    - \"ruff check\"\n    - \"go test .\u002F...\"\n    - \"git status\"\n    - \"git diff\"\n    - \"git log\"\n    - \"git checkout -b\"\n    - \"git add\"\n    - \"git commit\"\n    - \"ls\"\n    - \"cat\"\n    - \"head\"\n    - \"tail\"\n\n  blocked_commands:\n    - \"rm -rf\"\n    - \"curl\"\n    - \"wget\"\n    - \"ssh\"\n    - \"scp\"\n    - \"kubectl\"\n    - \"terraform\"\n    - \"aws\"\n    - \"gcloud\"\n    - \"az\"\n    - \"docker push\"\n    - \"npm publish\"\n\n  blocked_paths:\n    - \".env*\"\n    - \"**\u002F*.pem\"\n    - \"**\u002F*.key\"\n    - \"**\u002Fsecrets\u002F**\"\n    - \"infrastructure\u002F**\"\n    - \".github\u002Fworkflows\u002F**\"\n\n  allowed_paths:\n    - \"src\u002F**\"\n    - \"lib\u002F**\"\n    - \"tests\u002F**\"\n    - \"docs\u002F**\"\n    - \"package.json\"\n    - \"pyproject.toml\"\n```\n\n### File System Access Controls\n\nUse filesystem permissions to enforce boundaries at the OS level:\n\n```bash\n#!\u002Fbin\u002Fbash\n# setup-agent-workspace.sh\n# Create a restricted workspace for agent execution\n\nAGENT_USER=\"ai-agent\"\nREPO_DIR=\"\u002Fworkspace\u002Frepo\"\n\n# Create agent user with limited permissions\nuseradd --system --shell \u002Fbin\u002Fbash --no-create-home \"$AGENT_USER\"\n\n# Set ownership: developers own everything, agent gets read on most\nchown -R root:developers \"$REPO_DIR\"\nchmod -R 750 \"$REPO_DIR\"\n\n# Grant agent write access only to safe directories\nsetfacl -R -m u:${AGENT_USER}:rwx \"${REPO_DIR}\u002Fsrc\"\nsetfacl -R -m u:${AGENT_USER}:rwx \"${REPO_DIR}\u002Ftests\"\nsetfacl -R -m u:${AGENT_USER}:rwx \"${REPO_DIR}\u002Fdocs\"\n\n# Deny agent access to sensitive files\nsetfacl -m u:${AGENT_USER}:--- \"${REPO_DIR}\u002F.env\"\nsetfacl -R -m u:${AGENT_USER}:--- \"${REPO_DIR}\u002Finfrastructure\"\nsetfacl -R -m u:${AGENT_USER}:--- \"${REPO_DIR}\u002F.github\u002Fworkflows\"\n\necho \"Agent workspace permissions configured.\"\n```\n\n---\n\n## Secret Protection\n\n### Pre-commit Hooks with git-secrets\n\n```bash\n#!\u002Fbin\u002Fbash\n# install-secret-scanning.sh\n\n# Install git-secrets\ngit clone https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fgit-secrets.git \u002Ftmp\u002Fgit-secrets\ncd \u002Ftmp\u002Fgit-secrets && make install\n\n# Initialize in repository\ncd \u002Fpath\u002Fto\u002Frepo\ngit secrets --install\n\n# Register common secret patterns\ngit secrets --register-aws\n\n# Add custom patterns for common credential formats\ngit secrets --add '-----BEGIN (RSA |EC |DSA )?PRIVATE KEY-----'\ngit secrets --add 'AKIA[0-9A-Z]{16}'\ngit secrets --add 'ghp_[a-zA-Z0-9]{36}'\ngit secrets --add 'sk-[a-zA-Z0-9]{48}'\ngit secrets --add 'xox[baprs]-[0-9a-zA-Z-]{10,}'\ngit secrets --add 'password\\s*[:=]\\s*[\"\\x27][^\\s]{8,}'\ngit secrets --add 'api[_-]?key\\s*[:=]\\s*[\"\\x27][^\\s]{8,}'\n\n# Add allowed patterns (false positive exclusions)\ngit secrets --add --allowed 'EXAMPLE_KEY'\ngit secrets --add --allowed 'your-api-key-here'\n```\n\n### Agent Output Scanning\n\nScan agent-generated output before it reaches version control:\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"scan_agent_output.py - Scan AI agent output for leaked secrets.\"\"\"\n\nimport re\nimport sys\nfrom pathlib import Path\n\nSECRET_PATTERNS = [\n    (r'AKIA[0-9A-Z]{16}', 'AWS Access Key'),\n    (r'(?i)aws_secret_access_key\\s*[:=]\\s*\\S+', 'AWS Secret Key'),\n    (r'ghp_[a-zA-Z0-9]{36}', 'GitHub Personal Access Token'),\n    (r'gho_[a-zA-Z0-9]{36}', 'GitHub OAuth Token'),\n    (r'sk-[a-zA-Z0-9]{48,}', 'OpenAI\u002FAnthropic API Key'),\n    (r'xox[baprs]-[0-9a-zA-Z\\-]{10,}', 'Slack Token'),\n    (r'-----BEGIN (RSA |EC |DSA )?PRIVATE KEY-----', 'Private Key'),\n    (r'(?i)(password|passwd|pwd)\\s*[:=]\\s*[\"\\x27][^\\s]{4,}', 'Hardcoded Password'),\n    (r'(?i)(api[_-]?key|apikey)\\s*[:=]\\s*[\"\\x27][^\\s]{8,}', 'API Key'),\n    (r'eyJ[a-zA-Z0-9_-]{10,}\\.[a-zA-Z0-9_-]{10,}', 'JWT Token'),\n    (r'(?i)database_url\\s*[:=]\\s*\\S+', 'Database Connection String'),\n]\n\n\ndef scan_file(filepath: str) -> list[dict]:\n    findings = []\n    content = Path(filepath).read_text(errors=\"ignore\")\n    for line_num, line in enumerate(content.splitlines(), 1):\n        for pattern, label in SECRET_PATTERNS:\n            if re.search(pattern, line):\n                findings.append({\n                    \"file\": filepath,\n                    \"line\": line_num,\n                    \"type\": label,\n                    \"content\": line.strip()[:120],\n                })\n    return findings\n\n\ndef main():\n    files = sys.argv[1:]\n    if not files:\n        print(\"Usage: scan_agent_output.py \u003Cfile1> [file2] ...\")\n        sys.exit(1)\n\n    all_findings = []\n    for f in files:\n        all_findings.extend(scan_file(f))\n\n    if all_findings:\n        print(f\"BLOCKED: {len(all_findings)} potential secret(s) detected:\\n\")\n        for finding in all_findings:\n            print(f\"  [{finding['type']}] {finding['file']}:{finding['line']}\")\n            print(f\"    {finding['content']}\\n\")\n        sys.exit(1)\n\n    print(\"OK: No secrets detected in agent output.\")\n    sys.exit(0)\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Git Pre-commit Hook Integration\n\n```bash\n#!\u002Fbin\u002Fbash\n# .git\u002Fhooks\u002Fpre-commit\n# Block commits containing secrets from AI agents\n\nSTAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)\n\nif [ -z \"$STAGED_FILES\" ]; then\n  exit 0\nfi\n\necho \"Scanning staged files for secrets...\"\n\n# Run git-secrets\ngit secrets --pre_commit_hook -- \"$@\"\nGIT_SECRETS_EXIT=$?\n\n# Run custom scanner on staged files\npython3 .tools\u002Fscan_agent_output.py $STAGED_FILES\nSCANNER_EXIT=$?\n\nif [ $GIT_SECRETS_EXIT -ne 0 ] || [ $SCANNER_EXIT -ne 0 ]; then\n  echo \"\"\n  echo \"COMMIT BLOCKED: Secrets detected in staged files.\"\n  echo \"If this is a false positive, use: git commit\"\n  exit 1\nfi\n```\n\n---\n\n## Sandbox Configuration\n\n### Docker Sandbox for Agent Execution\n\n```dockerfile\n# Dockerfile.agent-sandbox\nFROM ubuntu:24.04\n\nRUN apt-get update && apt-get install -y \\\n    git \\\n    nodejs \\\n    npm \\\n    python3 \\\n    python3-pip \\\n    && rm -rf \u002Fvar\u002Flib\u002Fapt\u002Flists\u002F*\n\n# Create non-root agent user\nRUN useradd -m -s \u002Fbin\u002Fbash agent && \\\n    mkdir -p \u002Fworkspace && \\\n    chown agent:agent \u002Fworkspace\n\n# Drop capabilities\nUSER agent\nWORKDIR \u002Fworkspace\n\n# No network by default - override at runtime if needed\n# No access to Docker socket\n# No access to host filesystem beyond mounted volume\n```\n\n```bash\n#!\u002Fbin\u002Fbash\n# run-agent-sandbox.sh\n# Launch an AI coding agent inside a locked-down container\n\nREPO_DIR=\"$(pwd)\"\nCONTAINER_NAME=\"agent-sandbox-$$\"\n\ndocker run \\\n  --name \"$CONTAINER_NAME\" \\\n  --rm \\\n  --network none \\\n  --read-only \\\n  --tmpfs \u002Ftmp:size=512m \\\n  --tmpfs \u002Fhome\u002Fagent:size=256m \\\n  --memory 4g \\\n  --cpus 2 \\\n  --pids-limit 256 \\\n  --security-opt no-new-privileges:true \\\n  --security-opt seccomp=seccomp-agent.json \\\n  --cap-drop ALL \\\n  --cap-add DAC_OVERRIDE \\\n  -v \"${REPO_DIR}\u002Fsrc:\u002Fworkspace\u002Fsrc\" \\\n  -v \"${REPO_DIR}\u002Ftests:\u002Fworkspace\u002Ftests:rw\" \\\n  -v \"${REPO_DIR}\u002Fdocs:\u002Fworkspace\u002Fdocs:rw\" \\\n  -v \"${REPO_DIR}\u002Fpackage.json:\u002Fworkspace\u002Fpackage.json:ro\" \\\n  -e \"NO_COLOR=1\" \\\n  agent-sandbox:latest \\\n  \"$@\"\n```\n\n### Seccomp Profile for Agent Containers\n\n```json\n{\n  \"defaultAction\": \"SCMP_ACT_ERRNO\",\n  \"comment\": \"seccomp-agent.json - Restrictive profile for AI coding agents\",\n  \"syscalls\": [\n    {\n      \"names\": [\n        \"read\", \"write\", \"open\", \"close\", \"stat\", \"fstat\", \"lstat\",\n        \"poll\", \"lseek\", \"mmap\", \"mprotect\", \"munmap\", \"brk\",\n        \"access\", \"pipe\", \"select\", \"sched_yield\", \"mremap\",\n        \"dup\", \"dup2\", \"nanosleep\", \"getpid\", \"getuid\", \"getgid\",\n        \"geteuid\", \"getegid\", \"getppid\", \"getpgrp\", \"setsid\",\n        \"getgroups\", \"uname\", \"fcntl\", \"flock\", \"fsync\",\n        \"getcwd\", \"chdir\", \"readlink\", \"chmod\", \"mkdir\",\n        \"rmdir\", \"unlink\", \"rename\", \"symlink\", \"readlinkat\",\n        \"openat\", \"mkdirat\", \"newfstatat\", \"unlinkat\", \"renameat\",\n        \"faccessat\", \"pselect6\", \"ppoll\", \"set_robust_list\",\n        \"get_robust_list\", \"epoll_create1\", \"epoll_ctl\", \"epoll_wait\",\n        \"eventfd2\", \"pipe2\", \"dup3\", \"pread64\", \"pwrite64\",\n        \"futex\", \"clock_gettime\", \"clock_getres\", \"exit_group\",\n        \"wait4\", \"clone\", \"execve\", \"arch_prctl\", \"set_tid_address\",\n        \"exit\", \"getdents64\", \"rt_sigaction\", \"rt_sigprocmask\",\n        \"rt_sigreturn\", \"ioctl\", \"writev\", \"madvise\", \"getrandom\"\n      ],\n      \"action\": \"SCMP_ACT_ALLOW\"\n    },\n    {\n      \"names\": [\n        \"socket\", \"connect\", \"bind\", \"listen\", \"accept\",\n        \"sendto\", \"recvfrom\", \"sendmsg\", \"recvmsg\"\n      ],\n      \"action\": \"SCMP_ACT_ERRNO\",\n      \"comment\": \"Block all network syscalls\"\n    },\n    {\n      \"names\": [\"ptrace\", \"process_vm_readv\", \"process_vm_writev\"],\n      \"action\": \"SCMP_ACT_ERRNO\",\n      \"comment\": \"Block debugging and process inspection\"\n    }\n  ]\n}\n```\n\n---\n\n\n## Contents\n\n- [Code Review Gates](references\u002Fdetails.md)\n- [Repository Configuration](references\u002Fdetails.md)\n- [Security Rules](references\u002Fdetails.md)\n- [File Restrictions](references\u002Fdetails.md)\n- [Code Quality](references\u002Fdetails.md)\n- [Git Behavior](references\u002Fdetails.md)\n- [Rules](references\u002Fdetails.md)\n- [Network Controls](references\u002Fdetails.md)\n- [Audit Trail](references\u002Fdetails.md)\n- [Team Policies](references\u002Fdetails.md)\n- [Testing Agent Output](references\u002Fdetails.md)\n- [Quick Reference](references\u002Fdetails.md)\n\n## When to Use\n\nApply these guardrails when:\n\n- Onboarding AI coding agents into an engineering team for the first time\n- Developers are using Claude Code, Cursor, Copilot, or Codex to generate production code\n- Agents have access to repositories containing secrets, infrastructure configs, or sensitive business logic\n- Your compliance framework (SOC 2, ISO 27001, FedRAMP) requires controls around automated code generation\n- Autonomous or semi-autonomous agents are creating pull requests without direct human typing\n- You need to enforce consistent security policies across multiple agents and team members\n\nSigns you need tighter guardrails:\n\n- Agents have committed secrets or credentials to version control\n- Agent-generated code has introduced vulnerabilities caught late in the pipeline\n- No clear audit trail distinguishes human-written from AI-generated code\n- Developers are bypassing code review for \"simple\" agent changes\n- Agents are executing arbitrary shell commands in production-connected environments\n\n---\n\n## Limitations\n\n- Apply guidance only within authorized scope; test destructive steps in non-production first.\n- Docs-only import: upstream scripts and templates not bundled.\n\n### Example\n\n```bash\n# Read-only first: inventory before any active step.\nwhich \u003Ctool> && \u003Ctool> --help | head -n 20\n```\n\n> Adapted from [BagelHole\u002FDevOps-Security-Agent-Skills](https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills) (MIT); frontmatter, When to Use\u002FLimitations, and safety boundaries added for upstream compliance. Docs-only import: helper scripts and templates not bundled.\n",{"name":5,"risk":51,"source":52,"license":14,"category":53,"metadata":54,"date_added":57,"description":7,"source_repo":58,"source_type":40,"compatibility":59,"license_source":60},"safe","https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills","security",{"author":55,"version":56},"devops-skills","1.0","2026-09-20","BagelHole\u002FDevOps-Security-Agent-Skills","Requires the relevant security tooling (scanners, vault CLIs) and an authorized scope for any active assessment. Docs-only; helper scripts and templates not bundled.","https:\u002F\u002Fgithub.com\u002FBagelHole\u002FDevOps-Security-Agent-Skills\u002Fblob\u002Fmain\u002FLICENSE","f3312ba749561b6159f477dbfc9313c875d40a56",".agents\u002Fskills_archive\u002Fai-coding-agent-guardrails","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612","2026-10-25 23:50:58",{"source":8,"skillName":5,"commands":67,"prompt":77,"zipAvailable":78},[68,71,74],{"tool":69,"command":70},"npx","npx skills add duc-duy-1612\u002FOnline-Delivery-Systems-Web --skill ai-coding-agent-guardrails",{"tool":72,"command":73},"bunx","bunx skills add duc-duy-1612\u002FOnline-Delivery-Systems-Web --skill ai-coding-agent-guardrails",{"tool":75,"command":76},"pnpm","pnpm dlx skills add duc-duy-1612\u002FOnline-Delivery-Systems-Web --skill ai-coding-agent-guardrails","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fai-coding-agent-guardrails\u002FSKILL.md",true,[80],{"path":81,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":84,"sourceHtmlUrl":85},"references\u002Fdetails.md","REFERENCE","参考文档",21122,"https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fai-coding-agent-guardrails\u002Freferences\u002Fdetails.md",[87,108,131,155,183,206],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":96,"publishedAt":46},"01M6Q0FA5FZ410Z33Z3TFQ4DBA","zero-trust","Implement zero-trust network architecture. Configure identity-based access, micro-segmentation, and continuous verification. Use when implementing modern security architectures.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fzero-trust\u002FSKILL.md",[93],{"categoryNo":94,"categoryName":95,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000011","运维与部署",[97,98,99,100,32,101,89,102,35,103,104,38,40,41,42,105,43,106,44,107],"ZeRO","trust","zero trust","architecture","verification","segmentation","access","configure","critical","scripts","implementing",{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":46},"01M6Q0F1YZJW3KX5FBKEVZ8CV4","zcode-delegate","Delegate coding tasks to the Z.AI ZCode CLI only when the user explicitly requests it, while the orchestrator retains review and landing responsibility.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fzcode-delegate\u002FSKILL.md",[],[115,116,117,45,118,119,120,121,122,123,124,125,126,38,127,40,128,129,105,130],"delegate","zcode","zcode delegate","cli","orchestration","tasks","run","Bash","model","node","read","orchestrator","files","desktop app","app","agent-orchestration",{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":46},"01M6Q0ETK41VGNMYEXW0T00AJN","youtube-transcript","Fetch YouTube transcripts through DeepAPI or local fallback tooling and save clean text output.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fyoutube-transcript\u002FSKILL.md",[],[138,139,140,51,141,142,143,144,145,146,147,148,149,40,41,150,151,152,153,154],"transcript","youtube transcript","youtube","github","codex","research","license","https","text","fetch","tooling","clean","local","output","deepapi","youtube transcripts","blob",{"skillNo":156,"name":157,"nameZh":6,"description":158,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":159,"categories":160,"keywords":172,"publishedAt":46},"01M6Q0EPPH2PVMDW40017F8WX0","youtube-transcript-skills","Fetch YouTube video transcripts, search videos\u002Fchannels, browse channels, and extract playlists via the getyoutubetranscript.com API - free tier, no card required.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fyoutube-transcript-skills\u002FSKILL.md",[161,164,167],{"categoryNo":162,"categoryName":163,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":165,"categoryName":166,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000016","图像与多媒体",{"categoryNo":168,"categoryName":169,"taxonomyType":170,"taxonomyTypeDesc":171},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[138,139,140,173,51,174,141,142,144,175,176,177,178,147,179,40,41,180,181,182],"youtube transcript skills","gemini","search","api","Video","browse","api-integration","free","card","channels",{"skillNo":184,"name":185,"nameZh":6,"description":186,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":187,"categories":188,"keywords":193,"publishedAt":46},"01M6Q0EAB96PX83W5PTE8A0R8D","youtube-notetaker","Turn YouTube talks into local study notes with slides, transcripts, editable annotations, and a markdown-backed viewer.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fyoutube-notetaker\u002FSKILL.md",[189,192],{"categoryNo":190,"categoryName":191,"taxonomyType":20,"taxonomyTypeDesc":21},"01JBSEEDCAT000000000000003","演示文稿",{"categoryNo":165,"categoryName":166,"taxonomyType":20,"taxonomyTypeDesc":21},[140,194,195,118,51,196,197,198,33,144,177,199,200,201,202,41,203,150,204,205],"youtube notetaker","notetaker","workflow","official","notes","markdown","slides","annotations","README","study","dair-academy","viewer",{"skillNo":207,"name":208,"nameZh":6,"description":209,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":210,"categories":211,"keywords":213,"publishedAt":46},"01M6Q0E55F0GW5MX48V8HXS8B5","youtube-full","Fetch YouTube transcripts, search videos, browse channels, and extract playlists via TranscriptAPI — no yt-dlp, no Google API key, works from any cloud server.","https:\u002F\u002Fgithub.com\u002Fduc-duy-1612\u002FOnline-Delivery-Systems-Web\u002Fblob\u002Fmain\u002F.agents\u002Fskills_archive\u002Fyoutube-full\u002FSKILL.md",[212],{"categoryNo":162,"categoryName":163,"taxonomyType":20,"taxonomyTypeDesc":21},[214,140,215,216,51,174,175,217,218,176,177,178,147,219,179,40,41,180,220,153],"youtube full","full","google","server","dlp","credits","automatic"]