personal-corp-os
Personal Corp OS: run a one-person company through AI agents with a weekly rhythm, department repos, safe public releases, and open Claude Code and Codex skills.
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Badge for your README
Markdown
[](/listings/serejaris--personal-corp-os)HTML
<a href="/listings/serejaris--personal-corp-os"><img src="/api/listings/serejaris--personal-corp-os/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
Claude Code
Terminal:
claude plugin marketplace add serejaris/personal-corp-os claude plugin install personal-corp-os@personal-corp-os claude plugin details personal-corp-os
Claude Code Desktop or interactive `/plugin` flow:
1. Open **Plugins** or `/plugin`. 2. Add marketplace: `serejaris/personal-corp-os`. 3. Install `personal-corp-os`.
Codex
This repo includes a Codex plugin manifest at [.codex-plugin/plugin.json](.codex-plugin/plugin.json). Add the marketplace from GitHub, then install the plugin:
codex plugin marketplace add serejaris/personal-corp-os codex plugin add personal-corp-os@personal-corp-os
After installation, start a new Codex thread and try:
Use Personal Corp skills to plan my week.
Migrating from personal-corp-skills
The repository was named `personal-corp-skills` until 2026-08-06. GitHub redirects the old links. The plugin identifier was renamed along with the repository, so remove the installed `personal-corp-skills` plugin via `/plugin` in Claude Code and install the new one using the instructions above.
Single Skill
Use this when you want one skill folder instead of the whole plugin:
> Install this skill: `https://github.com/serejaris/personal-corp-os/tree/main/skills/cc-analytics`
Replace `cc-analytics` with any skill name from the table below.
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
.claude-plugin/marketplace.json · Manifest · 20 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.
- {
- "name": "personal-corp-os",
- "description": "Personal Corp OS: run a one-person company through AI agents with a weekly rhythm, department repos, safe public releases, and open Claude Code and Codex skills.",
- "owner": {
- "name": "Sereja Ris",
- "email": "ris@sereja.tech"
- },
- "plugins": [
- {
- "name": "personal-corp-os",
- "source": "./",
- "description": "Personal Corp framework: run your business with AI agents through GitHub. Includes planning, retro, GitHub ops, department repositories, safe public artifact releases, Telegram and agent-gateway workflows, meeting copilot, html-draft diagrams, media/art-direction workflows, and utility skills.",
- "version": "6.0.0",
- "author": {
- "name": "Sereja Ris"
- },
- "category": "productivity"
- }
- ]
- }
README.md · README · 341 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.
- # Personal Corp OS
- Manager uses your local Manager Config for repositories and boards; the distributed skill contains no personal workspace logs.
- [](README.md)
- [](README.ru.md)
- [](LICENSE)
- [](https://github.com/serejaris/personal-corp-os/actions/workflows/validate.yml)
- > Personal Corp is a way to run a one-person company through AI agents: tasks out of your head, departments instead of one person's memory, a weekly retro instead of "I'll sort it out someday".
- This repo holds everything you need for that: the story of how the system works, templates for the HQ and a department, and the open skills for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) and Codex.
- By [Ris](https://t.me/ris_ai) — AI development & vibecoding.
- Русская версия: [README.ru.md](README.ru.md).
- ## The problem: you are the bottleneck
- Not because you work too little. Because strategy, memory, coordination, execution, and acceptance all sit in one pile — inside your head. While that is true, your department's throughput equals yours.
- Hiring does not fix it: a new person takes the work but not the context, so you keep explaining. AI alone does not fix it either: an agent without context is the same new hire, except it does not remember yesterday.
- The issue is not model strength. The issue is that context never leaves your head.
- ## What agent rules actually are
- Agent rules are a plain text file sitting in a folder. No magic: text you read with your eyes and edit by hand.
- Such a file lives in every folder, and its content differs.
- 
- Opening a folder, the agent learns three things from that file.
- 
- Those three answers replace a long prompt. The agent gets them from the folder instead of your message, so you stop explaining the same thing every time.
- ## The core idea: the folder defines the view
- Start the agent from the HQ and it reads the HQ rules and sees the map of the whole system. Start it from a department and it reads the department rules and sees that domain, its tasks, and its skills. Same model, different view, set by the folder rather than by a long prompt.
- Everything else follows from that: for this to work, context has to leave your head into files, and those files have to sit in folders that carry rules.
- ## What a department is
- A department is a folder that owns one domain and accumulates experience about it. Inside it has its own rules, its own tasks, and its own skills.
- 
- ### Which departments people start with
- I run about thirty. These are the usual first ones:
- | Department | What it accumulates | Time to create it |
- |---|---|---|
- | Content | Voice, topics, finished texts, notes on what landed | You write regularly and re-explain your style every time |
- | Research | Questions, found facts, sources, conclusions tied to decisions | You are looking up the same thing a second time |
- | Sales | People, agreements, correspondence, deal status | You keep track of who was promised what in your head |
- | Media | Briefs, prompts, finished assets, acceptance criteria | You generate images and video and the briefs get lost |
- | Legal | Contracts, templates, wording you already agreed to | Every new contract is assembled from scratch |
- | Finance | Expenses, subscriptions, recurring payments | You cannot recall what is charged every month |
- A department exists for repetition. Work that happened once is fine living in the HQ.
- ## What a skill is
- A skill is a written-down way of working that can be repeated. You walk the work by hand once, write the steps down, and from then on the agent runs them.
- 
- ## Four layers and who lives where
- | Layer | Who acts | What lives here |
- |---|---|---|
- | Management | The human | Goal, priorities, limits, the right to say "good enough" |
- | **Truth** | The human writes, the agent reads | Rules, memory, indexes, source of truth |
- | **Operations** | The agent executes, the human accepts | Tasks, queue, statuses, runs, departments |
- | Observation | The agent collects, the human looks | Dashboards, metrics, blockers |
- A subagent lives only in the operations layer: it does not write truth about the system and does not accept results.
- One test for any file: **is this truth about the system, or is it the result of work?** Truth sits in the folder from day one. Results are created by skills once there is something to record. That is why the templates ship no empty files for future reports, decisions, or glossaries.
- ## The route: how experience becomes capital
- ```mermaid
- graph LR
- A["Task<br/>owner + criteria"] --> B["Execution<br/>human or agent"]
- B --> C["Acceptance<br/>good enough or not"]
- C --> D["Pattern<br/>what worked"]
- D --> E["Department memory<br/>rules and decisions"]
- E --> F["Priority<br/>next week"]
- F --> A
- style A fill:#8b5cf6,color:#fff
- style C fill:#f59e0b,color:#fff
- style E fill:#10b981,color:#fff
- ```
- **1. Writing the task down.** A thought becomes a task once it has an owner, done criteria, and a place to live. Before that it lives in you. After that both a human and an agent can pick it up.
- **2. Experience accumulating in departments.** Artifacts and decisions settle in a department — a separate folder for its own domain. Next time the agent reads the department instead of reading you.
- **3. Retro with the agent.** Once a week you look at what worked and promote it into rules. Whatever you corrected twice becomes a written rule and stops needing you.
- ## The weekly rhythm
- Three links on their own are a feature list. The rhythm turns them into a system.
- ```mermaid
- graph LR
- R["retro<br/>what worked"] --> P["planning<br/>priorities of the week"]
- P --> D["daily<br/>living full-week view"]
- D --> T["tasks<br/>into departments"]
- T --> E["execution<br/>the trace goes back into the task"]
- E --> R
- style R fill:#f59e0b,color:#fff
- style P fill:#3b82f6,color:#fff
- style D fill:#64748b,color:#fff
- style T fill:#8b5cf6,color:#fff
- style E fill:#10b981,color:#fff
- ```
- The rhythm answers the question that usually stays unanswered: when exactly does experience turn into a rule. Answer: at the retro, once a week, not "someday".
- The same word gives a different result depending on the folder: "retro" inside a department means a slice of that department, "retro" in the HQ means a slice of the whole system. Folder rules win over general ones.
- Each generated department also includes a local `daily` skill. It refreshes the living `WNN-plan.html`: the whole ISO week stays visible, past days keep their facts, today is highlighted, future days remain the plan, and browser-only Wealth habits persist locally.
- ## Three levels of task tracking
- 
- ## Templates
- | Template | What it is |
- |---|---|
- | [`templates/hq`](./templates/hq/) | The HQ — the agent's entry point and the map of the system |
- | [`templates/department`](./templates/department/) | A department — one domain with its own tasks and skills |
- Departments sit **next to the HQ, not inside it**. Every template file opens with a line stating why it is there and which layer it belongs to.
- ## First step: 30 minutes today
- 1. Copy [`templates/hq`](./templates/hq/) to your machine and fill in `me.md`.
- 2. Open the agent from that folder and ask it to read `AGENTS.md`.
- 3. Create your first department from [`templates/department`](./templates/department/) next to the HQ and put one real task into it.
- 4. Install the plugin (see [Install](#install)) — it brings the weekly-rhythm skills.
- 5. Run the retro at the end of the week and planning at the start of the next one.
- After two such weeks the department has its own memory, and part of the decisions stop going through you.
- ## The four skills of the rhythm
- | Skill | Link in the route | What it does |
- |-------|-------------------|--------------|
- | [corp-doctor](./skills/corp-doctor/) | Loop, department, task | Diagnose and repair the loop, add a department, route a task |
- | [manager](./skills/manager/) | Execution | Sync session work into task files or GitHub issues and answer "what about this task" |
- | [weekly-retro](./skills/weekly-retro/) | Pattern into memory | Facts, outcome scorecard, Area Interviews, and next-week Area goals |
- | [weekly-planning](./skills/weekly-planning/) | Priority | Outcomes, seven-day living plan, Area Explorer, clocks, and Wealth habits |
- ## Where this leads
- | Stage | How you think | Where the bottleneck is |
- |-------|---------------|-------------------------|
- | Vibecoder | "Me and AI" | Context in your head |
- | Operator | "I direct agents" | Coordination by hand |
- | CEO | "I run a system" | No bottleneck, the system runs |
- Your job shrinks to three moves: set the goal, pick the next move, accept the result.
- Glossary — [CONTEXT.md](CONTEXT.md). Accepted architectural decisions — [docs/adr/](docs/adr/).
- ## Install
- ### Claude Code
- Terminal:
- ```bash
- claude plugin marketplace add serejaris/personal-corp-os
- claude plugin install personal-corp-os@personal-corp-os
- claude plugin details personal-corp-os
- ```
- Claude Code Desktop or interactive `/plugin` flow:
- 1. Open **Plugins** or `/plugin`.
- 2. Add marketplace: `serejaris/personal-corp-os`.
- 3. Install `personal-corp-os`.
- ### Codex
- This repo includes a Codex plugin manifest at [.codex-plugin/plugin.json](.codex-plugin/plugin.json).
- Add the marketplace from GitHub, then install the plugin:
- ```bash
- codex plugin marketplace add serejaris/personal-corp-os
- codex plugin add personal-corp-os@personal-corp-os
- ```
- After installation, start a new Codex thread and try:
- ```text
- Use Personal Corp skills to plan my week.
- ```
- ### Migrating from personal-corp-skills
- The repository was named `personal-corp-skills` until 2026-08-06. GitHub redirects the old links. The plugin identifier was renamed along with the repository, so remove the installed `personal-corp-skills` plugin via `/plugin` in Claude Code and install the new one using the instructions above.
- ### Single Skill
- Use this when you want one skill folder instead of the whole plugin:
- > Install this skill: `https://github.com/serejaris/personal-corp-os/tree/main/skills/cc-analytics`
- Replace `cc-analytics` with any skill name from the table below.
- ## All skills
- ### System rhythm
- | Skill | What it does |
- |---|---|
- | [corp-doctor](./skills/corp-doctor/) | One entry point to the loop: diagnose, repair, new department, task routing |
- | [manager](./skills/manager/) | HQ tasks: writes session results to the task file or GitHub issue, answers "what about this task" |
- | [weekly-retro](./skills/weekly-retro/) | Weekly retro: facts, scorecard, Area Interviews, and proposed Area goals |
- | [weekly-planning](./skills/weekly-planning/) | Prioritized outcomes plus a living full-week view refreshed by department daily |
- | [daily](./skills/daily/) | HQ daily focus: open tasks from all departments in a day file `tasks/YYYY-MM-DD.md` |
- | [retro](./skills/retro/) | HQ weekly retro: done, stuck, and repeats across all departments in `tasks/retro-YYYY-WNN.md` |
- ### From intent to tasks
- | Skill | What it does |
- |---|---|
- | [idea](./skills/idea/) | Capture one voiced idea into a provenance-tracked folder with index dedup |
- | [grill-me](./skills/grill-me/) | One question at a time until the plan is actually clear |
- | [harness](./skills/harness/) | One header sets the agent's mode: role, subagent model, effort, subagent limit |
- | [avatar](./skills/avatar/) | Your agent's robot: the model builds its head, the robot is saved in the HQ and opens as a page; joins the Personal Corp live class by link |
- | [corp-new](./skills/corp-new/) | Create a new HQ department: rules, skills and tasks folders, two-way link with the HQ; a private repo only if you ask |
- | [to-prd](./skills/to-prd/) | Synthesize the conversation into `PRD.md` with no new interview |
- | [to-issues](./skills/to-issues/) | Split a PRD into vertical `tasks/NN-slug.md` slices with acceptance criteria |
- | [gh-issues](./skills/gh-issues/) | Manage GitHub Issues through the CLI with session context |
- ### Design and media
- | Skill | What it does |
- |---|---|
- | [art-director](./skills/art-director/) | Iterative visual style search with a process log and a decision graph |
- | [html-draft](./skills/html-draft/) | One technical diagram in flat blueprint style: architecture, flows |
- | [make-landing](./skills/make-landing/) | Reference-led design variants: frozen concepts, gallery, human choice and a second round |
- | [make-3d](./skills/make-3d/) | 3D variants in scene copies, matching image sheets, human choice and transfer to the canon |
- ### Agent orchestration
- | Skill | What it does |
- |---|---|
- | [ceo-council](./skills/ceo-council/) | Parallel subagents as C-level experts for strategic analysis |
- | [fable-ruki-agenty](./skills/fable-ruki-agenty/) | Manual orchestration mode: specs into issues, execution to subagents |
- | [sdlc-milestones](./skills/sdlc-milestones/) | Milestones from the Anthropic AI-Native SDLC Playbook: six stages, a committed artifact (intent, spec, plan, PR) and a human gate at each, plus a status script |
- | [seo-audit](./skills/seo-audit/) | SEO audit with cross-checking: several auditors on one prompt, two blind critics verify every finding on the live site, fixes ship as three PRs with a change log |
- ### Docs and rules
- | Skill | What it does |
- |---|---|
- | [readme-generator](./skills/readme-generator/) | Human-focused README files with proper structure |
- | [claude-md-writer](./skills/claude-md-writer/) | Create and refactor the agent rules file following best practices |
- | [audit-agent-rules](./skills/audit-agent-rules/) | Audit AGENTS.md files and skill descriptions in a folder: report table, edits only after yes |
- ### Operations
- | Skill | What it does |
- |---|---|
- | [meeting-copilot](./skills/meeting-copilot/) | Live meeting dashboard: prepare, update from transcript, close with decisions |
- | [cc-analytics](./skills/cc-analytics/) | HTML report of Claude Code usage statistics |
- | [benchmark](./skills/benchmark/) | Measure pipeline variants (ASR engine, notes model, judge) in an isolated container: time, cost per hour with dated prices, quality |
- | [safe-public-release](./skills/safe-public-release/) | Provenance, licensing, allowlist, and fresh-clone checks before publishing |
- | [tg-bot-ops](./skills/tg-bot-ops/) | Operations playbook for Telegram bots and agent gateways |
- | [claude-sessions-sync](./skills/claude-sessions-sync/) | Sync Claude Code session records between two Anthropic accounts in the desktop app (macOS) when you switch for usage limits |
- | [it-ram-doctor](./skills/it-ram-doctor/) | Find and kill process tails holding memory: idle Claude Code sessions, closed-app leftovers, orphans; swap and pressure before and after |
- ## Agents
- A skill says how to do a job. An agent is who does it: a role with its own instructions and tool set. The plugin ships agents in [`agents/`](./agents/).
- | Agent | Role |
- |---|---|
- | [seo-reviewer](./agents/seo-reviewer.md) | SEO auditor: checks index, links, markup and redirects on the live site, returns the top ten findings with proof and a fix |
- | [blind-critic](./agents/blind-critic.md) | Blind critic: verifies anonymized reports on one task, gives a verdict per finding and ranks the reports |
- | [uncle-bob](./agents/uncle-bob.md) | PR and process reviewer: one verdict 🟢 / 🟡 / 🔴 as a PR comment, findings as `file:line — fix` |
- | [ilyakhov](./agents/ilyakhov.md) | Text editor in Maxim Ilyakhov's information style: the reader's point first, facts instead of judgments |
- | [tufte](./agents/tufte.md) | Layout and data editor after Edward Tufte: structure first, tables instead of paragraphs with numbers |
- | [matt-pocock](./agents/matt-pocock.md) | Matt Pocock on call: proofreads documents for agents (AGENTS.md, CLAUDE.md, skills, agent files) by his `writing-for-agents` skill for synonyms, tautology and contradictions, and names the route through his open skills for your situation |
- | [sereja-ris](./agents/sereja-ris.md) | Guide to Personal Corp OS: sets it up on your machine, picks guides from sereja.tech and the @ris_ai channel for your question, retells what the vibecoders chat is discussing from messages you can read |
- **Claude Code.** The plugin loads the agents; they appear in `/agents` as `personal-corp-os:<name>`. Call one in plain words: "have uncle-bob review PR 12".
- **Codex and other harnesses.** Hand the file over as a role: "read `agents/uncle-bob.md` and review PR 12 by it".
- ## Other
- ### [Statusline](./statusline/)
- Custom statusline showing costs, context usage, and git branch with color-coded indicators.
- ## Archived Skills
- Archived skills are preserved for reference and are not part of the active
- plugin skill set.
- | Skill | Notes |
- |-------|-------|
- | [paperclip-api](./archive/skills/paperclip-api/) | Historical Paperclip API helper; kept for reference |
- ## Manual Installation
- Skills are plain folders. Copy the whole skill directory so optional references
- and examples are preserved:
- ```bash
- cp -r skills/<name> ~/.claude/skills/
- ```
- ## Author
- - Telegram: [@ris_ai](https://t.me/ris_ai) — AI development & vibecoding
- - YouTube: [@serejaris](https://www.youtube.com/@serejaris)
- - [vibecoding.phd](https://vibecoding.phd)
- ## License
- MIT
- ## Security
- Please report secrets, private data exposure, or exploitable behavior privately.
- See [SECURITY.md](SECURITY.md).
skills/corp-new/templates/corp-it/skills/device-inventory/scripts/snapshot-linux.sh · Bundled script · 123 lines
- #!/bin/bash
- # Снимок описи устройства на Linux (systemd): только чтение, права не повышаются.
- # Вывод: разделы шаблона ../template.md, черновик для devices/<устройство>.md.
- # Удалённо: ssh -o BatchMode=yes -o ConnectTimeout=8 <алиас> 'bash -s' < snapshot-linux.sh
- TODAY=$(date +%Y-%m-%d)
- NOT_CHECKED=""
- nc_add() { NOT_CHECKED="${NOT_CHECKED}- $1 - не проверено ${TODAY}: $2
- "; }
- has() { command -v "$1" >/dev/null 2>&1; }
- section() { printf '\n## %s\n\nПроверено: %s (snapshot-linux.sh)\n\n' "$1" "$TODAY"; }
- t10() { timeout 10 "$@" 2>/dev/null; }
- snapshot() {
- host=$(hostnamectl --static 2>/dev/null || hostname)
- printf '# Снимок описи: %s\n\n' "$host"
- printf 'Снято: %s, ' "$TODAY"
- if [ -n "$SSH_CONNECTION" ]; then printf 'по SSH, '; else printf 'локально, '; fi
- printf 'пользователь `%s`, права не повышались. Черновик: перенести изменившееся в devices/<устройство>.md.\n' "$(id -un)"
- section "Шапка"
- echo "- имя хоста: \`$host\` (mDNS \`$host.local\`)"
- section "Система"
- # hostnamectl целиком не печатаем: в нём Machine ID и Boot ID.
- vendor=$(cat /sys/class/dmi/id/sys_vendor 2>/dev/null)
- model=$(cat /sys/class/dmi/id/product_name 2>/dev/null)
- echo "- модель: ${vendor:-?} ${model:-?}"
- echo "- процессор: $(lscpu 2>/dev/null | awk -F: '/^Model name/ {gsub(/^ +/,"",$2); print $2; exit}'), ядер: $(nproc)"
- echo "- память: $(awk '/^MemTotal/ {printf "%d GB", $2/1048576 + 0.5}' /proc/meminfo)"
- echo "- ОС: $(. /etc/os-release 2>/dev/null; echo "${PRETTY_NAME:-?}"), ядро \`$(uname -r)\`"
- section "Ресурсы"
- echo "- RAM: $(awk '/^MemTotal/ {printf "%d GB", $2/1048576 + 0.5}' /proc/meminfo)"
- awk '/^SwapTotal/ {t=$2} END { if (t == 0) print "- своп: нет"; else printf "- своп: есть, порядок %d GB\n", t/1048576 + 0.5 }' /proc/meminfo
- df -h / 2>/dev/null | awk 'NR==2 {printf "- диск рабочего тома: размер %s, занято %s\n", $2, $5}'
- if ls /sys/class/power_supply/BAT* >/dev/null 2>&1; then echo "- питание: батарея есть"; else echo "- питание: батареи нет"; fi
- section "Сеть"
- iface=$(ip route show default 2>/dev/null | awk '{for (i=1;i<NF;i++) if ($i=="dev") {print $(i+1); exit}}')
- gw=$(ip route show default 2>/dev/null | awk '{print $3; exit}')
- if [ -n "$iface" ]; then
- if [ -d "/sys/class/net/$iface/wireless" ]; then kind="Wi-Fi"; else kind="провод или другое"; fi
- echo "- связь: $kind \`$iface\`"
- echo "- адрес: \`$(ip -4 -br addr show "$iface" 2>/dev/null | awk '{print $3}' | cut -d/ -f1)\` (текущий, $TODAY)"
- echo "- шлюз: \`$gw\`"
- else
- echo "- маршрута по умолчанию нет: устройство вне сети"
- fi
- echo "- имя Wi-Fi: в опись не пишется"
- if getent hosts "$host.local" >/dev/null 2>&1; then
- echo "- mDNS-имя: \`$host.local\` разрешается"
- else
- echo "- mDNS-имя: \`$host.local\` не разрешается (нужны avahi-daemon и nss-mdns)"
- fi
- vpn=$(ip -br link 2>/dev/null | awk '$1 ~ /^(wg|tun|tailscale|zt)/ {print $1}' | paste -sd ',' - | sed 's/,/, /g')
- echo "- VPN-интерфейсы: ${vpn:-нет}"
- section "Доступы"
- echo "- sshd: $(systemctl is-active sshd 2>/dev/null || systemctl is-active ssh 2>/dev/null)"
- ports=$(ss -tlnH 2>/dev/null | awk '{n=split($4,a,":"); print a[n]}' | grep -E '^(22|5900|5901|3389)$' | sort -un | paste -sd ',' - | sed 's/,/, /g')
- echo "- слушают порты входа (22 SSH, 5900 и 5901 VNC, 3389 RDP): ${ports:-ни один}"
- echo "- пользователь: \`$(id -un)\`"
- if [ -f "$HOME/.ssh/authorized_keys" ]; then
- echo "- вход по ключу: строк в authorized_keys - $(grep -c -v -E '^[[:space:]]*(#|$)' "$HOME/.ssh/authorized_keys")"
- else
- echo "- authorized_keys: нет у этого пользователя"
- fi
- if [ -f "$HOME/.ssh/config" ]; then
- echo "- SSH-алиасы наружу: $(awk 'tolower($1)=="host" {for (i=2;i<=NF;i++) print $i}' "$HOME/.ssh/config" | grep -v '[*?!]' | sort -u | paste -sd ',' - | sed 's/,/, /g')"
- else
- echo "- SSH-алиасов наружу нет (~/.ssh/config отсутствует)"
- fi
- if has tmux; then echo "- tmux: есть"; else echo "- tmux: нет"; fi
- section "Разрешения"
- # sudo -n true ничего не запускает, а только проверяет, пустит ли система без пароля.
- if sudo -n true 2>/dev/null; then echo "- sudo без пароля: да"; else echo "- sudo без пароля: нет"; fi
- echo "- группы: $(id -Gn | sed 's/ /, /g')"
- echo "- linger (user-службы без входа): $(loginctl show-user "$(id -un)" -p Linger --value 2>/dev/null)"
- for u in ufw nftables firewalld; do
- [ "$(systemctl is-active "$u" 2>/dev/null)" = active ] && echo "- firewall: служба $u активна"
- done
- nc_add "правила firewall" "ufw status и nft list ruleset требуют root"
- section "Агенты и инструменты"
- for d in "$HOME/.local/bin" "$HOME/.npm-global/bin" "$HOME/.bun/bin" "$HOME/.cargo/bin"; do
- [ -d "$d" ] && PATH="$PATH:$d"
- done
- for c in claude codex gemini opencode hermes; do
- p=$(command -v "$c" 2>/dev/null)
- [ -z "$p" ] && continue
- v=$(t10 "$c" --version | head -1)
- echo "- $c: \`$(echo "$p" | sed "s#^$HOME#~#")\`, версия ${v:-не ответила за 10 с}"
- done
- [ -f "$HOME/.claude/settings.json" ] && echo "- Claude Code: настройки \`~/.claude/settings.json\`"
- [ -f "$HOME/.codex/config.toml" ] && echo "- Codex: настройки \`~/.codex/config.toml\`"
- tools=""
- for c in git gh node python3 uv docker ffmpeg; do has "$c" && tools="$tools $c"; done
- echo "- ключевые CLI:${tools:- нет}"
- section "Фоновые службы"
- systemctl --user list-units --type=service --state=running --no-legend --plain 2>/dev/null | awk '{printf "- user: %s - запущена\n", $1}'
- systemctl --user list-timers --no-legend --plain 2>/dev/null | awk '{for (i=1;i<=NF;i++) if ($i ~ /\.timer$/) {printf "- user-таймер: %s\n", $i; break}}'
- failed=$(systemctl list-units --failed --no-legend --plain 2>/dev/null | awk '{print $1}' | paste -sd ',' - | sed 's/,/, /g')
- echo "- упавшие юниты: ${failed:-нет}"
- section "Роли"
- echo "- скрипт роли не снимает: ссылка на отдел-владелец остаётся из текущей описи"
- section "Не проверено"
- printf '%s' "$NOT_CHECKED"
- }
- # Фильтр: MAC, UUID и строки с идентификаторами и секретами в вывод не попадают.
- redact() {
- sed -E 's/([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}/<скрыто>/g; s/[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}/<скрыто>/g' |
- grep -v -i -E 'serial|uuid|udid|bssid|ssid:|machine id|boot id|passw|token|secret|api.?key|private key'
- }
- snapshot 2>/dev/null | redact
skills/corp-new/templates/corp-it/skills/device-inventory/scripts/snapshot-macos.sh · Bundled script · 116 lines
- #!/bin/bash
- # Снимок описи устройства на macOS: только чтение, права не повышаются.
- # Вывод: разделы шаблона ../template.md, черновик для devices/<устройство>.md.
- # Удалённо: ssh -o BatchMode=yes -o ConnectTimeout=8 <алиас> 'bash -s' < snapshot-macos.sh
- # Совместим с bash 3.2 (системный bash macOS).
- TODAY=$(date +%Y-%m-%d)
- NOT_CHECKED=""
- nc_add() { NOT_CHECKED="${NOT_CHECKED}- $1 - не проверено ${TODAY}: $2
- "; }
- has() { command -v "$1" >/dev/null 2>&1; }
- gb() { awk -v b="$1" 'BEGIN{printf "%d GB", b/1073741824 + 0.5}'; }
- section() { printf '\n## %s\n\nПроверено: %s (snapshot-macos.sh)\n\n' "$1" "$TODAY"; }
- # Таймаут без coreutils: perl есть в любой macOS.
- t10() { perl -e 'alarm shift; exec @ARGV' 10 "$@" 2>/dev/null; }
- snapshot() {
- printf '# Снимок описи: %s\n\n' "$(scutil --get ComputerName 2>/dev/null)"
- printf 'Снято: %s, ' "$TODAY"
- if [ -n "$SSH_CONNECTION" ]; then printf 'по SSH, '; else printf 'локально, '; fi
- printf 'пользователь `%s`, права не повышались. Черновик: перенести изменившееся в devices/<устройство>.md.\n' "$(id -un)"
- section "Шапка"
- echo "- имя хоста: \`$(scutil --get LocalHostName 2>/dev/null)\` (mDNS \`$(scutil --get LocalHostName 2>/dev/null).local\`)"
- section "Система"
- echo "- модель: \`$(sysctl -n hw.model)\`"
- echo "- процессор: $(sysctl -n machdep.cpu.brand_string), ядер: $(sysctl -n hw.ncpu)"
- echo "- память: $(gb "$(sysctl -n hw.memsize)")"
- echo "- macOS \`$(sw_vers -productVersion)\`, ядро Darwin \`$(uname -r)\`"
- section "Ресурсы"
- echo "- RAM: $(gb "$(sysctl -n hw.memsize)")"
- sysctl -n vm.swapusage 2>/dev/null | awk '{ t=$3+0; if (t == 0) print "- своп: нет"; else printf "- своп: есть, порядок %d GB\n", t/1024 + 0.5 }'
- df -k /System/Volumes/Data 2>/dev/null | awk 'NR==2 {printf "- диск рабочего тома: %d GB, занято %s\n", ($2/1048576)+0.5, $5}'
- if pmset -g batt 2>/dev/null | grep -q InternalBattery; then echo "- питание: батарея есть"; else echo "- питание: батареи нет"; fi
- section "Сеть"
- iface=$(route -n get default 2>/dev/null | awk '/interface:/ {print $2}')
- gw=$(route -n get default 2>/dev/null | awk '/gateway:/ {print $2}')
- if [ -n "$iface" ]; then
- kind=$(networksetup -listallhardwareports 2>/dev/null | awk -v i="$iface" '/Hardware Port/ {p=$0; sub(/^Hardware Port: /,"",p)} $0 ~ "Device: "i"$" {print p}')
- echo "- связь: ${kind:-неизвестно} \`$iface\`"
- echo "- адрес: \`$(ipconfig getifaddr "$iface" 2>/dev/null)\` (текущий, ${TODAY})"
- echo "- шлюз: \`$gw\`"
- else
- echo "- маршрута по умолчанию нет: устройство вне сети"
- fi
- echo "- имя Wi-Fi: в опись не пишется"
- vpn=$(ls /Applications 2>/dev/null | grep -i -E 'tailscale|zerotier|wireguard|vpn' | sed 's/\.app$//' | paste -sd ',' - | sed 's/,/, /g')
- echo "- VPN-приложения: ${vpn:-нет}"
- section "Доступы"
- if nc -z localhost 22 2>/dev/null; then echo "- SSH на устройство: порт 22 принимает соединения"; else echo "- SSH на устройство: порт 22 закрыт (Remote Login выключен)"; fi
- if nc -z localhost 5900 2>/dev/null; then echo "- удалённый экран: порт 5900 принимает соединения"; else echo "- удалённый экран: порт 5900 закрыт"; fi
- echo "- пользователь: \`$(id -un)\`"
- if [ -f "$HOME/.ssh/authorized_keys" ]; then
- echo "- вход по ключу: строк в authorized_keys - $(grep -c -v -E '^[[:space:]]*(#|$)' "$HOME/.ssh/authorized_keys")"
- else
- echo "- authorized_keys: нет у этого пользователя"
- fi
- if [ -f "$HOME/.ssh/config" ]; then
- echo "- SSH-алиасы наружу: $(awk 'tolower($1)=="host" {for (i=2;i<=NF;i++) print $i}' "$HOME/.ssh/config" | grep -v '[*?!]' | sort -u | paste -sd ',' - | sed 's/,/, /g')"
- else
- echo "- SSH-алиасов наружу нет (~/.ssh/config отсутствует)"
- fi
- if has tmux; then echo "- tmux: есть"; else echo "- tmux: нет"; fi
- section "Разрешения"
- # sudo -n true ничего не запускает, а только проверяет, пустит ли система без пароля.
- if sudo -n true 2>/dev/null; then echo "- sudo без пароля: да"; else echo "- sudo без пароля: нет"; fi
- echo "- группы: $(id -Gn | sed 's/ /, /g')"
- echo "- шифрование диска: $(fdesetup status 2>/dev/null | head -1)"
- echo "- защита системы: $(csrutil status 2>/dev/null | sed 's/.*: //')"
- nc_add "разрешения macOS (камера, экран, полный доступ к диску)" "база TCC читается только при Full Disk Access у терминала"
- nc_add "правила firewall" "нужны права администратора"
- section "Агенты и инструменты"
- for d in "$HOME/.local/bin" "$HOME/.npm-global/bin" "$HOME/.bun/bin" "$HOME/.cargo/bin" /opt/homebrew/bin; do
- [ -d "$d" ] && PATH="$PATH:$d"
- done
- for c in claude codex gemini opencode hermes; do
- p=$(command -v "$c" 2>/dev/null)
- [ -z "$p" ] && continue
- v=$(t10 "$c" --version | head -1)
- echo "- $c: \`$(echo "$p" | sed "s#^$HOME#~#")\`, версия ${v:-не ответила за 10 с}"
- done
- [ -f "$HOME/.claude/settings.json" ] && echo "- Claude Code: настройки \`~/.claude/settings.json\`"
- [ -f "$HOME/.codex/config.toml" ] && echo "- Codex: настройки \`~/.codex/config.toml\`"
- tools=""
- for c in git gh node python3 uv docker ffmpeg brew; do has "$c" && tools="$tools $c"; done
- echo "- ключевые CLI:${tools:- нет}"
- section "Фоновые службы"
- agents=$(ls "$HOME/Library/LaunchAgents" 2>/dev/null | sed 's/\.plist$//' | paste -sd ',' - | sed 's/,/, /g')
- echo "- свои LaunchAgents: ${agents:-нет}"
- if [ -n "$agents" ]; then
- launchctl list 2>/dev/null | awk 'NR>1 {print $3}' | grep -F -f <(ls "$HOME/Library/LaunchAgents" 2>/dev/null | sed 's/\.plist$//') | sed 's/^/- загружен: /'
- fi
- section "Роли"
- echo "- скрипт роли не снимает: ссылка на отдел-владелец остаётся из текущей описи"
- section "Не проверено"
- printf '%s' "$NOT_CHECKED"
- }
- # Фильтр: MAC, UUID и строки с идентификаторами и секретами в вывод не попадают.
- redact() {
- sed -E 's/([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}/<скрыто>/g; s/[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}/<скрыто>/g' |
- grep -v -i -E 'serial|uuid|udid|bssid|ssid:|passw|token|secret|api.?key|private key'
- }
- snapshot 2>/dev/null | redact
skills/it-ram-doctor/scripts/tails-macos.sh · Bundled script · 229 lines
- #!/bin/bash
- # Хвосты процессов на macOS: кандидаты, которые держат память впустую. Только чтение, без sudo, ничего не убивает.
- # Вывод — markdown-таблица кандидатов и итог по памяти; решение и убийство — по ../SKILL.md.
- # Удалённо: ssh -o BatchMode=yes -o ConnectTimeout=8 <алиас> 'bash -s' < tails-macos.sh
- # Совместим с bash 3.2 (системный bash macOS).
- TODAY=$(date '+%Y-%m-%d %H:%M')
- ME=$(id -u)
- TMP=$(mktemp -d "${TMPDIR:-/tmp}/tails.XXXXXX") || exit 1
- trap 'rm -rf "$TMP"' EXIT
- # Снимок процессов: поля отдельно от строки запуска (в путях бывают пробелы).
- ps -axww -o pid=,ppid=,uid=,rss=,etime=,stat=,comm= >"$TMP/ps" 2>/dev/null
- ps -axww -o pid=,args= >"$TMP/args" 2>/dev/null
- # PID служб gui-домена: их держит сам launchd, это не хвосты.
- launchctl print "gui/$ME" 2>/dev/null |
- awk '/^\tservices = \{/ {s=1; next} s && /^\t\}/ {exit} s && $1 ~ /^[0-9]+$/ && $1 > 0 {print $1}' >"$TMP/svc"
- report() {
- printf '# Хвосты процессов: %s\n\n' "$(scutil --get ComputerName 2>/dev/null)"
- printf 'Снято: %s, ' "$TODAY"
- if [ -n "$SSH_CONNECTION" ]; then printf 'по SSH, '; else printf 'локально, '; fi
- printf 'пользователь `%s`, без sudo. Скрипт ничего не убивает.\n\n' "$(id -un)"
- awk -v SELF="$$" -v ME="$ME" -v TASK_HOME="$HOME" -v ARGS="$TMP/args" -v SVC="$TMP/svc" -v SUMF="$TMP/sum" '
- function secs(e, d, n, p, s) { # [[dd-]hh:]mm:ss -> секунды
- d = 0; if (index(e, "-")) { d = substr(e, 1, index(e, "-") - 1); e = substr(e, index(e, "-") + 1) }
- n = split(e, p, ":"); s = 0
- if (n == 3) s = p[1]*3600 + p[2]*60 + p[3]; else if (n == 2) s = p[1]*60 + p[2]; else s = p[1]
- return d*86400 + s
- }
- function age(s) {
- if (s >= 86400) return int(s/86400) " д " int((s%86400)/3600) " ч"
- if (s >= 3600) return int(s/3600) " ч"
- return int(s/60) " мин"
- }
- function base(p, n, a) { n = split(p, a, "/"); return a[n] }
- function tilde(p) { if (index(p, TASK_HOME) == 1) return "~" substr(p, length(TASK_HOME) + 1); return p }
- function isclaude(pid, a, c) {
- a = args[pid]; c = comm[pid]
- # Desktop layouts with and without the content-hash directory, plus standalone CLI.
- return (c ~ /\/claude-code\/[^\/]+\/([^\/]+\/)?claude\.app\/Contents\/MacOS\/claude$/ ||
- a ~ /^([^ ]*\/)?claude( |$)/ || c ~ /\/\.local\/share\/claude\/versions\/[^\/ ]+$/)
- }
- function mdsafe(s) { gsub(/\|/, "/", s); gsub(/`/, "", s); return s }
- # Короткое имя: приложение или argv0 и первые аргументы.
- function short(pid, a, n, w, i, s) {
- a = args[pid]
- if (match(a, /\/claude-code\/[^\/]+\//)) return "claude CLI " substr(a, RSTART + 13, RLENGTH - 14)
- if (match(a, /^\/Applications\/[^\/]+\.app\//)) {
- s = substr(a, 15, RLENGTH - 15)
- w = substr(a, RLENGTH + 1); sub(/ --.*/, "", w)
- return mdsafe(s ": " base(w) (index(a, " --") ? " …" : ""))
- }
- n = split(a, w, " "); s = base(w[1])
- for (i = 2; i <= n && i <= 4; i++) s = s " " tilde(w[i])
- if (n > 4) s = s " …"
- if (length(s) > 80) s = substr(s, 1, 77) "…"
- return mdsafe(s)
- }
- function isdev(pid, a) {
- a = args[pid]
- return (a ~ /http\.server|(^|[\/ ])vite( |$)|npm run dev|pnpm (run )?dev|bun (run )?dev|next dev|astro dev|webpack.*serve/)
- }
- function ports(pid, c, l, out) { # слушающие TCP-порты процесса
- out = ""; c = "lsof -nP -a -p " pid " -iTCP -sTCP:LISTEN -Fn 2>/dev/null"
- while ((c | getline l) > 0) if (l ~ /^n/) { sub(/.*:/, "", l); if (index(" " out " ", " " l " ") == 0) out = out (out ? " " : "") l }
- close(c); return out
- }
- function cwd(pid, c, l, out) {
- out = ""; c = "lsof -a -p " pid " -d cwd -Fn 2>/dev/null"
- while ((c | getline l) > 0) if (l ~ /^n/) out = substr(l, 2)
- close(c); return out
- }
- function session(pid, c, l, out) { # из окружения берём только id сессии, остальное не печатаем
- out = ""; c = "ps eww -o command= -p " pid " 2>/dev/null | tr \" \" \"\\n\" | grep \"^CLAUDE_CODE_HOST_SESSION_ID=\" | head -1"
- if ((c | getline l) > 0) { sub(/^CLAUDE_CODE_HOST_SESSION_ID=/, "", l); out = l }
- close(c); return out
- }
- function bundle_exe(app, c, l) { # главный бинарник приложения по Info.plist
- if (app in exe_of) return exe_of[app]
- l = ""; c = "defaults read \"/Applications/" app ".app/Contents/Info\" CFBundleExecutable 2>/dev/null"
- c | getline l; close(c)
- if (l == "") l = app
- exe_of[app] = l; return l
- }
- # Все потомки pid: в список D через пробел.
- function desc(pid, q, h, t, x, c, out) {
- out = ""; q[1] = pid; h = 1; t = 1
- while (h <= t) { x = q[h++]; for (c in ppid) if (ppid[c] == x) { q[++t] = c; out = out " " c } }
- return out
- }
- function row(pid, cls, why) {
- if (pid in shown) return
- shown[pid] = 1; nrow++
- printf "| %s | %d | %s | %s | `%s` | %s |\n", pid, rss[pid]/1024 + 0.5, age(et[pid]), cls, short(pid), why
- sum += rss[pid]
- }
- FILENAME == SVC { svc[$1] = 1; next }
- FILENAME == ARGS { p = $1; sub(/^ *[0-9]+ /, ""); args[p] = $0; next }
- {
- p = $1; ppid[p] = $2; uid[p] = $3; rss[p] = $4; et[p] = secs($5); st[p] = $6
- c = $0; sub(/^ *[0-9]+ +[0-9]+ +[0-9]+ +[0-9]+ +[^ ]+ +[^ ]+ +/, "", c); comm[p] = c
- pids[++np] = p
- }
- END {
- # Текущая оболочка и её предки (в т.ч. сессия, из которой запущен скрипт).
- x = SELF; while (x != "" && x != "0" && !(x in anc)) { anc[x] = 1; x = ppid[x] }
- for (i = 1; i <= np; i++) {
- p = pids[i]; a = args[p]
- if (a == "") a = comm[p]
- args[p] = a
- app = ""
- if (match(a, /^\/Applications\/[^\/]+\.app\//)) app = substr(a, 15, RLENGTH - 19)
- appof[p] = app
- if (app != "") running[a] = 1
- if (app != "" && (p in svc)) svcapp[app] = 1 # у приложения есть живая служба launchd: его помощники законны
- if (comm[p] ~ /^\//) running[comm[p]] = 1
- else if (comm[p] !~ /\//) running_name[comm[p]] = 1 # некоторые GUI-процессы дают только имя, например ZCode
- }
- for (i = 1; i <= np; i++) {
- p = pids[i]
- if (st[p] ~ /Z/) { if (et[p] >= 60) zomb[p] = 1; continue } # моложе минуты — обычный переходный зомби (sshd и т.п.)
- if (uid[p] != ME || (p in anc) || (p in svc)) continue
- if (comm[p] ~ /^\/(System|usr\/libexec|usr\/sbin|sbin)\// || args[p] ~ /^\/(System|usr\/libexec|usr\/sbin|sbin)\//) continue
- if (appof[p] == "Claude") continue
- a = args[p]
- if (isclaude(p)) { claude[p] = 1; continue }
- app = appof[p]
- if (app != "") {
- # Корень хвоста — только у launchd (PPID 1): помощник под живым процессом (cua_node у codex) хвостом не считается.
- # Расширения .appex система поднимает без приложения — тоже не хвост.
- if (ppid[p] != 1 || (app in svcapp) || a ~ /\.appex\//) continue
- e = "/Applications/" app ".app/Contents/MacOS/" bundle_exe(app)
- alive = (bundle_exe(app) in running_name)
- for (r in running) if (r == e || index(r, e " ") == 1) { alive = 1; break }
- if (!alive) { tail[p] = app }
- continue
- }
- if (ppid[p] == 1) {
- if (base(comm[p]) ~ /^(omp|bun)$/ || a ~ /^([^ ]*\/)?(omp|bun)( |$)/) orphan[p] = "omp/bun-воркер"
- else if (a ~ /Chrome for Testing|\/puppeteer\/|ms-playwright\/|chrome-headless-shell/) orphan[p] = "Chrome for Testing / puppeteer"
- else if (a ~ /mcp|modelcontextprotocol|npm exec|(^|\/)npx /) orphan[p] = "MCP-сервер / npx"
- else if (a ~ /^([^ ]*\/)?(grok|codex)( |$|-)/) orphan[p] = "grok/codex без родителя"
- else if (isdev(p) && et[p] > 86400) dev[p] = 1
- }
- }
- print "| PID | RSS MB | возраст | класс | процесс | причина и что умрёт вместе |"
- print "|---|---|---|---|---|---|"
- # claude-сессии: решение об idle — агент по list_sessions.
- for (p in claude) {
- s = session(p); d = desc(p); n = split(d, dl, " "); kids = ""; krss = 0; devs = ""
- delete cnt
- for (j = 1; j <= n; j++) {
- k = dl[j]; krss += rss[k]
- if (isdev(k)) { pt = ports(k); devs = devs (devs ? "; " : "") short(k) (pt ? " порт " pt : "") }
- w = args[k]; split(w, ww, " "); b = base(ww[1])
- if (b ~ /^(node|python[0-9.]*|Python|bun|npm|npx)$/ && ww[2] != "") b = b " " base(ww[2])
- if (appof[k] != "") b = appof[k] ".app"
- else if (w ~ /Chrome for Testing/) b = "Chrome for Testing"
- cnt[b]++
- }
- for (b in cnt) kids = kids (kids ? ", " : "") mdsafe(b) (cnt[b] > 1 ? "×" cnt[b] : "")
- why = "сессия `" (s ? s : "не найдена") "` · cwd `" mdsafe(tilde(cwd(p))) "` · дочерних " n
- if (n) why = why " (" int(krss/1024 + 0.5) " MB): " kids
- if (devs != "") why = why " · **dev-серверы умрут вместе:** " devs
- row(p, "claude-сессия", why)
- }
- # Хвосты закрытых приложений и всё, что под ними.
- for (p in tail) {
- row(p, "хвост закрытого приложения", tail[p] ".app закрыто, главный бинарник `" bundle_exe(tail[p]) "` не запущен")
- d = desc(p); n = split(d, dl, " ")
- for (j = 1; j <= n; j++) if (!(dl[j] in anc)) row(dl[j], "хвост закрытого приложения", "внутри хвоста " tail[p] ".app (PID " p ")")
- }
- # Сироты: дубли по одинаковой строке запуска.
- for (p in orphan) dup[args[p]]++
- for (p in orphan) {
- why = orphan[p] ", PPID 1"
- if (dup[args[p]] > 1) why = why " · **дубль** (" dup[args[p]] " одинаковых)"
- row(p, "сирота", why)
- d = desc(p); n = split(d, dl, " ")
- for (j = 1; j <= n; j++) if (!(dl[j] in anc)) row(dl[j], "сирота", "внутри сироты PID " p)
- }
- for (p in dev) { pt = ports(p); row(p, "dev-сервер", "PPID 1, старше суток" (pt ? ", порт " pt : "") " — только показать, спросить") }
- for (p in zomb) {
- nz++; q = ppid[p]
- printf "| %s | 0 | %s | зомби | `%s` | родитель PID %s `%s` — память не держит, убирается родителем |\n", p, age(et[p]), short(p), q, short(q)
- }
- if (nrow + nz == 0) print "| — | — | — | — | — | кандидатов нет |"
- printf "%d %d\n", sum/1024 + 0.5, nrow + nz > SUMF
- }' "$TMP/svc" "$TMP/args" "$TMP/ps"
- # Текущая сессия исключена из таблицы, но названа: её не трогать.
- x=$$
- while [ -n "$x" ] && [ "$x" != "0" ] && [ "$x" != "1" ]; do
- a=$(ps -o args= -p "$x" 2>/dev/null)
- case "$a" in
- */claude-code/*/claude.app/Contents/MacOS/claude*|claude\ *|*/.local/bin/claude*|*/.local/share/claude/versions/*)
- s=$(ps eww -o command= -p "$x" 2>/dev/null | tr ' ' '\n' | grep '^CLAUDE_CODE_HOST_SESSION_ID=' | head -1 | sed 's/^CLAUDE_CODE_HOST_SESSION_ID=//')
- printf '\nТекущая сессия (исключена, не трогать): PID %s, `%s`.\n' "$x" "${s:-без id}"
- break ;;
- esac
- x=$(ps -o ppid= -p "$x" 2>/dev/null | tr -d ' ')
- done
- set -- $(cat "$TMP/sum" 2>/dev/null)
- printf '\n## Итог\n\n'
- echo "- кандидатов: ${2:-0}, их RSS вместе: ${1:-0} MB (без дочерних claude-сессий)"
- echo "- своп: $(sysctl -n vm.swapusage 2>/dev/null)"
- echo "- $(memory_pressure 2>/dev/null | tail -1)"
- }
- # Фильтр последней линии: MAC и UUID скрыты, кроме id сессии `local_<uuid>`; значения секретов в аргументах скрыты.
- redact() {
- perl -pe 's/\b([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}\b/<скрыто>/g;
- s/(?<!local_)\b[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}\b/<скрыто>/g;
- s/((?:token|secret|passw\w*|api[_-]?key|auth)\w*[=: ]+)[^ |`]+/$1<скрыто>/gi'
- }
- report 2>/dev/null | redact
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.