Official agent skill

Add Torch Shapes Example

by facebook in facebook/pyrefly

A skill your agent uses when adding a new PyTorch model to Pyrefly's shape-tracking example corpus under tensor-shapes/pyrefly-torch-stubs/examples — i.e.

OfficialMITAuto-check passedAI & LLM Engineering

Install Add Torch Shapes Example

skills CLI
$ npx skills add facebook/pyrefly --skill add-torch-shapes-example -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install facebook/pyrefly add-torch-shapes-example --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/facebook/pyrefly.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/add-torch-shapes-example .claude/skills/add-torch-shapes-example && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
add-torch-shapes-example
GitHub stars
7.1k
Token cost
~1.3k tokens
SKILL.md length
619 words
Files
1
Skills in repo
6
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when adding a new PyTorch model to Pyrefly's shape-tracking example corpus under tensor-shapes/pyrefly-torch-stubs/examples — i.e.

  • Works in 3 steps: Run the port → Place the file → Verify (the fbsource commands)
  • Adding a new PyTorch model to Pyreflys shape-tracking example corpus under tensor-shapes/pyrefly-torch-stubs/examples — i.e
  • SKILL.md covers 1. Run the port, 2. Place the file, 3. Verify (the fbsource… and If you hit a wrong or missing…
  • Calls python3

What it does

Add Torch Shapes Example is an agent skill from facebook/pyrefly, published by the product's own GitHub organization. Use when adding a new PyTorch model to Pyrefly's shape-tracking example corpus under tensor-shapes/pyrefly-torch-stubs/examples — i.e. importing a model as a tested, corpus-quality reference port. This is maintainer-facing fbsource work. For porting your own model elsewhere, use the porting skill directly; for fixing a wrong/missing shape rule, use modify-shaped-array-dsl.

Its SKILL.md is about 1.3k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering Deep learning. It works with PyTorch. The repository describes itself as: A fast type checker and language server for Python. The licence is MIT.

When your agent uses it

  • Adding a new PyTorch model to Pyreflys shape-tracking example corpus under tensor-shapes/pyrefly-torch-stubs/examples — i.e
  • Tasks that involve Deep learning

Example prompts

  • “/add-torch-shapes-example”

Requirements

  • Python 3

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Run the port
  2. Place the file
  3. Verify (the fbsource commands)

What it can do on your machine

Read from SKILL.md and the folder at commit 6bc6ea9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • python3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Add Torch Shapes Example loads about 1.3k tokens when it runs. Until then it costs about 100 tokens; SKILL.md has 619 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~100
When it runs · the whole SKILL.md, loaded when a task matches
~1.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from facebook/pyrefly at commit 6bc6ea9, republished under its MIT licence (© facebook). 619 words, ~1,346 tokens.

Download SKILL.mdSave it as .claude/skills/add-torch-shapes-example/SKILL.md (or your agent's skills folder).
name
add-torch-shapes-example
description
Use when adding a new PyTorch model to Pyrefly's shape-tracking example corpus under tensor-shapes/pyrefly-torch-stubs/examples — i.e. importing a model as a tested, corpus-quality reference port. This is maintainer-facing fbsource work. For porting your own model elsewhere, use the porting skill directly; for fixing a wrong/missing shape rule, use modify-shaped-array-dsl.

You are importing a PyTorch model into Pyrefly's example corpus at tensor-shapes/pyrefly-torch-stubs/examples/. This is the contribution case the porting skill describes: these ports are tested reference material that others read to learn the patterns, so produce its fuller deliverable — paste every artifact (audit table, per-local reveal_type dumps, typed-interface receipts, exhaustive assert_type coverage, completion report) in full, not just the annotated model.

Why these ports matter. They demonstrate what happens when you write a real PyTorch model with tensor shape types. Record the upstream repository and revision, exact files or dependency closure, concrete configuration, entry points, and train/eval/cache/export modes included. "Complete" means complete inside that declared boundary; list any omitted wrapper or mode rather than calling a representative core the full upstream model.

Start from evidence, not a blank page. Before editing, skim two or three existing examples with the closest architecture and mine the upstream source for shape comments, docstrings, reshape/einsum equations, runtime assertions, and tests. Treat that evidence as a hypothesis to verify with Pyrefly, not text to copy. The existing ports demonstrate that substantial real models normally reach useful shape coverage after a few checker-guided iterations.

Improving the stubs is the point, not a side quest. First distinguish a true stub gap from an unavailable overlay symbol, Any, a declared gradual return, third-party code, or unrepresentable dynamic construction. Fix genuine general stub gaps in the corpus case rather than hiding them in the model. A corpus port may retain a narrow precise cast, typed interface, or gradual boundary for heterogeneous containers, dynamic factories, mutable caches, or untyped external backends. Preserve every known public dimension and document the boundary. Propose, but do not perform, a runtime rewrite unless the user separately requests it.

1. Run the port

Do the actual porting by reading and following the add-shape-types-to-torch-model skill's SKILL.md (in tensor-shapes/skills/add-shape-types-to-torch-model/) end to end — its gated workflow (pre-flight gates → per-module loop → verification) is the algorithm.

The general skill has two setup choices; for corpus work both are already resolved, so do not stop to ask: use the Buck check below, and treat stub improvements as in scope. Produce all of the corpus artifacts it requests.

Show full SKILL.md (263 more words)Show less

2. Place the file

Write the port at tensor-shapes/pyrefly-torch-stubs/examples/<model>.py. Every class, function, method, entry point, configuration, and mode inside the declared upstream boundary belongs in the port. Do not silently shrink that boundary when a difficult construct appears.

3. Verify (the fbsource commands)

The porting skill's verification phase tells you to run verify_port.sh and the actual Pyrefly check. Run these commands from the fbcode/pyrefly checkout root. First ensure the shared tensor-shapes virtual environment exists; add --fwdproxy when the host needs it:

bash
python3 tensor-shapes/bootstrap_venv.py
buck build fbcode//pyrefly/tensor-shapes:torch-stubs-search-path
SEARCH_ROOT="$(buck targets --show-output fbcode//pyrefly/tensor-shapes:torch-stubs-search-path | awk '{print $2}')"
VENV="${TENSOR_SHAPES_VENV:-$HOME/.tensor-shapes-venv}"
SITE="$("$VENV/bin/python" -c 'import site; print(site.getsitepackages()[0])')"
buck run fbcode//pyrefly:pyrefly -- check --config /dev/null \
  --python-version 3.13 --search-path "$SEARCH_ROOT" \
  --site-package-path "$SITE" \
  tensor-shapes/pyrefly-torch-stubs/examples/<model>.py

If the model imports einops, also pass --search-path tensor-shapes/pyrefly-einops-stubs; otherwise an einops call can silently appear to preserve its input shape. The result must be 0 errors, with no leftover reveal_type.

Then run the corpus test target so the new example is covered by CI and checked with the real Torch fallback modules:

bash
python3 tensor-shapes/pyrefly-torch-stubs/run_pyrefly.py --buck --suite torch-examples

If you hit a wrong or missing shape

When shape precision is missing, first distinguish among an unavailable symbol in the partial overlay, Any, a declared gradual Tensor, a third-party boundary, and a true stub-signature gap. Add or refine a general stub when that is the right fix. A corpus port may retain a documented boundary for unrepresentable dynamic construction; it should not hide an easily fixable stub gap.

A wrong shape (Pyrefly computes a concrete shape that's incorrect) or a missing shape that can't be expressed by a stub signature alone is a shape-DSL change: see the modify-shaped-array-dsl skill. That skill insists on unit-testing the DSL logic, not just relying on this example to exercise it. Don't reach for the DSL for shapes a stub signature could express.

© facebook, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/add-torch-shapes-example of facebook/pyrefly.

Open the folder on GitHubat commit 6bc6ea9

Compare with similar skills

Add Torch Shapes Example next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Add Torch Shapes Example compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Add Torch Shapes Example this skillfacebook/pyrefly7.1k—~1.3kAutomated safety check: PassMIT
Add Uint Supportpytorch/pytorch104k2 repos~2.3kAutomated safety check: PassCustom licence
CLIP Image-Text MatchingOrchestra-Research/AI-Research-SKILLs13k8 repos~1.7kAutomated safety check: PassMIT
Interview Cheatsheetwanshuiyin/ARIS-in-AI-Offer5801 repos~3.4kAutomated safety check: NotesMIT
Ghstack CIpytorch/pytorch104k—~1.4kAutomated safety check: PassCustom licence
MUSA GPU Training Optimizeropen-infra-skills/infra-skills141—~1.7kAutomated safety check: PassApache-2.0

Similar skills

  • Add Uint Support

    pytorch/pytorch

    Add unsigned integer (uint) type support to PyTorch operators by updating ATDISPATCH macros.

    104k GitHub starsUsed in 2 repos~2.3k tokens
    AI & LLM EngineeringAuto-check passed
  • CLIP Image-Text Matching

    Orchestra-Research/AI-Research-SKILLs

    Explains OpenAI's CLIP model for zero-shot image classification, image-text similarity, semantic image search and content moderation, with install steps and code patterns.

    13k GitHub starsUsed in 8 repos~1.7k tokens
    AI & LLM EngineeringAuto-check passed
  • Interview Cheatsheet

    wanshuiyin/ARIS-in-AI-Offer

    Generate a long-form Chinese interview-prep cheat sheet on a specific ML/LLM topic — formulas with derivations, from-scratch PyTorch code, comparison tables, and 25 高频面试题 (L1 必会 / L2 进阶 / L3 顶级 lab).

    580 GitHub starsUsed in 1 repo~3.4k tokens
    AI & LLM EngineeringAuto-check: notes
  • Ghstack CI

    pytorch/pytorch

    Manage CI for PyTorch ghstack stacks by running CI where its results are useful now and deferring other PRs with [no-ci].

    104k GitHub stars~1.4k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • MUSA GPU Training Optimizer

    open-infra-skills/infra-skills

    Profiles, benchmarks and tunes AI training workloads on Moore Threads MUSA GPUs with a measurement-first process that keeps model behavior unchanged.

    141 GitHub stars~1.7k tokensUpdated 3 mo ago
    AI & LLM EngineeringAuto-check passed
  • Depth Estimation

    SharpAI/DeepCamera

    Real-time depth map privacy transforms using Depth Anything v2 (CoreML + PyTorch)

    3.1k GitHub stars~945 tokensUpdated 21 days ago
    AI & LLM EngineeringAuto-check passed

More from facebook/pyrefly

  • Benchmark Pyrefly

    facebook/pyrefly

    Official

    Run Pyrefly benchmarks locally via Buck or Cargo, including PyTorch real-world LSP benchmarks.

    7.1k GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Modify Shaped Array Dsl

    facebook/pyrefly

    Official

    A skill your agent uses when Pyrefly computes a wrong tensor shape (or is missing one that can't be expressed in a stub signature) and you need to add or fix a shape-DSL rule.

    7.1k GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Official

    Port a PyTorch model to use pyrefly's tensor shape type system (Tensor[[B, C, H, W]], Int[T]).

    7.1k GitHub stars~13k tokensUpdated today
    Auto-check passed
  • Score Pyrefly Change

    facebook/pyrefly

    Official

    Produces a scorecard evaluating a pyrefly change on correctness and quality.

    7.1k GitHub stars~1.5k tokensUpdated today
    Auto-check passed
  • Review Pyrefly Diff

    facebook/pyrefly

    Official

    Reviews a comma separated pyrefly diff according to the pyrefly review best practices.

    7.1k GitHub stars~863 tokensUpdated today
    Auto-check passed

Works with

Questions about Add Torch Shapes Example

What does Add Torch Shapes Example do?

A skill your agent uses when adding a new PyTorch model to Pyrefly's shape-tracking example corpus under tensor-shapes/pyrefly-torch-stubs/examples — i.e. Add Torch Shapes Example is an agent skill from facebook/pyrefly, published by the product's own GitHub organization.e.

When should I use Add Torch Shapes Example?

Add Torch Shapes Example fits situations like: adding a new PyTorch model to Pyreflys shape-tracking example corpus under tensor-shapes/pyrefly-torch-stubs/examples — i.e; tasks that involve Deep learning.

How do I install Add Torch Shapes Example in Claude Code?

Run `npx skills add facebook/pyrefly --skill add-torch-shapes-example -a claude-code`. Or copy the skill folder (.agents/skills/add-torch-shapes-example in facebook/pyrefly) into .claude/skills/add-torch-shapes-example in your project. Claude Code loads it when a task matches its description.

How do I install Add Torch Shapes Example in Codex?

Run `npx skills add facebook/pyrefly --skill add-torch-shapes-example -a codex`. Or copy the skill folder (.agents/skills/add-torch-shapes-example in facebook/pyrefly) into .agents/skills/add-torch-shapes-example in your project. Codex loads it when a task matches its description.

Can I use Add Torch Shapes Example in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add facebook/pyrefly --skill add-torch-shapes-example -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/add-torch-shapes-example, .gemini/skills/add-torch-shapes-example, .github/skills/add-torch-shapes-example and .opencode/skills/add-torch-shapes-example in your project.

What does Add Torch Shapes Example need to run?

Going by SKILL.md and its folder, Add Torch Shapes Example needs the command-line tools its instructions call (python3). Our summary lists: Python 3.

Does Add Torch Shapes Example access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Add Torch Shapes Example safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Add Torch Shapes Example use?

Add Torch Shapes Example is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Add Torch Shapes Example use?

About 1.3k tokens (SKILL.md is roughly 5.4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Add Torch Shapes Example?

Skills that share tags, products or a category with Add Torch Shapes Example: Add Uint Support (pytorch/pytorch, 104k stars), CLIP Image-Text Matching (Orchestra-Research/AI-Research-SKILLs, 13k stars), Interview Cheatsheet (wanshuiyin/ARIS-in-AI-Offer, 580 stars) and Ghstack CI (pytorch/pytorch, 104k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Add Torch Shapes Example?

facebook (a GitHub organization, an official publisher) maintains it in facebook/pyrefly, which has 7,054 GitHub stars. The repository holds 6 skills in this directory. The repository was last updated on October 8, 2026.

Source: facebook/pyrefly on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.