Implement Perplexity lint rules, policy enforcement, and automated guardrails. Use when setting up code quality rules for Perplexity integrations, implementing pre-commit hooks, or configuring CI policy checks for Perplexity best practices. Trigger with phrases like "perplexity policy", "perplexity lint", "perplexity guardrails", "perplexity best practices check", "perplexity eslint".
Enforces Perplexity best practices through lint rules, pre-commit hooks, and CI policy checks.
/plugin marketplace add jeremylongshore/claude-code-plugins-plus-skills/plugin install perplexity-pack@claude-code-plugins-plusThis skill is limited to using the following tools:
Automated policy enforcement and guardrails for Perplexity integrations.
// eslint-plugin-perplexity/rules/no-hardcoded-keys.js
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Disallow hardcoded Perplexity API keys',
},
fixable: 'code',
},
create(context) {
return {
Literal(node) {
if (typeof node.value === 'string') {
if (node.value.match(/^sk_(live|test)_[a-zA-Z0-9]{24,}/)) {
context.report({
node,
message: 'Hardcoded Perplexity API key detected',
});
}
}
},
};
},
};
// .eslintrc.js
module.exports = {
plugins: ['perplexity'],
rules: {
'perplexity/no-hardcoded-keys': 'error',
'perplexity/require-error-handling': 'warn',
'perplexity/use-typed-client': 'warn',
},
};
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: perplexity-secrets-check
name: Check for Perplexity secrets
entry: bash -c 'git diff --cached --name-only | xargs grep -l "sk_live_" && exit 1 || exit 0'
language: system
pass_filenames: false
- id: perplexity-config-validate
name: Validate Perplexity configuration
entry: node scripts/validate-perplexity-config.js
language: node
files: '\.perplexity\.json$'
// Enforce typed configuration
interface PerplexityStrictConfig {
apiKey: string; // Required
environment: 'development' | 'staging' | 'production'; // Enum
timeout: number; // Required number, not optional
retries: number;
}
// Disallow any in Perplexity code
// @ts-expect-error - Using any is forbidden
const client = new Client({ apiKey: any });
// Prefer this
const client = new PerplexityClient(config satisfies PerplexityStrictConfig);
# ADR-001: Perplexity Client Initialization
## Status
Accepted
## Context
We need to decide how to initialize the Perplexity client across our application.
## Decision
We will use the singleton pattern with lazy initialization.
## Consequences
- Pro: Single client instance, connection reuse
- Pro: Easy to mock in tests
- Con: Global state requires careful lifecycle management
## Enforcement
- ESLint rule: perplexity/use-singleton-client
- CI check: grep for "new PerplexityClient(" outside allowed files
# perplexity-policy.rego
package perplexity
# Deny production API keys in non-production environments
deny[msg] {
input.environment != "production"
startswith(input.apiKey, "sk_live_")
msg := "Production API keys not allowed in non-production environment"
}
# Require minimum timeout
deny[msg] {
input.timeout < 10000
msg := sprintf("Timeout too low: %d < 10000ms minimum", [input.timeout])
}
# Require retry configuration
deny[msg] {
not input.retries
msg := "Retry configuration is required"
}
# .github/workflows/perplexity-policy.yml
name: Perplexity Policy Check
on: [push, pull_request]
jobs:
policy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for hardcoded secrets
run: |
if grep -rE "sk_(live|test)_[a-zA-Z0-9]{24,}" --include="*.ts" --include="*.js" .; then
echo "ERROR: Hardcoded Perplexity keys found"
exit 1
fi
- name: Validate configuration schema
run: |
npx ajv validate -s perplexity-config.schema.json -d config/perplexity/*.json
- name: Run ESLint Perplexity rules
run: npx eslint --plugin perplexity --rule 'perplexity/no-hardcoded-keys: error' src/
// Prevent dangerous operations in production
const BLOCKED_IN_PROD = ['deleteAll', 'resetData', 'migrateDown'];
function guardPerplexityOperation(operation: string): void {
const isProd = process.env.NODE_ENV === 'production';
if (isProd && BLOCKED_IN_PROD.includes(operation)) {
throw new Error(`Operation '${operation}' blocked in production`);
}
}
// Rate limit protection
function guardRateLimits(requestsInWindow: number): void {
const limit = parseInt(process.env.PERPLEXITY_RATE_LIMIT || '100');
if (requestsInWindow > limit * 0.9) {
console.warn('Approaching Perplexity rate limit');
}
if (requestsInWindow >= limit) {
throw new Error('Perplexity rate limit exceeded - request blocked');
}
}
Implement custom lint rules for Perplexity patterns.
Set up hooks to catch issues before commit.
Implement policy-as-code in CI pipeline.
Add production safeguards for dangerous operations.
| Issue | Cause | Solution |
|---|---|---|
| ESLint rule not firing | Wrong config | Check plugin registration |
| Pre-commit skipped | --no-verify | Enforce in CI |
| Policy false positive | Regex too broad | Narrow pattern match |
| Guardrail triggered | Actual issue | Fix or whitelist |
npx eslint --plugin perplexity --rule 'perplexity/no-hardcoded-keys: error' src/
For architecture blueprints, see perplexity-architecture-variants.
Expert guidance for Next.js Cache Components and Partial Prerendering (PPR). **PROACTIVE ACTIVATION**: Use this skill automatically when working in Next.js projects that have `cacheComponents: true` in their next.config.ts/next.config.js. When this config is detected, proactively apply Cache Components patterns and best practices to all React Server Component implementations. **DETECTION**: At the start of a session in a Next.js project, check for `cacheComponents: true` in next.config. If enabled, this skill's patterns should guide all component authoring, data fetching, and caching decisions. **USE CASES**: Implementing 'use cache' directive, configuring cache lifetimes with cacheLife(), tagging cached data with cacheTag(), invalidating caches with updateTag()/revalidateTag(), optimizing static vs dynamic content boundaries, debugging cache issues, and reviewing Cache Component implementations.