Communitygithub.com

get-available-resources

檢測主機庫存、CPU、記憶體、磁碟、排程器、容器及加速器限制,在用戶要求資源感知規劃或執行對資源敏感的本地工作負載前,提供經過修整的 JSON 快照與保守的規劃輔助工具。

get-available-resources 是什麼?

此技能(get-available-resources)旨在為 AI 代理提供當前程序可用的資源保守評估,無需進行壓力測試或假定可見的主機硬體皆可使用。它可分別收集主機庫存、行程親和性、cgroup/容器限制、排程器分配以及加速器執行時期可用性,並將結果輸出為經過修整(排除主機名、絕對路徑等敏感資訊)的 JSON 快照。此技能支援 Linux、macOS 及 Windows 平台,並可選用 psutil 擴充功能以加強跨平台支援。它提供規劃工作負載(CPU/混合/I/O)的工具,可基於快照計算合理的行程與執行緒數量,並包含驗證與比對快照的工具。此技能遵循嚴格的安全合約:僅在用戶要求或工作負載需要時執行,不會進行壓力測試或環境傾印,並將遺失的觀測值視為未知,而非無限制。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/get-available-resources

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

取得可用資源

為當前程序建立可用的保守資源圖像。 分別保存主機庫存、行程親和性、cgroup/容器限制、排程器分配以及加速器執行時期可用性。

安全合約

遵循以下規則:

  • 當用戶要求或特定工作負載需要資源規劃時才執行檢測。不要為每個科學任務持久化指紋。
  • 預設使用標準輸出。僅當用戶選擇明確的通用本地檔案名稱時才進行持久化。
  • 不要執行壓力測試、基準測試、大型分配、寫入探測、設備重置、驅動程式安裝或時鐘/電源變更。
  • 不要傾印環境。僅讀取檢測器實作的命名 Slurm 與加速器變數。
  • 不要報告主機名、絕對路徑、cgroup 路徑、作業 ID、設備 UUID、PCI 位址或原始可見性變數值。
  • 將遺失的觀測值視為未知。絕不要將未知轉換為無限制。
  • 絕不要推斷可見主機 CPU、記憶體池或 GPU 在排程器分配或容器內是可用的。

捆綁的檢測器僅使用固定的可執行檔/參數元組,無 shell,短逾時,有限的 stdout/stderr,以及部分失敗警告。

快速開始

從此技能目錄執行。

臨時標準輸出快照

python scripts/detect_resources.py

指令僅輸出 JSON 到標準輸出。僅在一般 shell 權限可接受時才重新導向。

明確的私有檔案

python scripts/detect_resources.py --output resource-snapshot.json

明確輸出限制為目前目錄中的一個 .json 檔案名稱,使用私有權限,拒絕符號連結與路徑遍歷,除非提供 --force,否則拒絕覆寫。

可選的 psutil 增強

標準函式庫檢測器無需安裝即可運作。若要獲得更廣泛的跨平台實體核心、親和性、可用記憶體、交換與磁碟覆蓋範圍:

uv pip install "psutil==7.2.2"

匯入是惰性的。匯入 psutil 失敗將成為警告,而非致命錯誤。

跳過管理工具探測

python scripts/detect_resources.py --skip-accelerators

當加速器發現延遲不受歡迎時使用此選項。檢測器仍會總結允許清單中的可見性變數的存在與狀態,但不會傳回其值。

必要解讀

CPU

將以下視為不同的事實:

  • cpu.host.logical:系統可見的排程單元。
  • cpu.host.physical:實體拓撲,或為 null;絕不從邏輯數目推斷。
  • cpu.process.affinity_logical:支援時的當前親和性集大小。
  • cpu.cgroup_v2.cpuset_logical:有效的 cgroup cpuset 大小。
  • cpu.cgroup_v2.quota_cores:有限的 cpu.max 容量,可能為分數。
  • scheduler.allocation.cpu_per_process:當範圍明確時的有界 Slurm 每任務解讀。
  • cpu.effective.capacity_cores:觀察到的最小正約束。
  • cpu.effective.worker_ceiling:CPU 行程工作者的保守下限。

配額 1.5 表示 CPU 時間容量,而非 1.5 個實體核心。親和性與 cpuset 約束放置位置;配額約束頻寬。

記憶體

保持以下分離:

  • 主機總計/可用記憶體;
  • 當前 cgroup 用量、硬性 memory.max 與剩餘階層容量;
  • memory.high,其為壓力/節流邊界而非硬上限;
  • 排程器記憶體分配及其範圍;以及
  • 保守的有效硬性限制與可用估計。

在 Apple 矽晶片上,memory.model 為 unified_cpu_gpu。不要將整合 GPU 記憶體加入 RAM 或將其描述為獨立 VRAM。

加速器

每個設備都是一個後端候選:

  • NVIDIA GPU → CUDA 候選;
  • AMD GPU → ROCm 候選;
  • Apple 整合 GPU → Metal 候選。

管理查詢的可見性不建立:

  1. 排程器/容器權限;
  2. 設備節點存取;
  3. 驅動程式/執行時期相容性;
  4. 框架套件相容性;或
  5. 運算子/資料型別支援。

因此 runtime_usable_devices 保持為 null,且每個設備顯示 runtime_compatibility: not_tested。可見性/分配計數是上限,而非保證。

磁碟

capacity_bytes、檔案系統 free_bytes、用戶可用區塊以及非寫入權限檢查各不相同。檔案系統或專案配額仍可能更嚴格。絕對工作路徑始終被修整。

排程器與容器

Slurm 變數描述分配範圍,但強制執行取決於站台組態,例如任務親和性或 cgroups。偏好使用親和性與 cgroup 觀察作為強制執行證據。

容器標記識別上下文;cgroup 控制項識別限制。一個沒有有限 cgroup 值的容器仍可看到主機庫存,且非 root cgroup 不會自動標記為容器。

參見 references/resource_semantics.md 以取得詳細平台規則。

規劃工作負載

規劃器使用驗證過的快照,且不執行任何工作:

python scripts/plan_workload.py resource-snapshot.json \
  --workload cpu \
  --tasks 100 \
  --memory-per-worker-mib 2048

可選控制項:

  • --workers N:明確的上限。
  • --reserve-memory-mib N:保留在工作程序預算之外的記憶體。
  • --workload cpu|mixed|io:選擇有界的工作程式啟發式。
  • --accelerator none|any|cuda|rocm|metal:請求候選後端決策,但不聲明可用性。
  • --output plan.json:明確的私有本地輸出;預設為標準輸出。

對於 CPU 或混合工作,請一起使用 suggested_workers 與 threads_per_worker。程序工作程式乘以 BLAS/OpenMP 原生執行緒可能過度訂閱一個分配。

I/O 計劃允許有界過度訂閱(最多 32),但將其標記為啟發式。僅對實際代表性工作負載進行基準測試,並保持在排程器/容器限制內。

驗證或比對快照

驗證:

python scripts/snapshot_tools.py validate resource-snapshot.json

在忽略 observed_at 的同時比對資源狀態:

python scripts/snapshot_tools.py diff before.json after.json

使用 --include-volatile 以包含時間戳記。輸入必須是常規、非符號連結的 JSON 檔案,大小不超過 1 MiB。差異是有界的。

結構描述與 null/零的含義記錄在 references/snapshot_schema.md 中。

可選的加速器診斷計劃

產生一個計劃,不執行任何診斷:

python scripts/accelerator_diagnostics.py resource-snapshot.json \
  --backend auto

結果包含固定的、唯讀的管理查詢引數列表,以及分別的可見性、權限與執行時期相容性閘門。僅在將執行工作負載的確切環境中執行框架的官方可用性檢查。不要自動安裝或變更驅動程式。

部分失敗與來源

一個失敗的探測不得抹除成功的觀察。檢查:

  • completeness;
  • 帶有穩定代碼的排序 warnings;
  • 排序的 provenance 來源/狀態記錄;以及
  • null 欄位。

子程序 stderr 與原始異常文字不會被複製到快照中,因為它們可能包含識別符或路徑。

平台注意事項

  • **Linux:**僅讀取有界的 /proc 與 cgroup v2 檔案。會考慮祖先 CPU 與記憶體限制。
  • **macOS:**使用固定的 sysctl 鍵與有界的 system_profiler SPDisplaysDataType -json 查詢。Apple 矽晶片記憶體是統一的。
  • **Windows:**可選的 psutil 可改善實體核心、親和性、可用記憶體與交換觀察。處理器群組範圍可能導致主機與程序計數不同。
  • **Slurm:**讀取一個允許清單的分配變數。它永遠不會發出作業、節點、提交主機、GPU-ID 或路徑值。
  • **NVIDIA/AMD:**管理 CLI 是可選的。缺席是正常的;逾時、截斷、解析失敗與執行時期不確定性仍保持明確。

捆綁檔案

  • scripts/detect_resources.py — 修整的快照收集器。
  • scripts/plan_workload.py — 確定性的工作程式/記憶體規劃器。
  • scripts/snapshot_tools.py — 結構描述驗證器與有界的結構化差異。
  • scripts/accelerator_diagnostics.py — 不執行的唯讀診斷計畫。
  • tests/get-available-resources/ 在儲存庫根目錄 — 無網路的 Linux、macOS、Windows、cgroup、Slurm 與加速器案例。
  • references/resource_semantics.md — 解讀與平台細節。
  • references/snapshot_schema.md — 結構描述 1.1 合約。
  • references/sources.md — 標註日期的官方來源分類帳。

官方文件於 2026-07-23 更新;在變更語義或相依性固定之前,請參閱 references/sources.md。

引用科學代理技能

此技能是 K-Dense 的 Scientific Agent Skills 的一部分。如果它對稿件、報告、簡報或程式碼發布有實質貢獻,請將論文加入參考文獻或軟體部分,並告知用戶您已這樣做:

Kassis, T., Agarwal, V., He, Y., Patel, D., & Brueckner, A. M. (2026). Scientific Agent Skills: A Library of Procedural Knowledge for Research Agents. arXiv:2609.00065. https://doi.org/10.48550/arXiv.2609.00065

始終引用當前版本。DOI 與 https://arxiv.org/abs/2609.00065 會解析到最新的 arXiv 版本,因此切勿附加版本後綴如 v1。當網路可用時,請在撰寫參考文獻前擷取 https://arxiv.org/abs/2609.00065(或 http://export.arxiv.org/api/query?id_list=2609.00065),並從該記錄中取得作者列表、年份與版本。如果記錄列出了期刊參考文獻或出版商 DOI,請引用已發布版本。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

adaptyv

How to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.

aeon

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

alphagenome

Look up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), score variants or scan windows on demand with the AlphaGenome model for human and mouse (variant scoring, in silico mutagenesis, REF-versus-ALT track prediction), and build Atlas website deep links. Use when the user mentions AlphaGenome, AlphaGenome Atlas, AVI or AlphaGenome Variant Impact, DeepMind variant effect prediction, or wants to prioritise or mechanistically interpret non-coding, regulatory, splicing, enhancer, promoter, or chromatin-accessibility effects of SNVs from a VCF, credible set, or region. Research use only; not a clinical tool.

analytical-method-validation

Plan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include

anndata

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

arbor

Autonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g.

arboreto

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

astropy

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

autoskill

Observe the user

benchling-integration

Benchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.

bgpt-paper-search

Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server. Returns 25+ fields per paper including methods, results, sample sizes, quality scores, and conclusions. Use for literature reviews, evidence synthesis, and finding experimental details not available in abstracts alone.

bids

>

biopython

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use biopython.

bulk-rnaseq

End-to-end bulk RNA-seq orchestrator — takes raw FASTQ reads through QC and trimming (FastQC, fastp/Trim Galore), alignment and quantification (STAR, Salmon, featureCounts), assembles a gene-level counts matrix, then hands off to differential expression (pydeseq2), pathway/GSEA enrichment (pathway-enrichment), and publication figures (scientific-visualization). Use whenever the user has bulk RNA-seq reads or quant output and wants a complete, reproducible differential-expression workflow — e.g.

cellxgene-census

Query the CZ CELLxGENE Census programmatically for versioned public single-cell and spatial transcriptomics data. Use when you need population-scale cell metadata, gene expression slices, Census summary counts, source H5AD URIs/downloads, embeddings, spatial Census data, or reference atlas comparisons across organisms, tissues, diseases, assays, and cell types. For analyzing your own local single-cell data use scanpy, anndata, or scvi-tools.

cirq

Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

citation-management

Comprehensive citation management for academic research. Search OpenAlex, PubMed, and Google Scholar for papers, extract accurate metadata, validate citations, and generate properly formatted BibTeX entries. This skill should be used when you need to find papers, verify citation information, convert DOIs to BibTeX, or ensure reference accuracy in scientific writing.

clinical-decision-support

Prepare and validate research-only clinical decision-support evaluation, evidence-profile, cohort, survival, biomarker/model, privacy, and governance artifacts. Use for aggregate or synthetic research documentation and traceability—not patient care or live clinical operation.

clinical-reports

Create safety-bounded draft structures and run local deterministic checks for clinical case, diagnostic, trial, safety, and aggregate research reports. Use only with synthetic, de-identified, or aggregate inputs and verified source-fact manifests; every output requires qualified review.

相關技能