long-context

long-context is a skill for Claude Code, Codex from synthetic-sciences/openscience. It costs 74 tokens per session (4,255 once invoked), scanned A, a copy of emerging-techniques-long-context, Apache-2.0.

A set of techniques for helping transformer-based AI models handle documents and prompts longer than their original context limit.

In plain words
What is it for?
Use it to process long documents, extend existing models' context windows, train models for longer inputs, and implement positional methods such as RoPE, YaRN, or ALiBi.
Why use it?
It allows an application to work with more text at once without splitting everything into small pieces.

Skill for Claude CodeCodex

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

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is python scripts/train.py \.

Good fit Use it to process long documents, extend existing models' context windows, train models for longer inputs, and implement positional methods such as RoPE, YaRN, or ALiBi.

Compare 6 skills from other repositories ↓
About the project

synthetic-sciences/openscience is an AI workbench that carries out scientific research by reading papers, forming hypotheses, writing and running code, conducting experiments, analyzing results, and preparing reports. Researchers use it for work in machine learning, biology, physics, and chemistry with remote or local models. Catalogue add-ons extend its scientific workflows through skills and instructions.

synthetic-sciences/openscience · 4,357 stars · on GitHub · openscience.sh

Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/synthetic-sciences/openscience
agentmods
npx agentmods add skills/synthetic-sciences/openscience/long-context

Made for: Claude Code, Codex.

Wrote this? Show the measurements

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

agentmods badge for long-context

README.md
[![agentmods](https://agentmods.dev/badge/skills/synthetic-sciences/openscience/long-context/github.svg)](https://agentmods.dev/skills/synthetic-sciences/openscience/long-context)
Your own site
<a href="https://agentmods.dev/skills/synthetic-sciences/openscience/long-context"><img src="https://agentmods.dev/badge/skills/synthetic-sciences/openscience/long-context/github.svg" alt="Measured on agentmods" height="20"></a>

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

agentmods 80×15 button for long-context

Your own site · 80×15
<a href="https://agentmods.dev/skills/synthetic-sciences/openscience/long-context"><img src="https://agentmods.dev/badge/skills/synthetic-sciences/openscience/long-context.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 74 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,255 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 97% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

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

ModelPer sessionOnce invoked
Fable 5.1 $0.00074 $0.04255
Opus 5.5 $0.00030 $0.01702
Sonnet 5.5 $0.00015 $0.00851
Haiku 4.5 $0.00007 $0.00426

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

Security

Grade A, and why

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

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

Nothing flagged

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

Origin

This is a copy

97% identical to emerging-techniques-long-context — 12 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

backend/cli/skills/llm-tools/long-context/SKILL.md · 538 lines

How it starts

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

Long Context: Extending Transformer Context Windows

When to Use This Skill

Use Long Context techniques when you need to:

  • Process long documents (32k, 64k, 128k+ tokens) with transformer models
  • Extend context windows of pre-trained models (LLaMA, Mistral, etc.)
  • Implement efficient positional encodings (RoPE, ALiBi)
  • Train models with length extrapolation capabilities
  • Deploy models that handle variable-length inputs efficiently
  • Fine-tune existing models for longer contexts with minimal compute

Key Techniques: RoPE (Rotary Position Embeddings), YaRN, ALiBi (Attention with Linear Biases), Position Interpolation

Papers: RoFormer (arXiv 2104.09864), YaRN (arXiv 2309.00071), ALiBi (arXiv 2108.12409), Position Interpolation (arXiv 2306.15595)

Installation

# HuggingFace Transformers (includes RoPE, YaRN support)
pip install transformers torch

# For custom implementations
pip install einops  # Tensor operations
pip install rotary-embedding-torch  # Standalone RoPE

# Optional: FlashAttention for efficiency
pip install flash-attn --no-build-isolation

Quick Start

RoPE (Rotary Position Embeddings)

import torch
import torch.nn as nn

class RotaryEmbedding(nn.Module):
    """Rotary Position Embeddings (RoPE)."""

    def __init__(self, dim, max_seq_len=8192, base=10000):
        super().__init__()
        # Compute inverse frequencies
        inv_freq = 1.0 / (base ** (torch.arange(0, dim, 2).float() / dim))
        self.register_buffer("inv_freq", inv_freq)
        self.max_seq_len = max_seq_len

    def forward(self, seq_len, device):
        # Position indices
        t = torch.arange(seq_len, device=device).type_as(self.inv_freq)

        # Compute frequencies
        freqs = torch.outer(t, self.inv_freq)  # (seq_len, dim/2)

        # Compute sin and cos
        emb = torch.cat((freqs, freqs), dim=-1)  # (seq_len, dim)
        return emb.cos(), emb.sin()

def rotate_half(x):
    """Rotate half the hidden dimensions."""
    x1, x2 = x.chunk(2, dim=-1)
    return torch.cat((-x2, x1), dim=-1)

def apply_rotary_pos_emb(q, k, cos, sin):
    """Apply rotary embeddings to queries and keys."""
    # q, k shape: (batch, heads, seq_len, dim)
    q_embed = (q * cos) + (rotate_half(q) * sin)
    k_embed = (k * cos) + (rotate_half(k) * sin)
    return q_embed, k_embed

# Usage
rope = RotaryEmbedding(dim=64, max_seq_len=8192)
cos, sin = rope(seq_len=2048, device='cuda')

# In attention layer
q_rotated, k_rotated = apply_rotary_pos_emb(query, key, cos, sin)

Read the full file on GitHub · 538 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

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

  1. 2mo ago First seen · 538 lines · 74 tokens per session scan A 722c1aa58acf

Subscribe to this mod's changes

long-context is a skill published in the GitHub repository synthetic-sciences/openscience (4,357 stars, last pushed yesterday), licensed Apache-2.0. It adds 74 tokens to every session and 4,255 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 97% identical to emerging-techniques-long-context, differing in 12 lines, and is treated as a copy.

Related

long-context compared with skills from other repositories

long-context next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
long-contextsynthetic-sciences/openscienceSkill4.4kyesterdayApache-2.0A74Claude Code, Codex
long-contextOpenLAIR/dr-clawSkill1.2k3d agononeA74Claude Code, Codex
long-contextOrchestra-Research/AI-Research-SKILLsSkill14k29d agoMITA74Claude Code
long-contextliortesta/ClawdAgentSkill122mo agoApache-2.0A74Claude Code
long-contextOpenLAIR/dr-claw-plugin-ccSkill55mo agononeA74Claude Code
long-contextihatesea69/HieuNghi-AI-SkillsSkill38mo agoMITA74Claude Code, Codex
model-mergingOrchestra-Research/AI-Research-SKILLsSkill14k29d agoMITA73Claude Code