emerging-techniques-long-context

emerging-techniques-long-context is a skill for Claude Code, Codex from davila7/claude-code-templates. It costs 78 tokens per session (4,258 once invoked), scanned A, original, MIT.

A guide to making transformer models handle documents longer than their original context window, which is the amount of text they can consider at once. It covers positional methods such as RoPE, YaRN, ALiBi, and position interpolation.

In plain words
What is it for?
Use it to process long documents, fine-tune models for longer inputs, and implement extended context windows with HuggingFace or custom PyTorch code.
Why use it?
It helps when a model cannot fit a long document, codebase, or conversation into one request. The techniques extend or adapt how the model represents positions in longer inputs.

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, fine-tune models for longer inputs, and implement extended context windows with HuggingFace or custom PyTorch code.

Compare 6 skills from other repositories ↓
About the project

Claude Code Templates is a command-line tool and catalogue for configuring Anthropic’s Claude Code with agents, commands, settings, hooks, integrations, skills, and project templates. Developers use it to browse and install reusable components for their coding workflows. The catalogue includes many of these Claude Code components.

davila7/claude-code-templates · 34,790 stars · on GitHub · aitmpl.com

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/davila7/claude-code-templates
agentmods
npx agentmods add skills/davila7/claude-code-templates/emerging-techniques-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 emerging-techniques-long-context

README.md
[![agentmods](https://agentmods.dev/badge/skills/davila7/claude-code-templates/emerging-techniques-long-context/github.svg)](https://agentmods.dev/skills/davila7/claude-code-templates/emerging-techniques-long-context)
Your own site
<a href="https://agentmods.dev/skills/davila7/claude-code-templates/emerging-techniques-long-context"><img src="https://agentmods.dev/badge/skills/davila7/claude-code-templates/emerging-techniques-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 emerging-techniques-long-context

Your own site · 80×15
<a href="https://agentmods.dev/skills/davila7/claude-code-templates/emerging-techniques-long-context"><img src="https://agentmods.dev/badge/skills/davila7/claude-code-templates/emerging-techniques-long-context.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 78 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,258 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. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium analysis-evasion · line 1
    Suspicious Unicode normalization or mixed-script content
    Fix: Review the flagged content for security risks. Ensure no credentials, secrets, or sensitive data are exposed.
How audits are shown
Origin original No closer match found 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.00078 $0.04258
Opus 5.5 $0.00031 $0.01703
Sonnet 5.5 $0.00016 $0.00852
Haiku 4.5 $0.00008 $0.00426

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

Security

Grade A, and why

emerging-techniques-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 1mo 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

Copies of this mod

4 near-identical copies found in the catalogue:

cli-tool/components/skills/ai-research/emerging-techniques-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. 1mo ago Changed · +4 tokens per session 0304c65fec1d
  2. 1mo ago Changed · +1 lines 785054081425
  3. 3mo ago First seen · 537 lines · 74 tokens per session scan A 6426eb21a38b

Subscribe to this mod's changes

emerging-techniques-long-context is a skill published in the GitHub repository davila7/claude-code-templates (34,790 stars, last pushed today), licensed MIT. It adds 78 tokens to every session and 4,258 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

emerging-techniques-long-context compared with skills from other repositories

emerging-techniques-long-context next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
emerging-techniques-long-contextdavila7/claude-code-templatesSkill35ktodayMITA78Claude Code, Codex
Vizra ADK Memory Systemvizra-ai/vizra-adkSkill2951mo agoMITA24Claude Code, Codex
memory-optimizationeric-cielo/mofloSkill192d agoMITA60Claude Code
memory-patternseric-cielo/mofloSkill192d agoMITA55Claude Code
folded-memory-implementationsimbajigege/book2skillsSkill2083mo agoMITA70Claude Code, Codex
agent-memory-implementationsimbajigege/book2skillsSkill2083mo agoMITA129Claude Code, Codex
compact-memory-implementationsimbajigege/book2skillsSkill2083mo agoMITA68Claude Code, Codex