Grammar Fixer Agent Skill
Grammar Fixer Agent Skill
Add grammar and spelling correction capabilities to your AI agents with this AI Pass skill. This skill enables agents to automatically detect and fix errors while preserving original tone and style.
Skill Overview
The Grammar Fixer skill allows agents to:
- Detect grammar, spelling, and punctuation errors
- Provide context-aware corrections
- Maintain original writing style and tone
- Offer multiple correction modes for different use cases
Installation
Add this skill to your agent configuration:
{
"skills": [
{
"name": "grammar-fix",
"version": "1.0.0",
"enabled": true
}
]
}
Skill Content
// Grammar Fixer Skill
// Get your API key from: https://aipass.one/developer/api-keys
const GRAMMAR_FIX_SKILL = {
name: "grammar-fix",
description: "Fix grammar, spelling, and punctuation errors using AI",
version: "1.0.0",
apiEndpoint: "https://aipass.one/api/v1/models/gpt-5-mini/completions",
modes: {
basic: {
name: "Basic",
description: "Fix only grammar, spelling, and punctuation errors",
instruction: "Fix only grammar, spelling, and punctuation errors. Preserve the original style and tone."
},
professional: {
name: "Professional",
description: "Correct errors AND improve for professional business communication",
instruction: "Correct errors AND improve for professional business communication. Make it more formal and polished while keeping the core message intact."
},
creative: {
name: "Creative",
description: "Fix errors AND enhance for creative writing",
instruction: "Fix errors AND enhance for creative writing. Improve flow, engagement, and expressive language while preserving the creative intent."
},
academic: {
name: "Academic",
description: "Fix errors AND adapt for academic writing",
instruction: "Fix errors AND adapt for academic writing. Use formal, scholarly language and proper academic conventions."
},
casual: {
name: "Casual",
description: "Fix errors AND make it more natural and conversational",
instruction: "Fix errors AND make it more natural and conversational. Use appropriate casual language while correcting errors."
}
},
async execute(text, mode = "basic") {
const apiKey = "$AIPASS_API_KEY"; // Replace with your API key from developer dashboard
const modeInfo = this.modes[mode] || this.modes.basic;
const response = await fetch(this.apiEndpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${apiKey}`
},
body: JSON.stringify({
model: "gpt-5-mini",
temperature: 1,
max_tokens: 16000,
messages: [
{
role: "system",
content: `You are an expert grammar and writing assistant. ${modeInfo.instruction} Provide corrections in this JSON format: {"correctedText": "corrected version", "corrections": [{"original": "original text", "corrected": "corrected text", "type": "grammar|spelling|punctuation|style", "explanation": "why this change"}]}`
},
{
role: "user",
content: `Fix this text: ${text}`
}
]
})
});
const result = await response.json();
return result;
},
getAvailableModes() {
return Object.keys(this.modes).map(key => ({
id: key,
...this.modes[key]
}));
},
examples: [
{
input: "Their going to the store to buy some apples.",
mode: "basic",
output: {
correctedText: "They're going to the store to buy some apples.",
corrections: [
{
original: "Their",
corrected: "They're",
type: "grammar",
explanation: "Changed possessive 'Their' to contraction 'They're' for subject 'going'"
}
]
}
}
]
};
// Export for use in agents
if (typeof module !== "undefined" && module.exports) {
module.exports = GRAMMAR_FIX_SKILL;
}
Usage in Your Agent
// Import the skill
const grammarFix = require('./grammar-fix-skill');
// Use the skill in your agent
async function fixText(text, mode) {
try {
const availableModes = grammarFix.getAvailableModes();
const modeIds = availableModes.map(m => m.id);
if (!modeIds.includes(mode)) {
throw new Error(`Invalid mode. Available: ${modeIds.join(", ")}`);
}
const result = await grammarFix.execute(text, mode);
const data = JSON.parse(result.choices[0].message.content);
return {
success: true,
correctedText: data.correctedText,
corrections: data.corrections
};
} catch (error) {
return {
success: false,
error: error.message
};
}
}
Getting Your API Key
- Go to the AI Pass Developer Dashboard
- Navigate to API Keys
- Click "Generate New Key"
- Copy your API key
- Replace
$AIPASS_API_KEYin the skill code with your actual key
Security Note: Never hardcode your API key in client-side code. Use environment variables or secure server-side storage.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Text to be corrected |
| mode | string | No | Correction mode (default: "basic") |
Available Correction Modes
| Mode ID | Name | Description |
|---|---|---|
| basic | Basic | Errors only, preserve style |
| professional | Professional | Business communication |
| creative | Creative | Enhanced writing |
| academic | Academic | Scholarly language |
| casual | Casual | Natural, conversational |
Response Format
{
"id": "completion-123",
"object": "text.completion",
"created": 1234567890,
"model": "gpt-5-mini",
"choices": [
{
"message": {
"role": "assistant",
"content": "{\"correctedText\":\"They're going to the store\",\"corrections\":[{\"original\":\"Their\",\"corrected\":\"They're\",\"type\":\"grammar\",\"explanation\":\"...\"}]}"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 456,
"completion_tokens": 234,
"total_tokens": 690
}
}
Best Practices
- Text length - Keep text under 10,000 characters for best results
- Context awareness - Choose mode that matches intended audience
- Review corrections - Always review AI corrections for accuracy
- Iterative improvement - Can apply multiple passes for complex texts
Example Agent Integration
class GrammarCorrectionAgent {
constructor(apiKey) {
this.skill = GRAMMAR_FIX_SKILL;
}
async correct(text, mode) {
const result = await this.skill.execute(text, mode);
return result;
}
async suggestMode(context) {
// Suggest appropriate correction mode based on context
const modeSuggestions = {
email: "professional",
essay: "academic",
story: "creative",
chat: "casual",
general: "basic"
};
return modeSuggestions[context] || "basic";
}
getAvailableModes() {
return this.skill.getAvailableModes();
}
async batchCorrect(textArray, mode) {
const results = [];
for (const text of textArray) {
const result = await this.correct(text, mode);
results.push(result);
}
return results;
}
async explainCorrection(correction) {
// Provide additional explanation for a correction
return `Why change "${correction.original}" to "${correction.corrected}"? ${correction.explanation}`;
}
}
Use Cases
- Email composition - Ensure professional, error-free emails
- Content creation - Polish blog posts and articles
- Academic writing - Improve essays and papers
- Social media - Clean up posts and comments
- Documentation - Ensure clear, correct technical writing
Error Types Detected
- Grammar - Subject-verb agreement, tense consistency, sentence structure
- Spelling - Typos, misspelled words, homophone errors
- Punctuation - Comma placement, quotation marks, sentence boundaries
- Style - Word choice, tone consistency, flow improvements
- Usage - Proper word selection and idiomatic expressions
Pricing
Usage is based on API credits. Check the AI Pass pricing page for current rates.
Support
For issues or questions, visit the AI Pass documentation or contact support.
Perfect your agents' writing with AI-powered grammar checking! ✍️✅