Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

pi-grammar

A comprehensive grammar checking extension for pi — your AI coding agent.

Check grammar in text snippets, markdown files, or entire documents with intelligent corrections and flexible save options.

Features

  • Quick inline checks with ?grammar prefix
  • Interactive editor via /grammar command
  • Markdown file analysis with /grammar-file command
  • Flexible saving with overwrite or new file options via /grammar-save
  • LLM-powered tools that work automatically when you ask for grammar help
  • Rule-based pre-checks for common issues (50+ spelling errors, punctuation, capitalization)
  • Smart markdown handling — preserves formatting, code blocks, and structure

Installation

Install the extension:

pi install git:github.com/soikat/pi-grammar

Or try it without installing:

pi -e git:github.com/soikat/pi-grammar

Usage

1️⃣ Quick Inline Check

For a quick grammar check on a single sentence or short text:

?grammar I has went to the store yesterday and buyed some grocerys.

The LLM will instantly analyze and provide corrections.

2️⃣ Text Editor Mode

Open a multi-line editor for longer text:

/grammar

Or pass text directly as an argument:

/grammar I has went to the store yesterday.

3️⃣ Markdown File Grammar Check

Check a file:

/grammar-file ./README.md

Without arguments, you'll be prompted to enter the file path:

/grammar-file

What happens:

  1. The file is read and analyzed for grammar issues
  2. The LLM provides:
    • List of issues found with explanations
    • Complete corrected content in a markdown code block
  3. File context is saved for the next step

Save corrections:

After reviewing the LLM's corrections, run:

/grammar-save

You'll be prompted to choose:

  • Overwrite original file — Replaces the original with corrections (requires confirmation)
  • Create new file (with -fixed suffix) — Saves as filename-fixed.md
  • Create new file (custom name) — You choose the filename

Copy the corrected markdown content from the LLM's response and paste it into the editor that opens.

4️⃣ Let the LLM Handle Everything

You can also ask the LLM directly and it will use the appropriate tool:

For files:

Check the grammar in ./docs/guide.md and fix any issues

For text:

Can you check the grammar in this paragraph: "Their going too the store to buy there grocerys."

The LLM has access to two tools:

  • grammar_check — For text snippets (rule-based + LLM analysis)
  • grammar_check_file — For markdown files (can check, fix, and save)

What Gets Checked

The extension performs rule-based checks for:

✅ Spelling — 50+ common misspellings (recieve → receive, teh → the, etc.)
✅ Grammar — Article usage (a/an), comma splices, repeated words
✅ Punctuation — Missing spaces, double spaces
✅ Capitalization — Sentence starts after periods
✅ Style (detailed mode) — Passive voice, long sentences, weak words

Then the LLM performs deeper analysis for:

  • Context-dependent corrections
  • Complex grammar rules
  • Natural phrasing improvements
  • Markdown-specific handling (preserves code blocks, links, formatting)

Example Workflows

Workflow 1: Quick File Fix

# 1. Check the file
/grammar-file ./blog-post.md

# 2. Review corrections (LLM shows issues + corrected content)

# 3. Save it
/grammar-save
# Choose: "Create new file (with -fixed suffix)"
# Result: blog-post-fixed.md is created

Workflow 2: Let the LLM Handle It

Check grammar in ./README.md, fix all issues, and save to a new file

The LLM will:

  1. Use grammar_check_file to analyze the file
  2. Provide corrected content
  3. Save it to README-fixed.md

Workflow 3: Inline Quick Checks

?grammar Their going too the store to buy there grocerys

Instant feedback without leaving the editor.

Commands Reference

Command Description
?grammar <text> Quick inline grammar check
/grammar [text] Open editor for multi-line check, or check provided text
/grammar-file [path] Analyze grammar in a markdown file
/grammar-save Save corrected content after /grammar-file

Tools (LLM-Callable)

Tool Description
grammar_check Check grammar in text with rule-based + LLM analysis
grammar_check_file Check grammar in markdown files with options to save

Supported File Types

While optimized for markdown files (.md, .markdown, .mdx), the extension can check grammar in any text file. You'll receive a warning for non-markdown files with the option to proceed.

How It Works

  1. Rule-based pre-check scans for common issues
  2. LLM analysis provides nuanced corrections and context-aware fixes
  3. Smart markdown handling preserves:
    • Code blocks (fenced and inline)
    • Links and images
    • Headers and formatting
    • Lists and tables

Troubleshooting

File not found?

  • Use relative paths from your current working directory
  • Or use absolute paths: /full/path/to/file.md

LLM not providing corrected content?

  • Ask explicitly: "Please provide the full corrected content in a markdown code block"
  • The extension expects content wrapped in ```markdown blocks

Want to check multiple files?

  • Run /grammar-file for each file separately
  • Or ask the LLM: "Check grammar in all markdown files in ./docs/"

Uninstall

pi remove git:github.com/soikat/pi-grammar

Contributing

Found a bug or have a feature request? Open an issue on GitHub.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages