Skills · Business & ops

Pci Compliance

Unverified30/40

Implement PCI DSS compliance requirements for secure handling of payment card data and payment systems. Use when securing payment processing, achieving PCI compliance, or implementing payment card security measures.

Originally by wshobson · MIT

Claude CodePartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
CursorPartialPlain prose you can paste in — but no Cursor rules file
CodexPartialPlain prose you can paste in — but no AGENTS.md
Gemini CLIPartialPlain prose you can paste in
CopilotPartialPlain prose you can paste in — but no Copilot instructions file
npx agentalley add pci-compliance

This command does not work yet — the CLI is still being built. Until then, use Raw in the reader below to take the file.

Who is stuck, and on what

Implement PCI DSS compliance requirements for secure handling of payment card data and payment systems. Use when securing payment processing, achieving PCI compliance, or implementing payment card security measures.

The whole source

No sign-in, no blur, nothing truncated
pci-compliance/SKILL.md274 lines7.5 KBRawView on GitHub
Frontmatter — 2 properties
namepci-compliance
descriptionImplement PCI DSS compliance requirements for secure handling of payment card data and payment systems. Use when securing payment processing, achieving PCI compliance, or implementing payment card security measures.
1---
2name: pci-compliance
3description: Implement PCI DSS compliance requirements for secure handling of payment card data and payment systems. Use when securing payment processing, achieving PCI compliance, or implementing payment card security measures.
4---A5No allowed-tools declared — no way to tell what this skill may touch
5 
6# PCI Compliance
7 
8Master PCI DSS (Payment Card Industry Data Security Standard) compliance for secure payment processing and handling of cardholder data.
9 
10## When to Use This Skill
11 
12- Building payment processing systems
13- Handling credit card information
14- Implementing secure payment flows
15- Conducting PCI compliance audits
16- Reducing PCI compliance scope
17- Implementing tokenization and encryption
18- Preparing for PCI DSS assessments
19 
20## PCI DSS Requirements (12 Core Requirements)
21 
22### Build and Maintain Secure Network
23 
241. Install and maintain firewall configuration
252. Don't use vendor-supplied defaults for passwords
26 
27### Protect Cardholder Data
28 
293. Protect stored cardholder data
304. Encrypt transmission of cardholder data across public networks
31 
32### Maintain Vulnerability Management
33 
345. Protect systems against malware
356. Develop and maintain secure systems and applications
36 
37### Implement Strong Access Control
38 
397. Restrict access to cardholder data by business need-to-know
408. Identify and authenticate access to system components
419. Restrict physical access to cardholder data
42 
43### Monitor and Test Networks
44 
4510. Track and monitor all access to network resources and cardholder data
4611. Regularly test security systems and processes
47 
48### Maintain Information Security Policy
49 
5012. Maintain a policy that addresses information security
51 
52## Compliance Levels
53 
54**Level 1**: > 6 million transactions/year (annual ROC required)
55**Level 2**: 1-6 million transactions/year (annual SAQ)
56**Level 3**: 20,000-1 million e-commerce transactions/year
57**Level 4**: < 20,000 e-commerce or < 1 million total transactions
58 
59## Data Minimization (Never Store)
60 
61```python
62# NEVER STORE THESE
63PROHIBITED_DATA = {
64 'full_track_data': 'Magnetic stripe data',
65 'cvv': 'Card verification code/value',
66 'pin': 'PIN or PIN block'
67}
68 
69# CAN STORE (if encrypted)
70ALLOWED_DATA = {
71 'pan': 'Primary Account Number (card number)',
72 'cardholder_name': 'Name on card',
73 'expiration_date': 'Card expiration',
74 'service_code': 'Service code'
75}
76 
77class PaymentData:
78 """Safe payment data handling."""
79 
80 def __init__(self):
81 self.prohibited_fields = ['cvv', 'cvv2', 'cvc', 'pin']
82 
83 def sanitize_log(self, data):
84 """Remove sensitive data from logs."""
85 sanitized = data.copy()
86 
87 # Mask PAN
88 if 'card_number' in sanitized:
89 card = sanitized['card_number']
90 sanitized['card_number'] = f"{card[:6]}{'*' * (len(card) - 10)}{card[-4:]}"
91 
92 # Remove prohibited data
93 for field in self.prohibited_fields:
94 sanitized.pop(field, None)
95 
96 return sanitized
97 
98 def validate_no_prohibited_storage(self, data):
99 """Ensure no prohibited data is being stored."""
100 for field in self.prohibited_fields:
101 if field in data:
102 raise SecurityError(f"Attempting to store prohibited field: {field}")
103```
104 
105## Tokenization
106 
107### Using Payment Processor Tokens
108 
109```python
110import stripe
111 
112class TokenizedPayment:
113 """Handle payments using tokens (no card data on server)."""
114 
115 @staticmethod
116 def create_payment_method_token(card_details):
117 """Create token from card details (client-side only)."""
118 # THIS SHOULD ONLY BE DONE CLIENT-SIDE WITH STRIPE.JS
119 # NEVER send card details to your server
120 
121 """
122 // Frontend JavaScript
123 const stripe = Stripe('pk_...');
124 
125 const {token, error} = await stripe.createToken({
126 card: {
127 number: '4242424242424242',
128 exp_month: 12,
129 exp_year: 2024,
130 cvc: '123'
131 }
132 });
133 
134 // Send token.id to server (NOT card details)
135 """
136 pass
137 
138 @staticmethod
139 def charge_with_token(token_id, amount):
140 """Charge using token (server-side)."""
141 # Your server only sees the token, never the card number
142 stripe.api_key = "sk_..."
143 
144 charge = stripe.Charge.create(
145 amount=amount,
146 currency="usd",
147 source=token_id, # Token instead of card details
148 description="Payment"
149 )
150 
151 return charge
152 
153 @staticmethod
154 def store_payment_method(customer_id, payment_method_token):
155 """Store payment method as token for future use."""
156 stripe.Customer.modify(
157 customer_id,
158 source=payment_method_token
159 )
160 
161 # Store only customer_id and payment_method_id in your database
162 # NEVER store actual card details
163 return {
164 'customer_id': customer_id,
165 'has_payment_method': True
166 # DO NOT store: card number, CVV, etc.
167 }
168```
169 
170### Custom Tokenization (Advanced)
171 
172```python
173import secrets
174from cryptography.fernet import Fernet
175 
176class TokenVault:
177 """Secure token vault for card data (if you must store it)."""
178 
179 def __init__(self, encryption_key):
180 self.cipher = Fernet(encryption_key)
181 self.vault = {} # In production: use encrypted database
182 
183 def tokenize(self, card_data):
184 """Convert card data to token."""
185 # Generate secure random token
186 token = secrets.token_urlsafe(32)
187 
188 # Encrypt card data
189 encrypted = self.cipher.encrypt(json.dumps(card_data).encode())
190 
191 # Store token -> encrypted data mapping
192 self.vault[token] = encrypted
193 
194 return token
195 
196 def detokenize(self, token):
197 """Retrieve card data from token."""
198 encrypted = self.vault.get(token)
199 if not encrypted:
200 raise ValueError("Token not found")
201 
202 # Decrypt
203 decrypted = self.cipher.decrypt(encrypted)
204 return json.loads(decrypted.decode())
205 
206 def delete_token(self, token):
207 """Remove token from vault."""
208 self.vault.pop(token, None)
209```
210 
211## Encryption
212 
213### Data at Rest
214 
215```python
216from cryptography.hazmat.primitives.ciphers.aead import AESGCM
217import os
218 
219class EncryptedStorage:
220 """Encrypt data at rest using AES-256-GCM."""
221 
222 def __init__(self, encryption_key):
223 """Initialize with 256-bit key."""
224 self.key = encryption_key # Must be 32 bytes
225 
226 def encrypt(self, plaintext):
227 """Encrypt data."""
228 # Generate random nonce
229 nonce = os.urandom(12)
230 
231 # Encrypt
232 aesgcm = AESGCM(self.key)
233 ciphertext = aesgcm.encrypt(nonce, plaintext.encode(), None)
234 
235 # Return nonce + ciphertext
236 return nonce + ciphertext
237 
238 def decrypt(self, encrypted_data):
239 """Decrypt data."""
240 # Extract nonce and ciphertext
241 nonce = encrypted_data[:12]
242 ciphertext = encrypted_data[12:]
243 
244 # Decrypt
245 aesgcm = AESGCM(self.key)
246 plaintext = aesgcm.decrypt(nonce, ciphertext, None)
247 
248 return plaintext.decode()
249 
250# Usage
251storage = EncryptedStorage(os.urandom(32))
252encrypted_pan = storage.encrypt("4242424242424242")
253# Store encrypted_pan in database
254```
255 
256### Data in Transit
257 
258```python
259# Always use TLS 1.2 or higher
260# Flask/Django example
261app.config['SESSION_COOKIE_SECURE'] = True # HTTPS only
262app.config['SESSION_COOKIE_HTTPONLY'] = True
263app.config['SESSION_COOKIE_SAMESITE'] = 'Strict'
264 
265# Enforce HTTPS
266from flask_talisman import Talisman
267Talisman(app, force_https=True)
268```
269 
270## Additional patterns and templates
271 
272More detailed templates and worked examples live in `references/details.md`. Read that file for the full pattern library.
273 
274 

Reviews

Installed this one?Write the first review and take the Trailblazer badge.

Reviews only open after a real install, so this is empty — and we leave it empty rather than invent one.

Alternatives

Also in Business & ops