Agent skill
thegraph
TheGraph subgraph development with AssemblyScript handlers, schema definitions, and Matchstick testing. Triggers on subgraph, thegraph, graphql, mapping.ts.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/thegraph
SKILL.md
<mcp_first> CRITICAL: TheGraph has no Context7 docs. Use OctoCode to search graph-ts.
MCPSearch({ query: "select:mcp__plugin_devtools_octocode__githubSearchCode" })
// graph-ts type definitions
mcp__octocode__githubSearchCode({
keywordsToSearch: ["BigInt", "Bytes", "Address", "store"],
owner: "graphprotocol",
repo: "graph-tooling",
path: "packages/ts/common",
mainResearchGoal: "Understand graph-ts type system",
researchGoal: "Find BigInt, Bytes, Address type definitions",
reasoning: "Need current API for AssemblyScript types"
})
// Entity patterns
mcp__octocode__githubSearchCode({
keywordsToSearch: ["Entity", "save", "load"],
owner: "graphprotocol",
repo: "graph-tooling",
path: "packages/ts",
mainResearchGoal: "Understand graph-ts entity patterns",
researchGoal: "Find entity save/load patterns",
reasoning: "Need current API for entity persistence"
})
// Matchstick testing
mcp__octocode__githubSearchCode({
keywordsToSearch: ["createMockedFunction", "newMockEvent", "assert"],
owner: "LimeChain",
repo: "matchstick",
path: "packages/matchstick-as/assembly",
mainResearchGoal: "Understand Matchstick testing",
researchGoal: "Find mock and assertion patterns",
reasoning: "Need current API for subgraph unit testing"
})
</mcp_first>
<quick_start> Schema (schema.graphql):
type Transfer @entity {
id: Bytes!
from: Bytes!
to: Bytes!
amount: BigInt!
blockNumber: BigInt!
timestamp: BigInt!
}
Handler (mapping.ts):
import { Transfer as TransferEvent } from "../generated/Token/Token";
import { Transfer } from "../generated/schema";
export function handleTransfer(event: TransferEvent): void {
let entity = new Transfer(event.transaction.hash.concatI32(event.logIndex.toI32()));
entity.from = event.params.from;
entity.to = event.params.to;
entity.amount = event.params.value;
entity.blockNumber = event.block.number;
entity.timestamp = event.block.timestamp;
entity.save(); // REQUIRED!
}
</quick_start>
<assemblyscript_rules> AssemblyScript is NOT TypeScript:
- No async/await
- No closures
- No exceptions (try/catch)
- No null (use nullable types)
- Use
Bytesfor addresses - Use
BigIntfor numbers - Use
BigDecimalfor decimals - Always call
.save()to persist
Composite IDs:
// ✅ Correct
event.transaction.hash.concatI32(event.logIndex.toI32())
// ❌ Wrong - string concatenation
event.transaction.hash.toHexString() + "-" + event.logIndex.toString()
</assemblyscript_rules>
Required:
- All entities have
id: Bytes!orid: ID! - All handlers call
.save()after changes - Run
codegenafter schema/ABI changes - Run
compileafter mapping changes
<success_criteria>
- OctoCode searched for graph-ts patterns
- All entities have
idfield - All handlers call
.save() -
codegenruns without errors -
compilesucceeds - Tests cover critical handlers </success_criteria>
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?