Skip to content

Python Code Assistant skill#2

Open
tmikula-dev wants to merge 4 commits into
masterfrom
feature/python-standards-skill
Open

Python Code Assistant skill#2
tmikula-dev wants to merge 4 commits into
masterfrom
feature/python-standards-skill

Conversation

@tmikula-dev

Copy link
Copy Markdown

Background

This pull request introduces a comprehensive Python coding standards skill for CPS projects, including detailed documentation, evaluation scenarios, and context-based triggers for activation. The main changes are the addition of the standards documentation, a set of evaluation prompts to test adherence, and a trigger configuration that ensures the skill activates only in appropriate Python-related contexts.

Related issus

Closes #https://github.com/absa-group/cps-agentic-toolkit/issues/5

@tmikula-dev tmikula-dev self-assigned this May 18, 2026
@tmikula-dev tmikula-dev added the enhancement New feature or request label May 18, 2026

@oto-macenauer-absa oto-macenauer-absa left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While 336 lines is under the limit, the skill is a flat wall of coding standards. There's no decision logic, no branching, no "if X then load Y." Compare with create-issue which has a two-phase architecture and delegates mechanical work.

Comment thread skills/python-standards/SKILL.md Outdated
---
name: python-standards
description: >-
Python coding standards for CPS projects. Covers repository-first conventions, type annotations, error handling, testing, logging, documentation, async code, and dependency hygiene. Activate this skill whenever the user is editing or creating .py files, working in a Python project, or asks for help writing functions, classes, tests, modules, or fixing code - even if they do not say "Python" explicitly. Also triggers on questions about coding conventions, type hints, pytest, imports, logging setup, or dependency management in a Python context.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every time someone edits a .py file in a CPS project, this skill injects ~1,300 tokens of mostly-known Python conventions. Over a day of Python work (say 20 skill activations), that's ~26,000 wasted input tokens for information the model already has.

If it's going to be injected very often, I'd make it considerably slimmer. Like 100 lines top, keep only the important rules, models already know how to write Python.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It this expected to be in review phase or in dev phase?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the skill could be shortened as it is not for human but for AI.
Shorting - caveman style.

Comment thread skills/python-standards/SKILL.md Outdated
- Create custom exception classes for domain-specific errors rather than reusing generic built-ins.
- Fail fast and fail loudly: validate inputs early and raise immediately on invalid state.

```python

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The skill doesn't require the code examples to follow the guidelines, if it's helpful it should be moved to references and loaded only on demand.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

Comment thread skills/python-standards/SKILL.md Outdated
- For vendor API responses, be lenient about unknown fields (vendors may add them) but strict about expected fields.
- Define data contracts as explicit models or data classes, not raw dicts. Typed structures make the expected shape discoverable and enforceable.

## Testing

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not every python code contains tests, this should be reference and loaded only for tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the skill could start with kind of decision table. Helping with exact navigation.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, agree. It's unlikely that 1 common standard will be applicable broadly anyway

Comment thread skills/python-standards/SKILL.md Outdated
Before applying these standards in an existing repository:

- Inspect the nearby Python files and project configuration first.
- Follow the repository's established formatter, import sorter, linter, type checker, test framework, packaging flow, and docstring style unless the user asks you to change them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting part ... maybe the skill should stop here if the repo contains all of the information already, because then it would add the same info twice.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is possible to replace some AI detections by smart scripts?
It woul reduce AI activity and be more determistic.

@miroslavpojer miroslavpojer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, see my reactions in comments.

Comment thread skills/python-standards/SKILL.md Outdated

## Type Annotations

Python is dynamically typed, which means entire categories of bugs (type mismatches, contract violations, null references) can reach production undetected. Type annotations are the primary defence against this.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what an LLM already knows though

Comment thread skills/python-standards/SKILL.md Outdated

### Rules

- Annotate all public function signatures: both parameters and return types.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, I wouldn't be that strict in general. Maybe some people don't want to be bothered for some scripts or some less-production grade code. Maybe let the user choose this during the first phase of the skill - let the user choose and the skill will navigate it based on that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about two regimes - it will ask 1st.

Comment thread skills/python-standards/SKILL.md Outdated

### Structure

- Follow the repository's existing test layout. In repos that mirror the source tree, `src/handlers/` maps to `tests/unit/handlers/`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, the sub dir unit/ is not really that commonly used I think

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be a bit less strict. Not everyone has integration tests also

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have, Maybe make it smart using some if section + detect?

Comment thread skills/python-standards/SKILL.md Outdated
## Dependencies

- Follow the repository's existing dependency-management approach. For new projects, or repos that already use modern packaging, prefer `pyproject.toml` with PEP 621 metadata.
- If the repository uses `requirements.txt`, constraints files, Poetry, uv, or another established workflow, stay consistent unless the user explicitly asks for a migration.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this sentence I think. What do you mean by constraints files?

Comment thread skills/python-standards/SKILL.md Outdated

## Database

CPS projects prefer to access databases directly using `aiosql` to keep SQL out of Python string literals.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what everyone will prefer I think, but can be an optional recdommendation. Maybe we can be strict in a way of not having hard-coded sql statements in python strings, and recommend aiosql, but proabbly not insisting on it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this repo no CPS should be present.

Comment thread skills/python-standards/SKILL.md Outdated
- Use the `secrets` module for generating tokens and random values, not `random` (which is not cryptographically secure).
- Validate and sanitise all user-provided input before using it in queries, commands, or file paths.
- Be explicit about timeouts on all network calls. Hanging connections are a denial-of-service vector.
- Lock or pin dependencies according to the repository's release process, and audit them regularly. Supply-chain attacks through compromised packages are a real and growing threat.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be a bit more procedural. This sounds like a recommendation to the user of the skill

@tmikula-dev

Copy link
Copy Markdown
Author

I did read all of yours comments and did a refactored another version of the skill. This one should:

  • had a context decision table at the initial phase
  • two skill modes one strict and one loose
  • no CPS info at all in the skill
  • shortened SKILL.md to 114 rows
  • new references/ and testing/ modules created
  • removing familiar info that LLM knows, focusing on the stuff that is defining a good python code assistant

@lsulak @oto-macenauer-absa @miroslavpojer
Please re-review the current state. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants