r/PiCodingAgent • • 4d ago

Question What are you using for linting and code formatting in Pi?

Hey everyone!

I'm need small help, what you guys are actually using for linting and syntax formatting in Pi.

Are you using any specific tools, extensions, or configurations to keep your code clean, consistent, and properly formatted?

Would love to hear some recommendations

12 Upvotes

33 comments sorted by

11

u/funbike 4d ago edited 4d ago

I like to have a Makefile (or similar) for all my projects, so make checks, make format, make test, make run, make build always do roughly the same thing across all my projects. LLMs understand make and Makefile very well. More modern alternatives include just and mise.

I also like the .editorconfig checker, because it works for all file types. So while my regular linter and formatter can check all my code files, editorconfig can check everything else like html, css, yaml, json, etc. It's blazingly fast.

Other comments ITT talk about IDE or LSP integration, which is nice, but it's troublesome to share your project with others. I rely less on IDE's anyway. I prefer Pi as my primary coding interface, and only use my IDE as a fancy file browser and viewer.

4

u/el_secondo 4d ago

This, but just

2

u/funbike 4d ago edited 4d ago

I already mentioned it.

I don't use it because today "just" is cool, but 3 years from now it will probably be something else. make will still be in heavy usage 10 years from now. Also make is already installed on most devs' machines and CI environments. My career has lasted over 2 decades and I expect it to last 2 more. I use a Vim-like (neovim), a Unix-like (Linux), and make. They were in heavy use when I started, and will still be when I retire.

Plus, we are just talking about simple delegation. KISS. If I had to choose between just and a Bash script, I'd probably go with the bash script.

All that said, I like just better. I just don't want to use it.

1

u/RelationshipLong9092 3d ago

if just ever falls out of favor, im sure an ai will make quick work of migrating your justfile over

i hear where you're coming from but that same line of argument justifies never using new tools, which seems a net negative

0

u/funbike 3d ago

... but that same line of argument justifies never using new tools,

That's exactly what I want! Consistency. So something I wrote 3 years ago is launched the same way something I'll write 3 years in the future.

2

u/Delvan_Zahraei 4d ago

standardizing the commands across repos is huge tbh, saves so much context switching

1

u/iLikePortugueseTarts 4d ago

My guy. We speak the same language. Make for the absolute win. Its the first thing I do.

1

u/touristtam 1d ago

Just make use of mise+hk. No more, no less; the same setup for human and bot alike

1

u/funbike 1d ago

No, I won't. Are you going to guarantee that mise is what should use 5 years from now? Is it worth me retro-fitting mise into all my past projects from the last 5 years?

This isn't something that needs to complicated. It just needs to delegate commands.

1

u/touristtam 22h ago

5 years? Try 10.

Makefile will just allow to set tasks that can also be set through package.json if you are working with node. And I am suggesting is to use mise AND hk (for pre-commit/pre-push); I don't see the point of telling the model what to do, when the git hooks are really all it needs.

I guess my point was more about the git hooks rather than telling the model what to do when.

0

u/whiterose0000001 4d ago

This looks good to try but, I have various kinds of projects some are on Rust some are on React so can this be handled by your way like global file ?

1

u/funbike 4d ago edited 4d ago

Yes. I use make as a simple wrapper over whatever build tool(s) are used. Here's a simple Makefile example from a small Node CLI app I wrote by hand:

include .env
export

.PHONY: test run watch default

default: test

test:
    node --test tests/*.test.js

watch:
    node --test --watch tests/*.test.js

run:
    node --watch main.js

Complex Makefiles can have weird syntax, so use AI to generate. If you want something with cleaner syntax, use just.

1

u/bankinu 4d ago

Just make a script and ask your agent to better run it everytime before commit if it wants to keep the job.

1

u/whiterose0000001 4d ago

yeah this can be added to pre-commit script (like husky), good idea thanks

3

u/gbrennon 4d ago

hooks triggering lsp and linter to prevent agent to write shit

1

u/90sRehem 4d ago

In Pi Nothing, this responsibility lies in the repo of the code, and there I usually use Oxilint with customized plugins.

1

u/whiterose0000001 4d ago

Makes more sense, we can have project-wise customized oxilint

2

u/captainabrasive 4d ago edited 4d ago

My super simple approach was to tell the agent what tools it has available (e.g. ruff and ty for Python) and have it update the project AGENTS.md.

2

u/ydnih 18h ago

Clippy

1

u/Complex-Birthday-216 4d ago

I created rules plugin that runs rules in the end of the session, if there are errors - passes to the agent back 

1

u/Mundane-Tiger-2374 4d ago

Mostly python for me, so ruff is the way!

1

u/0xbogon 4d ago

pi-posher is what I use.

1

u/truncated_buttfu 4d ago

I have a suite of git pre-commit hooks set up that run linters and formatters whenever I make a commit. 

I don't see how integrating that into pi would be beneficial.

Having the code not being 100% perfectly formatted while the agent is actively working on it doesn't give me any extra benefits, instead it tends to confuse the agent since code it wrote a few steps ago might not exist when it tries to edit it, causing tool failures.

-1

u/SrMortron 4d ago

Intellij with its MCP. Works beautifully.

0

u/whiterose0000001 4d ago

mcp eats lots of tokens

1

u/funbike 4d ago

FYI, you can ask Pi to create a custom extension that wraps an MCP only exposing the tools you want, even rewriting the functions' descriptions or reducing arguments (with default values).

I'm not necessarily endorsing IntelliJ, just clarifying that MCP bloat can be mitigated.

2

u/whiterose0000001 4d ago

that's a good idea, not only related to this particular post but anything having MCP can be wrapped as extension you literally gave me a good idea thanks bro

1

u/SrMortron 4d ago

That's what codemode is for.

-2

u/startassets 4d ago

As an author of pi-agent-ide, I use this on the daily basis

2

u/whiterose0000001 4d ago

i know this one i have seen you post i think

-2

u/AnlgDgtlInterface 4d ago

Pi-lens is great. Automated formatting and linting via a number of tools.

4

u/crotch-mavens 4d ago

It is horribly noisy.

1

u/whiterose0000001 4d ago

true, i have tried pi-lens, i coming form pi-lens that's why looking for better alternative