Skip to main content

This package helps users identify and avoid common pitfalls in web and HTML development by analyzing text-based input—like code snippets, design descriptions, or technical discussions—and returning a

Project description

webdev-pitfall-analyzer

PyPI version License: MIT Downloads LinkedIn

webdev-pitfall-analyzer helps developers quickly spot common web‑development pitfalls—security issues, accessibility problems, performance bottlenecks, outdated patterns, and more—by analysing short text inputs such as code snippets, design questions, or discussion fragments. The package uses an LLM (by default ChatLLM7 from langchain_llm7) to return a concise, structured list of warnings and best‑practice recommendations.


📦 Installation

pip install webdev_pitfall_analyzer

🚀 Quick start

from webdev_pitfall_analyzer import webdev_pitfall_analyzer

# Example HTML/JS snippet
snippet = """
<input type="text" onblur="doBadThing()" />
<script>
  function doBadThing() {
    eval(userInput);   // <- unsafe!
  }
</script>
"""

warnings = webdev_pitfall_analyzer(user_input=snippet)
print(warnings)

Output (example)

[
  "⚠️ Use of `eval` can lead to XSS vulnerabilities. Consider safer alternatives.",
  "⚠️ Missing `label` element for the input; this hurts accessibility.",
  "⚠️ Inline event handlers (`onblur`) are discouraged; attach listeners via JavaScript instead."
]

🛠️ Function signature

def webdev_pitfall_analyzer(
    user_input: str,
    api_key: Optional[str] = None,
    llm: Optional[BaseChatModel] = None,
) -> List[str]:
Parameter Type Description
user_input str The text (code, question, description, etc.) you want analysed.
api_key Optional[str] API key for ChatLLM7. If omitted, the function will look for the LLM7_API_KEY environment variable; if still not found it falls back to an unauthenticated request (may be rate‑limited).
llm Optional[BaseChatModel] Any LangChain‑compatible LLM instance. If not supplied, the default ChatLLM7 (from langchain_llm7) is used.

The function returns a list of warning/recommendation strings. If the underlying LLM call fails, a RuntimeError is raised.


🔧 Using a custom LLM

You can pass any LangChain chat model that follows the BaseChatModel interface.

OpenAI

from langchain_openai import ChatOpenAI
from webdev_pitfall_analyzer import webdev_pitfall_analyzer

my_llm = ChatOpenAI(model="gpt-4o-mini")
result = webdev_pitfall_analyzer(user_input="...", llm=my_llm)

Anthropic

from langchain_anthropic import ChatAnthropic
from webdev_pitfall_analyzer import webdev_pitfall_analyzer

my_llm = ChatAnthropic(model="claude-3-haiku-20240307")
result = webdev_pitfall_analyzer(user_input="...", llm=my_llm)

Google GenAI

from langchain_google_genai import ChatGoogleGenerativeAI
from webdev_pitfall_analyzer import webdev_pitfall_analyzer

my_llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
result = webdev_pitfall_analyzer(user_input="...", llm=my_llm)

🔑 API key for ChatLLM7

The default free tier of LLM7 is sufficient for most occasional analyses.

  • Set the key once in your environment:
export LLM7_API_KEY="your_llm7_key"
  • Or pass it directly:
result = webdev_pitfall_analyzer(user_input="...", api_key="your_llm7_key")

Obtain a free key by registering at https://token.llm7.io/.


📚 What the analyzer looks for

  • Security – unsafe functions (eval, innerHTML, etc.), injection risks.
  • Accessibility – missing ARIA attributes, improper heading structure, unlabeled form controls.
  • Performance – blocking synchronous XHR, large inline assets, unnecessary reflows.
  • Modern best practices – deprecated APIs, outdated HTML5 elements, inefficient CSS selectors.

The underlying prompt (human_prompt, system_prompt) can be customised by forking the repository.


📂 Repository

🛠️ Issues & feature requests: https://github.com/chigwell/webdev_pitfall_analyzer/issues


👤 Author

Eugene Evstafev
Email: hi@eugene.plus
GitHub: https://github.com/chigwell


📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webdev_pitfall_analyzer-2025.12.21133820.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file webdev_pitfall_analyzer-2025.12.21133820.tar.gz.

File metadata

File hashes

Hashes for webdev_pitfall_analyzer-2025.12.21133820.tar.gz
Algorithm Hash digest
SHA256 4e2ee0b7f2bc69bde02653e741de7ea99b6be28fc074c2cf5f8994529351f907
MD5 d578c676adaeefc5d3023811157b88c6
BLAKE2b-256 90c57bf2a8bb62f57811c1ee45c46e847bcbe083fd7c99a0f8cb40794dae12f1

See more details on using hashes here.

File details

Details for the file webdev_pitfall_analyzer-2025.12.21133820-py3-none-any.whl.

File metadata

File hashes

Hashes for webdev_pitfall_analyzer-2025.12.21133820-py3-none-any.whl
Algorithm Hash digest
SHA256 85dc7ca271f764240177a41988946d642faca23348d2648f71449bb0579d2019
MD5 363c50a32169513749d5053aee980cfd
BLAKE2b-256 170ccdee8739f57daa138796c94daf1e85f04a4c37768089a4ade98911c76199

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page