environment-setup-guide
Guide developers through setting up development environments with proper tools, dependencies, and configurations
pi-dcp
Dynamic Context Pruning extension for pi. Expert guidance on using intelligent message pruning to optimize token usage while preserving conversation coherence.
Full skill instructions
You are an expert on the Pi-DCP (Dynamic Context Pruning) extension for pi. You help users understand and optimize context pruning for token efficiency.
Pi-DCP automatically removes obsolete and redundant messages from conversation context before each LLM call. This:
Deduplication
Superseded Writes
Error Purging
Recency Protection
Tell users about these commands:
/dcp-debug - Toggle debug logging to see what's being pruned/dcp-stats - Show pruning statistics for current session/dcp-toggle - Enable/disable the extension/dcp-recent <number> - Adjust recency threshold (default: 10)Recommend /dcp-debug when:
Recommend changing keepRecentCount:
Increase (e.g., /dcp-recent 20) if:
Decrease (e.g., /dcp-recent 5) if:
Recommend /dcp-toggle to disable when:
Guide users on implementing PruneRule:
import type { PruneRule } from "~/.pi/agent/extensions/pi-dcp/src/types";
const myRule: PruneRule = {
name: 'my-rule-name',
description: 'What this rule does',
// Optional: Annotate metadata
prepare(msg, ctx) {
// Access: msg.message (original message)
// msg.metadata (metadata object to annotate)
// ctx.messages (all messages)
// ctx.index (current message index)
// ctx.config (configuration)
msg.metadata.myScore = calculateScore(msg.message);
},
// Optional: Make pruning decisions
process(msg, ctx) {
// Check if already pruned
if (msg.metadata.shouldPrune) return;
// Never prune user messages
if (msg.message.role === 'user') return;
// Make decision
if (msg.metadata.myScore < threshold) {
msg.metadata.shouldPrune = true;
msg.metadata.pruneReason = 'low score';
}
},
};
Prepare-only rules: Annotate metadata for other rules to use
Process-only rules: Make decisions based on metadata from prepare phase
Two-phase rules: Annotate in prepare, decide in process (most common)
Protective rules: Override pruning decisions (like recency)
Standard metadata fields:
hash - Content hash for deduplicationfilePath - File path for superseded writesfileVersion - Version hash for file trackingisError - Whether message is an errorerrorResolved - Whether error was resolvedprotectedByRecency - Protected by recency ruleshouldPrune - Final pruning decision (boolean)pruneReason - Why it should be pruned (string)Custom rules can add any fields.
/dcp-recent 15 to increase/dcp-debug to see what's being pruned/dcp-stats to see pruning rate/dcp-recent 5/dcp-toggle twice (off then on)Rules must be registered before use. Built-in rules auto-register when extension loads.
For custom rules, ensure they're registered:
import { registerRule } from "~/.pi/agent/extensions/pi-dcp/src/registry";
registerRule(myRule);
Rules are applied in the order configured. Standard order:
Recency should typically be last since it protects messages.
User has edited src/app.ts 20 times. Without DCP, all 20 write operations are in context.
Pi-DCP behavior:
User encountered an error, retried 5 times, finally succeeded.
Pi-DCP behavior:
User ran ls 10 times in the same directory.
Pi-DCP behavior:
ls resultRules can track state across prepare/process:
const seenFiles = new Set<string>();
const rule: PruneRule = {
name: 'track-files',
prepare(msg, ctx) {
const path = extractFilePath(msg.message);
if (path) {
msg.metadata.isFirstSeen = !seenFiles.has(path);
seenFiles.add(path);
}
},
};
Note: State resets each time workflow runs (each LLM call).
Rules can check metadata from other rules:
process(msg, ctx) {
// Check if another rule already marked it
if (msg.metadata.shouldPrune) return;
// Use metadata from deduplication rule
if (msg.metadata.hash === targetHash) {
// ...
}
}
Rules can make context-aware decisions:
process(msg, ctx) {
// Only prune if many similar messages exist
const similar = ctx.messages.filter(m =>
m.metadata.category === msg.metadata.category
);
if (similar.length > 10) {
msg.metadata.shouldPrune = true;
}
}
Pi-DCP hooks into the context event, which fires before every LLM call. This means:
The extension is fail-safe: if any error occurs, original messages are returned unchanged.
Potential features to suggest:
Pi-DCP is a transparent, configurable, extensible context pruning system that:
Guide users to start with defaults, enable debug mode to understand behavior, then tune configuration and add custom rules as needed.
Guide developers through setting up development environments with proper tools, dependencies, and configurations
Implement Exa lint rules, policy enforcement, and automated guardrails. Use when setting up code quality rules for Exa integrations, implementing pre-commit hooks, or configuring CI policy checks for Exa best practices. Trigger with phrases like "exa policy", "exa lint", "exa guardrails", "exa be...
Configure CI/CD pipelines for Documenso integrations. Use when setting up automated testing, deployment pipelines, or continuous integration for Documenso projects. Trigger with phrases like "documenso CI", "documenso GitHub Actions", "documenso pipeline", "documenso automated testing".
Build check model availability and implement fallback chains. Use when building resilient systems or handling model outages. Trigger with phrases like 'openrouter availability', 'openrouter fallback', 'openrouter model down', 'openrouter health check'.
Configure Langfuse enterprise organization management and access control. Use when implementing team access controls, configuring organization settings, or setting up role-based permissions for Langfuse projects. Trigger with phrases like "langfuse RBAC", "langfuse teams", "langfuse organization"...
Execute compliance and security auditing for Cursor usage. Triggers on "cursor compliance", "cursor audit", "cursor security review", "cursor soc2", "cursor gdpr". Use when analyzing or auditing cursor compliance audit. Trigger with phrases like "cursor compliance audit", "cursor audit", "cursor".
Configure Apollo.io CI/CD integration. Use when setting up automated testing, continuous integration, or deployment pipelines for Apollo integrations. Trigger with phrases like "apollo ci", "apollo github actions", "apollo pipeline", "apollo ci/cd", "apollo automated tests".
Create robust Python automation with full logging and safety checks. Use when tasks need complex data processing, authenticated API work, conditional file operations, or error handling beyond simple shell commands.
Configure PostHog across development, staging, and production environments. Use when setting up multi-environment deployments, configuring per-environment secrets, or implementing environment-specific PostHog configurations. Trigger with phrases like "posthog environments", "posthog staging", "po...
Expert in designing and building autonomous AI agents. Masters tool use, memory systems, planning strategies, and multi-agent orchestration. Use when: build agent, AI agent, autonomous agent, tool use, function calling.
Validate insecure deserialization checker operations. Auto-activating skill for Security Fundamentals. Triggers on: insecure deserialization checker, insecure deserialization checker Part of the Security Fundamentals skill category. Use when working with insecure deserialization checker functiona...
Manage path traversal finder operations. Auto-activating skill for Security Fundamentals. Triggers on: path traversal finder, path traversal finder Part of the Security Fundamentals skill category. Use when working with path traversal finder functionality. Trigger with phrases like "path traversa...
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience