소스 정보
- 저장소
- tools-only/X-Skills
- 최근 소스 활동
- 2026년 2월 9일 04:36
- 감지된 SKILL.md 언어
- 영어
- 스타
- 7
- 포크
- 1
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/tools-only/X-Skills --skill generate-contract명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | generate-contract |
| description | Generate comprehensive API contracts for consumer-driven contract testing |
| shortcut | cont |
| category | api |
| difficulty | intermediate |
| estimated_time | 3-5 minutes |
| version | 2.0.0 |
Creates comprehensive API contracts for consumer-driven contract testing, enabling safe evolution of microservices by validating interactions between service consumers and providers. Supports Pact, Spring Cloud Contract, and OpenAPI specifications with automated verification and CI/CD integration.
Use this command when:
Do NOT use this command for:
Before running this command, ensure:
The command examines your API specifications to generate appropriate contracts:
Based on the analysis, creates contract files that include:
Generates test code to verify contracts:
Sets up infrastructure for contract lifecycle:
The command generates multiple files based on your chosen framework:
api-contracts/
├── consumers/
│ ├── [consumer-name]/
│ │ ├── pacts/
│ │ │ └── [consumer]-[provider].json
│ │ └── tests/
│ │ └── contract.test.js
├── providers/
│ ├── [provider-name]/
│ │ ├── contracts/
│ │ │ └── [provider]-contract.groovy
│ │ └── tests/
│ │ └── contract-verification.test.js
├── shared/
│ ├── schemas/
│ │ └── api-schema.json
│ └── states/
│ └── provider-states.js
└── docs/
└── contract-documentation.md
Output Files Explained:
pacts/: Pact contract files in JSON formatcontracts/: Spring Cloud Contract definitions in Groovy/YAMLtests/: Generated test files for contract verificationschemas/: Shared schema definitions (JSON Schema, OpenAPI)states/: Provider state setup for test scenariosdocs/: Human-readable contract documentationScenario: Generate contract for a user service with CRUD operations
User Input:
/generate-contract --service user-api --consumer mobile-app --framework pact
Generated Pact Contract:
{
"consumer": {
"name": "mobile-app"
},
"provider": {
"name": "user-api"
},
"interactions": [
{
"description": "a request to get a user",
"providerState": "user with ID 123 exists",
"request": {
"method": "GET",
"path": "/api/users/123",
"headers": {
"Accept": "application/json",
"Authorization": "Bearer [token]"
}
},
"response": {
Generated Consumer Test:
// consumer-tests/user-api.test.js
const { Pact } = require('@pact-foundation/pact');
const { getUserById, createUser } = require('../src/api-client');
describe('User API Consumer Tests', () => {
const provider = new Pact({
consumer: 'mobile-app',
provider: 'user-api',
port: 8080,
log: path.resolve(process.cwd(), 'logs', 'pact.log'),
dir: path.resolve(process.cwd(), 'pacts'),
logLevel: 'warn'
});
beforeAll(() => provider.setup());
afterEach(() => provider.verify());
afterAll(() => provider.finalize());
describe('GET /api/users/:id', () => {
it('should return a user when user exists', async () => {
// Arrange
await provider.addInteraction({
: ,
: ,
: {
: ,
: ,
: {
: ,
:
}
},
: {
: ,
: {
:
},
: {
: ,
: ,
: ,
:
}
}
});
user = (, );
(user.).();
(user.).();
});
});
});
Scenario: Generate contract for payment processing service
User Input:
/contract --service payment-service --consumer checkout-app --framework spring
Generated Spring Cloud Contract (Groovy):
// contracts/payment/process-payment.groovy
package contracts.payment
import org.springframework.cloud.contract.spec.Contract
Contract.make {
description "Process a payment transaction"
label "process_payment"
request {
method POST()
url "/api/payments"
headers {
contentType(applicationJson())
header("Authorization", "Bearer ${anyNonEmptyString()}")
}
body([
amount: 99.99,
currency: "USD",
customerId: anyUuid(),
paymentMethod: [
type: "CARD",
cardNumber: regex('[0-9]{16}'),
expiryMonth: regex('(0[1-9]|1[0-2])'),
expiryYear: regex('20[2-9][0-9]'),
cvv: regex('[0-9]{3}')
],
orderId: anyUuid()
])
}
response {
status 200
headers {
contentType(applicationJson())
}
body([
transactionId: anyUuid(),
status: "APPROVED",
amount: 99.99,
currency: "USD",
processedAt: anyIso8601DateTime(),
authorizationCode: regex('[A-Z0-9]{6}')
])
}
}
Generated Provider Verification Test:
// PaymentContractVerificationTest.java
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
@AutoConfigureWebTestClient
public class PaymentContractVerificationTest {
@LocalServerPort
private int port;
@MockBean
private PaymentService paymentService;
@TestTarget
public final Target target = new SpringBootHttpTarget();
@Before
public void setup() {
RestAssuredMockMvc.webAppContextSetup(context);
}
@State("payment service is available")
public void paymentServiceAvailable() {
// Setup mock responses
PaymentResponse response = PaymentResponse.builder()
.transactionId(UUID.randomUUID().toString())
.status("APPROVED")
.amount(99.99)
.currency("USD")
.processedAt(Instant.now())
.authorizationCode("ABC123")
.build();
when(paymentService.processPayment(any(PaymentRequest.class)))
.thenReturn(response);
}
}
Scenario: Generate OpenAPI contract with request/response validation
User Input:
/generate-contract --service product-catalog --format openapi --with-validation
Generated OpenAPI Specification:
openapi: 3.0.3
info:
title: Product Catalog API Contract
version: 1.0.0
description: Contract for product catalog service interactions
paths:
/api/products:
get:
operationId: getProducts
summary: List products with pagination
parameters:
- name: page
in: query
required: false
schema:
type: integer
minimum: 1
default: 1
- name: limit
in: query
required: false
schema:
type: integer
minimum: 1
Symptoms: No OpenAPI spec or API documentation available Cause: API not yet documented or in early development Solution:
The command will guide you through interactive API definition:
- Define endpoints and methods
- Specify request/response formats
- Add validation rules
- Generate initial documentation
Prevention: Document APIs as part of development process
Symptoms: Consumer and provider contracts don't match Cause: Services evolved independently without coordination Solution:
Contract Version Migration:
1. Identify breaking changes
2. Create compatibility layer
3. Version contracts appropriately
4. Implement gradual migration
Symptoms: Provider tests fail against consumer contracts Cause: Implementation doesn't match contract expectations Solution:
Debug Contract Mismatches:
1. Review failed interaction details
2. Check request/response differences
3. Update implementation or contract
4. Re-run verification tests
The contract generation can be customized with:
--frameworkpact, spring, openapi, postmanpact/contract --framework spring--strict/contract --strict--version/contract --version 2.0.0✅ DO:
❌ DON'T:
💡 TIPS:
/api-versioning-manager - Manage API versions and migrations/api-documentation-generator - Generate comprehensive API docs/api-mock-server - Create mock servers from contracts/api-testing-suite - Generate integration test suites⚠️ Security Considerations:
Solution: Check broker credentials and network connectivity
Solution: Verify port availability and permissions
Solution: Increase timeout values for slow services
Last updated: 2025-10-11 Quality score: 9+/10 Tested with: Pact v10, Spring Cloud Contract v4, OpenAPI v3.0.3