How to automatically add edit link on frontpage post of any wordpress theme?

As lot of themes use the_content() to display the post content. you can use the_content filter hook to add the edit link before/after the content.

Since you want this work outside themes, you have to put the following code in a file, and store it in your plugins folder then activate it as a plugin.

<?php
/**
 * Plugin Name: Add Edit Link in Frontend
 * Description: Append post edit link to content
 * Version: 1.0.0
 */

function wpael_content_edit_link( $content ) {

    $content .= '<br /><div style="font-size: 14px"><a href="'.  get_edit_post_link( get_the_ID() ) . '">Edit</a></div>';
    return $content;
}
add_filter( 'the_content', 'wpael_content_edit_link', 10 );