apigee-x-proxy-development
Skill1 starsChanged 4 months agoApache-2.0View on GitHub
Use when developing, reviewing, debugging, or explaining Apigee X API proxy configurations — proxy bundles, policies, flows, endpoints, shared flows, fault handling, and JavaScript callouts.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- aws-lambda-fleet-to-cloud-runSkill
- aws-lambda-to-cloud-run-migrationSkill
- preso-builderSkill
- visual-docsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
29 rules. About 0 are common, 23 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈23
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Use this skill when the user is:
- Distinctive: line 31
Do NOT use this skill when the user is:
- Distinctive: line 40
When you need to look up specific policy syntax, verify behavior, or find recent changes:
- Very specific: line 42
Web search: Use site:cloud.google.com/apigee to restrict results to official Apigee X docs
- Very specific: line 49
Important: Do NOT use docs.apigee.com — that is legacy Apigee Edge documentation.
- Very specific: line 72
Follow the [Abbreviation]-[Purpose].xml pattern from GoogleCloudPlatform/apigee-samples:
- Very specific: line 105
Create the apiproxy/ directory with root XML, proxies/, targets/, policies/
- Distinctive: line 115
Place security policies in PreFlow (execute for every request)
- Distinctive: line 116
Place business logic in conditional flows (execute per operation)
- Distinctive: line 117
Place response headers and caching in PostFlow
- Distinctive: line 118
Place MessageLogging in PostClientFlow (guarantees execution even on fault — PostFlow is skipped if proxy errors before reaching it)
- Distinctive: line 124
Follow this ordering within flows — security first, then mediation, then traffic:
- Distinctive: line 137
Add DefaultFaultRule as catch-all with consistent error format
- Distinctive: line 138
Use RaiseFault for custom validation errors
- Distinctive: line 146
Add response caching where appropriate
- Distinctive: line 147
Consider advanced patterns: proxy chaining, composite APIs, circuit breakers
- Distinctive: line 148
Add JavaScript callouts for complex transformations only when policies don't suffice
- Distinctive: line 209
Conditional flows: Only the FIRST flow whose condition evaluates to true executes.
- Distinctive: line 373
Add VerifyAPIKey to PreFlow — all requests must include a valid key:
- Distinctive: line 386
Create a token endpoint flow + verify tokens on resource flows:
- Distinctive: line 416
Place ResponseCache in the flow — it handles both lookup and population:
- Distinctive: line 438
Use ServiceCallout to call external APIs during request processing:
- Distinctive: line 450
Add FaultRules + DefaultFaultRule to ProxyEndpoint:
- Very specific: line 480
Naming: Always use [Abbreviation]-[Purpose].xml for policy files
- Distinctive: line 481
Policies over code: Use built-in policies first.
- Distinctive: line 482
Fault handling: Every proxy should have a DefaultFaultRule with a consistent error response format
- Very specific: line 484
Base paths: Use versioned paths (/v1/resource) and ensure uniqueness per environment
- Distinctive: line 485
Conditions: Place the most specific conditional flows first (first match wins)
- Distinctive: line 486
PostClientFlow: Always use for MessageLogging to guarantee execution regardless of errors
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Apigee X API Proxy Development
Comprehensive skill for building API proxies on Google Cloud's Apigee X platform. Covers the full proxy development lifecycle: bundle structure, endpoint configuration, flow design, policy implementation, fault handling, JavaScript extensibility, shared flows, and advanced patterns.
This skill covers: API proxy bundle authoring, policy configuration (42+ policy types), flow execution design, conditional routing, fault handling, JavaScript callouts, shared flows, and advanced development patterns.
This skill does NOT cover: Apigee X deployment/provisioning, CI/CD pipelines, Apigee Hybrid-specific configuration, GCP infrastructure setup, or Apigee management API usage. Focus is exclusively on proxy development artifacts.
When to Use This Skill
Use this skill when the user is:
- Building new API proxy bundles from scratch
- Writing or configuring Apigee policies (security, mediation, traffic management, etc.)
- Designing flow pipelines (PreFlow, conditional flows, PostFlow, PostClientFlow)
- Configuring ProxyEndpoints, TargetEndpoints, or RouteRules
- Implementing fault handling (FaultRules, DefaultFaultRule, RaiseFault)
- Writing JavaScript callout code for Apigee proxies
- Creating or consuming shared flows
- Debugging proxy execution or policy errors
- Reviewing existing proxy configurations for correctness or best practices
- Asking about Apigee X policy behavior, flow variables, or conditions
Do NOT use this skill when the user is:
- Deploying proxies to Apigee environments (use deployment tooling instead)
- Configuring Apigee Hybrid runtime infrastructure
- Setting up CI/CD for proxy bundles
- Managing Apigee organizations, environments, or environment groups via API
- Working with non-Apigee API gateways
Consulting Official Documentation
When you need to look up specific policy syntax, verify behavior, or find recent changes:
- Web search: Use
site:cloud.google.com/apigeeto restrict results to official Apigee X docs - Policy reference: Fetch
https://cloud.google.com/apigee/docs/api-platform/reference/policies/[policy-name]-policy - Configuration reference: Fetch
https://cloud.google.com/apigee/docs/api-platform/reference/api-proxy-configuration-reference - Flow variables: Fetch
https://cloud.google.com/apigee/docs/api-platform/reference/variables-reference - Conditions: Fetch
https://cloud.google.com/apigee/docs/api-platform/reference/conditions-reference - Vetted examples: Browse
https://github.com/GoogleCloudPlatform/apigee-samplesfor production patterns
Important: Do NOT use docs.apigee.com — that is legacy Apigee Edge documentation. Always use cloud.google.com/apigee for Apigee X.
API Proxy Bundle Quick Reference
apiproxy/
├── MyProxy.xml # Root proxy definition (name + revision)
├── proxies/ # ProxyEndpoint definitions
│ └── default.xml
├── targets/ # TargetEndpoint definitions
│ └── default.xml
├── policies/ # All policy XML files
│ ├── AM-SetHeaders.xml
│ ├── EV-ExtractPath.xml
│ └── ...
└── resources/ # Custom code and resources
├── jsc/ # JavaScript files
├── java/ # Java JAR files
└── xsl/ # XSLT transformationsPolicy Naming Conventions
Follow the [Abbreviation]-[Purpose].xml pattern from GoogleCloudPlatform/apigee-samples:
| Abbreviation | Policy Type | Example |
| AM | AssignMessage | AM-SetHeaders.xml |
| EV | ExtractVariables | EV-ExtractUserId.xml |
| SC | ServiceCallout | SC-CallBackend.xml |
| RF | RaiseFault | RF-InvalidInput.xml |
| FC | FlowCallout | FC-AuthSharedFlow.xml |
| SA | SpikeArrest | SA-ProtectBackend.xml |
| Q | Quota | Q-DailyLimit.xml |
| RC | ResponseCache | RC-CacheResponse.xml |
| LC | LookupCache | LC-GetCachedValue.xml |
| PC | PopulateCache | PC-StoreValue.xml |
| IC | InvalidateCache | IC-ClearCache.xml |
| KVM | KeyValueMapOperations | KVM-GetConfig.xml |
| JS | JavaScript | JS-TransformResponse.xml |
| JWT | JWT policies | JWT-GenerateToken.xml |
| OAuth | OAuthV2 | OAuth-VerifyToken.xml |
| VAK | VerifyAPIKey | VAK-CheckKey.xml |
| ML | MessageLogging | ML-LogToCloud.xml |
| DC | DataCapture | DC-CaptureMetrics.xml |
| CORS | CORS | CORS-AllowOrigins.xml |
| JTP | JSONThreatProtection | JTP-ValidatePayload.xml |
| XTP | XMLThreatProtection | XTP-ValidateXML.xml |
| OAS | OASValidation | OAS-ValidateRequest.xml |
See proxy_bundle_anatomy.md for full details.
Development Workflow
Phase 1: Define Proxy Structure
- Create the
apiproxy/directory with root XML,proxies/,targets/,policies/ - Configure ProxyEndpoint: set BasePath, define HTTPProxyConnection
- Configure TargetEndpoint: set backend URL or LoadBalancer
- Set up RouteRules to connect proxy to target
Reference: proxy_bundle_anatomy.md, endpoints_and_routing.md
Phase 2: Design Flow Pipeline
- Map API operations to conditional flows using verb + path conditions
- Place security policies in PreFlow (execute for every request)
- Place business logic in conditional flows (execute per operation)
- Place response headers and caching in PostFlow
- Place MessageLogging in PostClientFlow (guarantees execution even on fault — PostFlow is skipped if proxy errors before reaching it)
Reference: flows_and_execution.md, flow_variables_and_conditions.md
Phase 3: Implement Policies
Follow this ordering within flows — security first, then mediation, then traffic:
- Security: VerifyAPIKey, OAuthV2, VerifyJWT, AccessControl, threat protection
- Mediation: ExtractVariables, AssignMessage, transformations
- Traffic management: SpikeArrest, Quota
- Caching: ResponseCache (typically in PostFlow response)
- Logging: MessageLogging (typically in PostClientFlow)
Reference: policies_security.md, policies_mediation.md, policies_traffic_management.md, policies_caching.md, policies_integration.md
Phase 4: Add Fault Handling
- Define FaultRules for known error types (auth failures, quota exceeded, backend errors)
- Add DefaultFaultRule as catch-all with consistent error format
- Use RaiseFault for custom validation errors
- Set
continueOnErroronly for policies where failure is acceptable
Reference: fault_handling.md
Phase 5: Optimize and Extend
- Extract reusable policy sequences into shared flows
- Add response caching where appropriate
- Consider advanced patterns: proxy chaining, composite APIs, circuit breakers
- Add JavaScript callouts for complex transformations only when policies don't suffice
Reference: shared_flows.md, javascript_development.md, advanced_patterns.md, anti_patterns_and_best_practices.md
Flow Execution Model
CLIENT REQUEST
│
▼
┌─────────────────────────────────────────────────┐
│ PROXY ENDPOINT │
│ ┌──────────┐ ┌────────────────┐ ┌─────────┐ │
│ │ PreFlow │→ │ Conditional │→ │PostFlow │ │
│ │ (Request)│ │ Flows (Request)│ │(Request)│ │
│ └──────────┘ └────────────────┘ └─────────┘ │
│ │
│ RouteRule evaluation → select TargetEndpoint │
└─────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────┐
│ TARGET ENDPOINT │
│ ┌──────────┐ ┌────────────────┐ ┌─────────┐ │
│ │ PreFlow │→ │ Conditional │→ │PostFlow │ │
│ │ (Request)│ │ Flows (Request)│ │(Request)│ │
│ └──────────┘ └────────────────┘ └─────────┘ │
└─────────────────────────────────────────────────┘
│
▼
BACKEND SERVICE (request sent, response received)
│
▼
┌─────────────────────────────────────────────────┐
│ TARGET ENDPOINT │
│ ┌──────────┐ ┌─────────────────┐ ┌─────────┐ │
│ │ PreFlow │→ │ Conditional │→│PostFlow │ │
│ │(Response)│ │ Flows (Response)│ │(Response│ │
│ └──────────┘ └─────────────────┘ └─────────┘ │
└─────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────┐
│ PROXY ENDPOINT │
│ ┌──────────┐ ┌─────────────────┐ ┌─────────┐ │
│ │ PreFlow │→ │ Conditional │→│PostFlow │ │
│ │(Response)│ │ Flows (Response)│ │(Response│ │
│ └──────────┘ └─────────────────┘ └─────────┘ │
└─────────────────────────────────────────────────┘
│
▼
CLIENT RESPONSE SENT
│
▼
┌─────────────────────────────────────────────────┐
│ PostClientFlow (async — after response sent) │
│ Only: MessageLogging, FlowCallout │
└─────────────────────────────────────────────────┘Key rules:
- Conditional flows: Only the FIRST flow whose condition evaluates to true executes. Order matters.
- PostClientFlow: Executes even if the proxy errored. Only MessageLogging and FlowCallout policies allowed.
- FaultRules: Execute when a policy raises a fault. Skip remaining flow steps and enter error flow.
Policy Catalog
Traffic Management
| Policy | Purpose | Reference |
| SpikeArrest | Throttle request rate to protect backends | policies_traffic_management.md |
| Quota | Enforce consumption limits over time periods | policies_traffic_management.md |
| ResetQuota | Dynamically adjust quota counters mid-cycle | policies_traffic_management.md |
Caching
| Policy | Purpose | Reference |
| ResponseCache | Cache backend responses by request attributes | policies_caching.md |
| LookupCache | Retrieve values from general-purpose cache | policies_caching.md |
| PopulateCache | Store values in general-purpose cache | policies_caching.md |
| InvalidateCache | Remove entries from cache | policies_caching.md |
Security
| Policy | Purpose | Reference |
| VerifyAPIKey | Validate API key from header or query param | policies_security.md |
| BasicAuthentication | Encode/decode Base64 Basic auth credentials | policies_security.md |
| OAuthV2 | Generate/verify OAuth 2.0 tokens | policies_security.md |
| GenerateJWT | Create signed or encrypted JWT tokens | policies_security.md |
| VerifyJWT | Validate JWT signatures and claims | policies_security.md |
| DecodeJWT | Decode JWT without signature verification | policies_security.md |
| HMAC | Compute/verify hash-based message auth codes | policies_security.md |
| CORS | Enable cross-origin resource sharing | policies_security.md |
| AccessControl | IP-based allow/deny rules | policies_security.md |
| VerifyIAM | Google Cloud IAM-based authorization | policies_security.md |
| JSONThreatProtection | Protect against malicious JSON payloads | policies_security.md |
| XMLThreatProtection | Protect against malicious XML payloads | policies_security.md |
Mediation
| Policy | Purpose | Reference |
| AssignMessage | Modify/create request or response messages | policies_mediation.md |
| ExtractVariables | Extract content from messages into variables | policies_mediation.md |
| HTTPModifier | Add/remove/set HTTP headers and params | policies_mediation.md |
| XMLtoJSON | Convert XML payloads to JSON | policies_mediation.md |
| JSONtoXML | Convert JSON payloads to XML | policies_mediation.md |
| JavaScript | Execute custom JavaScript code | javascript_development.md |
Integration & Extension
| Policy | Purpose | Reference |
| ServiceCallout | Call external REST services during flow | policies_integration.md |
| FlowCallout | Invoke a shared flow | policies_integration.md |
| ExternalCallout | Send gRPC requests to external servers | policies_integration.md |
| KeyValueMapOperations | Read/write key-value map entries | policies_integration.md |
| ReadPropertySet | Read property set values into variables | policies_integration.md |
| AccessEntity | Look up entity profiles at runtime | policies_integration.md |
| RaiseFault | Generate custom fault responses | fault_handling.md |
| AssertCondition | Evaluate conditional statements | policies_integration.md |
| MessageLogging | Log to Cloud Logging or syslog | policies_integration.md |
| PublishMessage | Publish to Pub/Sub topics | policies_integration.md |
| DataCapture | Capture custom analytics data into Data Collectors | policies_integration.md |
Validation
| Policy | Purpose | Reference |
| OASValidation | Validate against OpenAPI 3.0 specs | policies_security.md |
| GraphQL | Parse and validate GraphQL payloads | policies_security.md |
AI/LLM
| Policy | Purpose | Reference |
| LLMTokenQuota | Enforce token consumption limits | advanced_patterns.md |
| PromptTokenLimit | Throttle token consumption per request | advanced_patterns.md |
| SanitizeUserPrompt | Filter harmful content from prompts | advanced_patterns.md |
| SanitizeModelResponse | Filter harmful content from LLM responses | advanced_patterns.md |
| SemanticCacheLookup | Semantic similarity cache lookup | advanced_patterns.md |
| SemanticCachePopulate | Cache responses by semantic similarity | advanced_patterns.md |
Reference Documentation
| Document | Description |
| proxy_bundle_anatomy.md | Bundle directory structure, file types, naming conventions |
| endpoints_and_routing.md | ProxyEndpoint, TargetEndpoint, RouteRules, proxy chaining |
| flows_and_execution.md | Flow pipeline, PreFlow/PostFlow/conditional flows, execution order |
| flow_variables_and_conditions.md | Variable system, conditions syntax, message templates |
| policies_traffic_management.md | SpikeArrest, Quota, ResetQuota |
| policies_caching.md | ResponseCache, cache-aside pattern, PopulateCache, LookupCache, InvalidateCache |
| policies_security.md | API keys, OAuth 2.0, JWT, CORS, threat protection, IAM |
| policies_mediation.md | AssignMessage, ExtractVariables, JSON/XML transforms |
| policies_integration.md | ServiceCallout, FlowCallout, KVM deep dive, PropertySets, logging, RaiseFault |
| load_balancing_and_routing.md | Target servers, load balancing algorithms, health monitors, advanced routing |
| fault_handling.md | FaultRules, DefaultFaultRule, error flows, error responses |
| javascript_development.md | JavaScript object model, patterns, best practices |
| shared_flows.md | Creating and consuming shared flows, flow hooks |
| advanced_patterns.md | Proxy chaining, composite APIs, circuit breaker, AI/LLM |
| anti_patterns_and_best_practices.md | Common mistakes, production best practices |
| debugging_and_performance.md | Debug sessions, trace methodology, performance optimization |
| multi_tenant_patterns.md | Multi-tenant routing, isolation, per-tenant config and rate limiting |
| websockets_and_streaming.md | WebSocket proxying, SSE, HTTP streaming, timeout gotchas |
| end_to_end_examples.md | 4 complete proxy bundle walkthroughs |
Quick Start: Minimal Proxy Bundle
apiproxy/MinimalProxy.xml
<?xml version="1.0" encoding="UTF-8"?>
<APIProxy name="MinimalProxy" revision="1">
<DisplayName>Minimal Proxy</DisplayName>
<Description>Simple passthrough proxy</Description>
</APIProxy>apiproxy/proxies/default.xml
<?xml version="1.0" encoding="UTF-8"?>
<ProxyEndpoint name="default">
<HTTPProxyConnection>
<BasePath>/v1/minimal</BasePath>
</HTTPProxyConnection>
<PreFlow name="PreFlow">
<Request/>
<Response/>
</PreFlow>
<Flows/>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<RouteRule name="default">
<TargetEndpoint>default</TargetEndpoint>
</RouteRule>
</ProxyEndpoint>apiproxy/targets/default.xml
<?xml version="1.0" encoding="UTF-8"?>
<TargetEndpoint name="default">
<HTTPTargetConnection>
<URL>https://mocktarget.apigee.net</URL>
</HTTPTargetConnection>
<PreFlow name="PreFlow">
<Request/>
<Response/>
</PreFlow>
<Flows/>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
</TargetEndpoint>Common Development Recipes
Add API Key Protection
Add VerifyAPIKey to PreFlow — all requests must include a valid key:
<PreFlow name="PreFlow">
<Request>
<Step>
<Name>VAK-VerifyKey</Name>
</Step>
</Request>
</PreFlow>See policies_security.md for VerifyAPIKey policy XML.
Add OAuth 2.0
Create a token endpoint flow + verify tokens on resource flows:
<Flow name="token">
<Condition>(proxy.pathsuffix MatchesPath "/token") and (request.verb = "POST")</Condition>
<Request>
<Step><Name>OAuth-GenerateToken</Name></Step>
</Request>
</Flow>
<Flow name="protected-resource">
<Condition>proxy.pathsuffix MatchesPath "/resource"</Condition>
<Request>
<Step><Name>OAuth-VerifyToken</Name></Step>
</Request>
</Flow>See policies_security.md for OAuthV2 policy configuration.
Add Rate Limiting
Combine SpikeArrest (protection) with Quota (SLA enforcement):
<PreFlow name="PreFlow">
<Request>
<Step><Name>SA-ProtectBackend</Name></Step>
<Step><Name>Q-DailyLimit</Name></Step>
</Request>
</PreFlow>See policies_traffic_management.md.
Add Response Caching
Place ResponseCache in the flow — it handles both lookup and population:
<PostFlow name="PostFlow">
<Response>
<Step><Name>RC-CacheResponse</Name></Step>
</Response>
</PostFlow>See policies_caching.md.
Add CORS
Attach CORS policy in PreFlow to handle preflight and response headers:
<PreFlow name="PreFlow">
<Request>
<Step><Name>CORS-AllowOrigins</Name></Step>
</Request>
</PreFlow>See policies_security.md for CORS policy XML.
Call an External Service
Use ServiceCallout to call external APIs during request processing:
<Flow name="enrich-request">
<Request>
<Step><Name>SC-GetUserProfile</Name></Step>
<Step><Name>EV-ExtractProfile</Name></Step>
</Request>
</Flow>See policies_integration.md.
Build Consistent Error Responses
Add FaultRules + DefaultFaultRule to ProxyEndpoint:
<FaultRules>
<FaultRule name="auth-error">
<Condition>fault.name = "FailedToResolveAPIKey"</Condition>
<Step><Name>AM-AuthError</Name></Step>
</FaultRule>
</FaultRules>
<DefaultFaultRule>
<AlwaysEnforce>true</AlwaysEnforce>
<Step><Name>AM-GenericError</Name></Step>
</DefaultFaultRule>See fault_handling.md.
Create and Use a Shared Flow
Extract reusable logic into a shared flow, invoke via FlowCallout:
<!-- In consuming proxy -->
<PreFlow name="PreFlow">
<Request>
<Step><Name>FC-AuthSharedFlow</Name></Step>
</Request>
</PreFlow>See shared_flows.md.
Best Practices Summary
- Policy ordering: Security (PreFlow) → Mediation → Traffic management → Caching (PostFlow) → Logging (PostClientFlow)
- Naming: Always use
[Abbreviation]-[Purpose].xmlfor policy files - Policies over code: Use built-in policies first; only use JavaScript for logic that policies cannot express
- Fault handling: Every proxy should have a DefaultFaultRule with a consistent error response format
- Shared flows: Extract any policy sequence used in 2+ proxies into a shared flow
- Base paths: Use versioned paths (
/v1/resource) and ensure uniqueness per environment - Conditions: Place the most specific conditional flows first (first match wins)
- PostClientFlow: Always use for MessageLogging to guarantee execution regardless of errors
- Caching: Set
ExcludeErrorResponseto true on ResponseCache to avoid caching error responses - Large payloads: Minimize policies that parse large payloads; enable streaming for passthrough scenarios
- Anti-patterns: See anti_patterns_and_best_practices.md for the complete catalog
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

